]> git.ipfire.org Git - thirdparty/linux.git/commit
bpf: force BPF_F_RDONLY_PROG on insn array creation
authorAnton Protopopov <a.s.protopopov@gmail.com>
Fri, 28 Nov 2025 06:32:23 +0000 (06:32 +0000)
committerAlexei Starovoitov <ast@kernel.org>
Fri, 28 Nov 2025 23:15:43 +0000 (15:15 -0800)
commit7feff23cdf2ecd30909872f3be1da820df839ab0
tree2121e89fecabf2830a3d00602cadeaee64e21c85
parent688b745401ab16e2e1a3b504863f0a45fd345638
bpf: force BPF_F_RDONLY_PROG on insn array creation

The original implementation added a hack to check_mem_access()
to prevent programs from writing into insn arrays. To get rid
of this hack, enforce BPF_F_RDONLY_PROG on map creation.

Also fix the corresponding selftest, as the error message changes
with this patch.

Suggested-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: Anton Protopopov <a.s.protopopov@gmail.com>
Link: https://lore.kernel.org/r/20251128063224.1305482-2-a.s.protopopov@gmail.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
kernel/bpf/bpf_insn_array.c
kernel/bpf/verifier.c
tools/testing/selftests/bpf/progs/verifier_gotox.c