bpf.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Alexei Starovoitov <alexei.starovoitov@gmail.com>
To: Song Liu <songliubraving@fb.com>
Cc: Yonghong Song <yhs@fb.com>, 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: Mon, 1 Jun 2020 13:40:35 -0700	[thread overview]
Message-ID: <CAADnVQ+RBSC+rkYXOrswRsQVEpWOj_8OHn5Y+0XO6CxRPGXqdg@mail.gmail.com> (raw)
In-Reply-To: <DD249D2B-7F03-43A2-99D2-002D1CA742C7@fb.com>

On Fri, May 29, 2020 at 1:45 PM Song Liu <songliubraving@fb.com> wrote:
>
>
>
> > 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")

Applied. Thanks

      reply	other threads:[~2020-06-01 20:40 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
2020-06-01 20:40   ` Alexei Starovoitov [this message]

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=CAADnVQ+RBSC+rkYXOrswRsQVEpWOj_8OHn5Y+0XO6CxRPGXqdg@mail.gmail.com \
    --to=alexei.starovoitov@gmail.com \
    --cc=Kernel-team@fb.com \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=hch@lst.de \
    --cc=songliubraving@fb.com \
    --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).