lkml.org 
[lkml]   [2022]   [Sep]   [6]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [PATCH v16 06/12] bpf: Add bpf_lookup_*_key() and bpf_key_put() kfuncs
On Tue, Sep 6, 2022 at 1:01 AM Roberto Sassu
<roberto.sassu@huaweicloud.com> wrote:
>
> > > +struct bpf_key *bpf_lookup_user_key(u32 serial, u64 flags)
> > > +{
> > > + key_ref_t key_ref;
> > > + struct bpf_key *bkey;
> > > +
> > > + if (flags & ~KEY_LOOKUP_ALL)
> > > + return NULL;
> > > +
> > > + /*
> > > + * Permission check is deferred until the key is used, as
> > > the
> > > + * intent of the caller is unknown here.
> > > + */
> > > + key_ref = lookup_user_key(serial, flags,
> > > KEY_DEFER_PERM_CHECK);
> > > + if (IS_ERR(key_ref))
> > > + return NULL;
> > > +
> > > + bkey = kmalloc(sizeof(*bkey), GFP_ATOMIC);
> >
> > Since this function (due to lookup_user_key) is sleepable, do we
> > really need GFP_ATOMIC here?
>
> Daniel suggested it for bpf_lookup_system_key(), so that the kfunc does
> not have to be sleepable.

Hold on. It has to be sleepable. Just take a look
at what lookup_user_key is doing inside.

> For symmetry, I did the same to
> bpf_lookup_user_key(). Will switch back to GFP_KERNEL.
>
> Thanks
>
> Roberto
>

\
 
 \ /
  Last update: 2022-09-06 20:46    [W:0.079 / U:0.844 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site