[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20220722041056.r2ozhs4p3s7mt7go@macbook-pro-3.dhcp.thefacebook.com>
Date: Thu, 21 Jul 2022 21:10:56 -0700
From: Alexei Starovoitov <alexei.starovoitov@...il.com>
To: Kumar Kartikeya Dwivedi <memxor@...il.com>
Cc: bpf@...r.kernel.org, Alexei Starovoitov <ast@...nel.org>,
Andrii Nakryiko <andrii@...nel.org>,
Daniel Borkmann <daniel@...earbox.net>,
Pablo Neira Ayuso <pablo@...filter.org>,
Florian Westphal <fw@...len.de>,
Jesper Dangaard Brouer <brouer@...hat.com>,
Toke Høiland-Jørgensen <toke@...hat.com>,
Lorenzo Bianconi <lorenzo@...nel.org>, netdev@...r.kernel.org,
netfilter-devel@...r.kernel.org
Subject: Re: [PATCH bpf-next v7 04/13] bpf: Add support for forcing kfunc
args to be trusted
On Thu, Jul 21, 2022 at 03:42:36PM +0200, Kumar Kartikeya Dwivedi wrote:
> +/* Trusted arguments are those which are meant to be referenced arguments with
> + * unchanged offset. It is used to enforce that pointers obtained from acquire
> + * kfuncs remain unmodified when being passed to helpers taking trusted args.
> + *
> + * Consider
> + * struct foo {
> + * int data;
> + * struct foo *next;
> + * };
> + *
> + * struct bar {
> + * int data;
> + * struct foo f;
> + * };
> + *
> + * struct foo *f = alloc_foo(); // Acquire kfunc
> + * struct bar *b = alloc_bar(); // Acquire kfunc
> + *
> + * If a kfunc set_foo_data() wants to operate only on the allocated object, it
> + * will set the KF_TRUSTED_ARGS flag, which will prevent unsafe usage like:
> + *
> + * set_foo_data(f, 42); // Allowed
> + * set_foo_data(f->next, 42); // Rejected, non-referenced pointer
> + * set_foo_data(&f->next, 42);// Rejected, referenced, but bad offset
> + * set_foo_data(&b->f, 42); // Rejected, referenced, but wrong type
I think you meant to swap above two comments ?
That's what I did while applying.
Also fixed typo in Fixes tag in patch 13. It was missing a letter in sha.
Since there are 3 other pending patchsets in patchwork that add new kfuncs
this cleanup of kfunc registration couldn't have come at better time.
Thank you for doing this work.
Powered by blists - more mailing lists