From: sdf@google.com
To: Daniel Borkmann <daniel@iogearbox.net>
Cc: netdev@vger.kernel.org, bpf@vger.kernel.org, ast@kernel.org,
andrii@kernel.org
Subject: Re: [PATCH bpf-next v2 2/2] bpf: use kvmalloc for map keys in syscalls
Date: Wed, 18 Aug 2021 16:02:22 -0700 [thread overview]
Message-ID: <YR2RfkFHtUoO5Kx9@google.com> (raw)
In-Reply-To: <afd42427-f424-5f0d-360c-5fcdfc078704@iogearbox.net>
On 08/19, Daniel Borkmann wrote:
> On 8/17/21 5:45 PM, Stanislav Fomichev wrote:
> > Same as previous patch but for the keys. memdup_bpfptr is renamed
> > to vmemdup_bpfptr (and converted to kvmalloc).
> >
> > Signed-off-by: Stanislav Fomichev <sdf@google.com>
> > ---
> > include/linux/bpfptr.h | 12 ++++++++++--
> > kernel/bpf/syscall.c | 34 +++++++++++++++++-----------------
> > 2 files changed, 27 insertions(+), 19 deletions(-)
> >
> > diff --git a/include/linux/bpfptr.h b/include/linux/bpfptr.h
> > index 5cdeab497cb3..84eeffb4316a 100644
> > --- a/include/linux/bpfptr.h
> > +++ b/include/linux/bpfptr.h
> > @@ -62,9 +62,17 @@ static inline int copy_to_bpfptr_offset(bpfptr_t
> dst, size_t offset,
> > return copy_to_sockptr_offset((sockptr_t) dst, offset, src, size);
> > }
> > -static inline void *memdup_bpfptr(bpfptr_t src, size_t len)
> > +static inline void *vmemdup_bpfptr(bpfptr_t src, size_t len)
> nit: should we just name it kvmemdup_bpfptr() in that case?
Sounds good!
> > {
> > - return memdup_sockptr((sockptr_t) src, len);
> > + void *p = kvmalloc(len, GFP_USER | __GFP_NOWARN);
> > +
> > + if (!p)
> > + return ERR_PTR(-ENOMEM);
> > + if (copy_from_sockptr(p, (sockptr_t) src, len)) {
> Also, I think this one should rather use copy_from_bpfptr() here.
Ah, missed that one, thanks!
> > + kvfree(p);
> > + return ERR_PTR(-EFAULT);
> > + }
> > + return p;
> > }
> Rest lgtm, thanks!
next prev parent reply other threads:[~2021-08-18 23:02 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-08-17 15:45 [PATCH bpf-next v2 1/2] bpf: use kvmalloc for map values in syscall Stanislav Fomichev
2021-08-17 15:45 ` [PATCH bpf-next v2 2/2] bpf: use kvmalloc for map keys in syscalls Stanislav Fomichev
2021-08-17 16:25 ` Song Liu
2021-08-18 22:24 ` Daniel Borkmann
2021-08-18 23:02 ` sdf [this message]
2021-08-17 16:19 ` [PATCH bpf-next v2 1/2] bpf: use kvmalloc for map values in syscall Song Liu
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=YR2RfkFHtUoO5Kx9@google.com \
--to=sdf@google.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=netdev@vger.kernel.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.