From: "Alexei Starovoitov" <alexei.starovoitov@gmail.com>
To: "Kumar Kartikeya Dwivedi" <memxor@gmail.com>, <bpf@vger.kernel.org>
Cc: "Alexei Starovoitov" <ast@kernel.org>,
"Andrii Nakryiko" <andrii@kernel.org>,
"Daniel Borkmann" <daniel@iogearbox.net>,
"Eduard Zingerman" <eddyz87@gmail.com>,
"Emil Tsalapatis" <emil@etsalapatis.com>,
"Ihor Solodrai" <ihor.solodrai@linux.dev>,
"Tejun Heo" <tj@kernel.org>, <kkd@meta.com>,
<kernel-team@meta.com>
Subject: Re: [PATCH bpf-next v3 05/15] compiler_types: Add __arena and __nullable BTF type tag qualifiers
Date: Fri, 16 Oct 2026 01:08:24 +0000 [thread overview]
Message-ID: <DM5V06J7GLXR.2BJ4ZJ3IN5TT@gmail.com> (raw)
In-Reply-To: <20261015234125.3152346-6-memxor@gmail.com>
On Thu Oct 15, 2026 at 11:41 PM UTC, Kumar Kartikeya Dwivedi wrote:
> Kernel structures increasingly want to publish pointers into a BPF arena
> to the BPF programs they are shared with, and some pointer members that
> reach programs as trusted are legitimately NULL at times. Neither can be
> expressed today: a pointer member reaches the program as an ordinary
> kernel pointer, and sched_ext resorts to a plain u64 holding a
> pre-translated arena address that programs cast before use.
>
> Define __arena and __nullable as BTF type tags, the way __user, __rcu
> and __percpu already are, so that tagged members survive into vmlinux
> and module BTF and the verifier can act on them. To kernel code and to
> sparse the qualifiers are empty: the pointers are ordinary kernel
> pointers. The verifier side follows in the next patches.
>
> Signed-off-by: Kumar Kartikeya Dwivedi <memxor@gmail.com>
> ---
> include/linux/compiler_types.h | 10 ++++++++++
> 1 file changed, 10 insertions(+)
>
> diff --git a/include/linux/compiler_types.h b/include/linux/compiler_types.h
> index c5921f139007..e97ee2d4d1df 100644
> --- a/include/linux/compiler_types.h
> +++ b/include/linux/compiler_types.h
> @@ -51,6 +51,8 @@
> # define __iomem __attribute__((noderef, address_space(__iomem)))
> # define __percpu __attribute__((noderef, address_space(__percpu)))
> # define __rcu __attribute__((noderef, address_space(__rcu)))
> +# define __arena
> +# define __nullable
> static inline void __chk_user_ptr(const volatile void __user *ptr) { }
> static inline void __chk_io_ptr(const volatile void __iomem *ptr) { }
> /* other */
> @@ -70,6 +72,14 @@ static inline void __chk_io_ptr(const volatile void __iomem *ptr) { }
> # define __iomem
> # define __percpu __percpu_qual BTF_TYPE_TAG(percpu)
> # define __rcu BTF_TYPE_TAG(rcu)
> +/*
> + * Qualifiers for the BPF verifier rather than address spaces: __arena marks
> + * a pointer into a BPF arena, __nullable a pointer that may be NULL. They
> + * reach BPF programs as BTF type tags on kernel struct members; to kernel
> + * code the pointers are ordinary.
> + */
> +# define __arena BTF_TYPE_TAG(arena)
> +# define __nullable BTF_TYPE_TAG(nullable)
I feel this is too early to put this for the whole kernel to use.
Only couple fields in sched-ext need it, right?
So sched-ext can define them locally.
next prev parent reply other threads:[~2026-10-16 1:08 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-15 23:41 [PATCH bpf-next v3 00/15] Fix some arena paper cuts Kumar Kartikeya Dwivedi
2026-10-15 23:41 ` [PATCH bpf-next v3 01/15] bpf: Compute the program digest before resolving the fd_array Kumar Kartikeya Dwivedi
2026-10-16 0:28 ` bot+bpf-ci
2026-10-15 23:41 ` [PATCH bpf-next v3 02/15] selftests/bpf: Bind an exclusive map through a continuous fd_array Kumar Kartikeya Dwivedi
2026-10-15 23:53 ` sashiko-bot
2026-10-16 0:00 ` Kumar Kartikeya Dwivedi
2026-10-15 23:41 ` [PATCH bpf-next v3 03/15] libbpf: Keep the fd_array fill index out of bpf_program__clone() Kumar Kartikeya Dwivedi
2026-10-15 23:41 ` [PATCH bpf-next v3 04/15] selftests/bpf: Clone a program that calls a module kfunc Kumar Kartikeya Dwivedi
2026-10-16 0:12 ` bot+bpf-ci
2026-10-15 23:41 ` [PATCH bpf-next v3 05/15] compiler_types: Add __arena and __nullable BTF type tag qualifiers Kumar Kartikeya Dwivedi
2026-10-16 1:08 ` Alexei Starovoitov [this message]
2026-10-16 1:15 ` Kumar Kartikeya Dwivedi
2026-10-15 23:41 ` [PATCH bpf-next v3 06/15] bpf: Recognize __nullable on pointer members of kernel structs Kumar Kartikeya Dwivedi
2026-10-15 23:54 ` sashiko-bot
2026-10-16 0:00 ` Kumar Kartikeya Dwivedi
2026-10-16 1:09 ` Alexei Starovoitov
2026-10-16 1:24 ` Kumar Kartikeya Dwivedi
2026-10-16 1:31 ` Alexei Starovoitov
2026-10-16 1:39 ` Kumar Kartikeya Dwivedi
2026-10-16 1:53 ` Alexei Starovoitov
2026-10-16 2:04 ` Kumar Kartikeya Dwivedi
2026-10-16 2:20 ` Alexei Starovoitov
2026-10-15 23:41 ` [PATCH bpf-next v3 07/15] bpf: Turn loads of __arena pointer members into arena pointers Kumar Kartikeya Dwivedi
2026-10-15 23:41 ` [PATCH bpf-next v3 08/15] selftests/bpf: Test __nullable pointer members Kumar Kartikeya Dwivedi
2026-10-15 23:41 ` [PATCH bpf-next v3 09/15] selftests/bpf: Test __arena " Kumar Kartikeya Dwivedi
2026-10-16 1:11 ` Alexei Starovoitov
2026-10-16 1:39 ` Kumar Kartikeya Dwivedi
2026-10-15 23:41 ` [PATCH bpf-next v3 10/15] libbpf: Bind the arena of an object to every program in it Kumar Kartikeya Dwivedi
2026-10-16 0:28 ` bot+bpf-ci
2026-10-15 23:41 ` [PATCH bpf-next v3 11/15] selftests/bpf: Test arena binding by libbpf Kumar Kartikeya Dwivedi
2026-10-16 0:28 ` bot+bpf-ci
2026-10-15 23:41 ` [PATCH bpf-next v3 12/15] bpf: Set up the arena base only in functions that use it Kumar Kartikeya Dwivedi
2026-10-16 1:13 ` Alexei Starovoitov
2026-10-15 23:41 ` [PATCH bpf-next v3 13/15] libbpf: Render the arena type tag with its address space Kumar Kartikeya Dwivedi
2026-10-15 23:41 ` [PATCH bpf-next v3 14/15] selftests/bpf: Test the address space rendering of the arena type tag Kumar Kartikeya Dwivedi
2026-10-15 23:41 ` [PATCH bpf-next v3 15/15] selftests/bpf: Test an arena kfunc argument passed from a subprogram Kumar Kartikeya Dwivedi
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=DM5V06J7GLXR.2BJ4ZJ3IN5TT@gmail.com \
--to=alexei.starovoitov@gmail.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=eddyz87@gmail.com \
--cc=emil@etsalapatis.com \
--cc=ihor.solodrai@linux.dev \
--cc=kernel-team@meta.com \
--cc=kkd@meta.com \
--cc=memxor@gmail.com \
--cc=tj@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox