From: Song Liu <songliubraving@fb.com>
To: Yonghong Song <yhs@fb.com>
Cc: bpf <bpf@vger.kernel.org>, Alexei Starovoitov <ast@kernel.org>,
"Daniel Borkmann" <daniel@iogearbox.net>,
Kernel Team <Kernel-team@fb.com>,
"Christoph Hellwig" <hch@lst.de>
Subject: Re: [PATCH bpf-next] bpf: use strncpy_from_unsafe_strict() in bpf_seq_printf() helper
Date: Fri, 29 May 2020 20:45:13 +0000 [thread overview]
Message-ID: <DD249D2B-7F03-43A2-99D2-002D1CA742C7@fb.com> (raw)
In-Reply-To: <20200529004810.3352219-1-yhs@fb.com>
> On May 28, 2020, at 5:48 PM, Yonghong Song <yhs@fb.com> wrote:
>
> In bpf_seq_printf() helper, when user specified a "%s" in the
> format string, strncpy_from_unsafe() is used to read the actual string
> to a buffer. The string could be a format string or a string in
> the kernel data structure. It is really unlikely that the string
> will reside in the user memory.
>
> This is different from Commit b2a5212fb634 ("bpf: Restrict bpf_trace_printk()'s %s
> usage and add %pks, %pus specifier") which still used
> strncpy_from_unsafe() for "%s" to preserve the old behavior.
>
> If in the future, bpf_seq_printf() indeed needs to read user
> memory, we can implement "%pus" format string.
>
> Based on discussion in [1], if the intent is to read kernel memory,
> strncpy_from_unsafe_strict() should be used. So this patch
> changed to use strncpy_from_unsafe_strict().
>
> [1]: https://lore.kernel.org/bpf/20200521152301.2587579-1-hch@lst.de/T/
>
> Cc: Christoph Hellwig <hch@lst.de>
> Signed-off-by: Yonghong Song <yhs@fb.com>
Acked-by: Song Liu <songliubraving@fb.com>
I guess we should add:
Fixes: 492e639f0c22 ("bpf: Add bpf_seq_printf and bpf_seq_write helpers")
next prev parent reply other threads:[~2020-05-29 20:45 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-05-29 0:48 [PATCH bpf-next] bpf: use strncpy_from_unsafe_strict() in bpf_seq_printf() helper Yonghong Song
2020-05-29 20:45 ` Song Liu [this message]
2020-06-01 20:40 ` Alexei Starovoitov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=DD249D2B-7F03-43A2-99D2-002D1CA742C7@fb.com \
--to=songliubraving@fb.com \
--cc=Kernel-team@fb.com \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=hch@lst.de \
--cc=yhs@fb.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).