[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-Id: <YR2RfkFHtUoO5Kx9@google.com>
Date: Wed, 18 Aug 2021 16:02:22 -0700
From: sdf@...gle.com
To: Daniel Borkmann <daniel@...earbox.net>
Cc: netdev@...r.kernel.org, bpf@...r.kernel.org, ast@...nel.org,
andrii@...nel.org
Subject: Re: [PATCH bpf-next v2 2/2] bpf: use kvmalloc for map keys in syscalls
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@...gle.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!
Powered by blists - more mailing lists