Re: [PATCH bpf-next 03/13] bpf: check CAP_SYS_ADMIN before looking up bpffs delegation names

From: Alexei Starovoitov

Date: Sat Oct 31 2026 - 13:03:50 EST


On Sat, Oct 31, 2026 at 06:09 AM Jay Wang <wanjay@xxxxxxxxxx> wrote:
> That is free today because the vmlinux BTF is parsed at boot. Once it
> is parsed on first use (CONFIG_DEBUG_INFO_BTF_LAZY, later in this
> series), it would let any user make the kernel parse it and keep it
> parsed until reboot, which is what the option is meant to avoid on
> systems that do not use BTF.

Any user can do that without this mount.
/sys/kernel/btf/vmlinux is 0444. With patch 9 one read() decompresses
5.5 MB into vmalloc_user() memory that is never freed.
The parse is the other 2 MB.
After the first use the kernel has what every BTF=y kernel has today.
There is nothing to guard.

> Check the capability first. An unprivileged caller could only ever set
> an empty mask; such a no-op delegate option, and a malformed value,
> now fail with EPERM as well instead of being accepted or failing with
> EINVAL. Privileged callers are not affected.

That changes what user space sees, with or without the option.
Drop this patch.