]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
selftests/bpf: check operations on untrusted ro pointers to mem
authorEduard Zingerman <eddyz87@gmail.com>
Wed, 25 Jun 2025 18:24:14 +0000 (11:24 -0700)
committerAlexei Starovoitov <ast@kernel.org>
Wed, 25 Jun 2025 22:13:16 +0000 (15:13 -0700)
commit12ed81f82391d073982cf0cd0b2d14e374e5112a
treedb9e70995200afe2b9a565411af99b60c6bf60b6
parentf2362a57aefff5816dc7cc078dab23de0a2918c4
selftests/bpf: check operations on untrusted ro pointers to mem

The following cases are tested:
- it is ok to load memory at any offset from rdonly_untrusted_mem;
- rdonly_untrusted_mem offset/bounds are not tracked;
- writes into rdonly_untrusted_mem are forbidden;
- atomic operations on rdonly_untrusted_mem are forbidden;
- rdonly_untrusted_mem can't be passed as a memory argument of a
  helper of kfunc;
- it is ok to use PTR_TO_MEM and PTR_TO_BTF_ID in a same load
  instruction.

Signed-off-by: Eduard Zingerman <eddyz87@gmail.com>
Link: https://lore.kernel.org/r/20250625182414.30659-4-eddyz87@gmail.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
tools/testing/selftests/bpf/prog_tests/mem_rdonly_untrusted.c [new file with mode: 0644]
tools/testing/selftests/bpf/progs/mem_rdonly_untrusted.c [new file with mode: 0644]