From 6147a140c99f1ded2b519dfbed17e781e5861bf3 Mon Sep 17 00:00:00 2001 From: Andrii Nakryiko Date: Thu, 21 Nov 2019 09:59:00 -0800 Subject: selftests/bpf: Ensure core_reloc_kernel is reading test_progs's data only test_core_reloc_kernel.c selftest is the only CO-RE test that reads and returns for validation calling thread's information (pid, tgid, comm). Thus it has to make sure that only test_prog's invocations are honored. Fixes: df36e621418b ("selftests/bpf: add CO-RE relocs testing setup") Reported-by: Alexei Starovoitov Signed-off-by: Andrii Nakryiko Signed-off-by: Alexei Starovoitov Acked-by: John Fastabend Link: https://lore.kernel.org/bpf/20191121175900.3486133-1-andriin@fb.com --- tools/testing/selftests/bpf/progs/test_core_reloc_kernel.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'tools/testing/selftests/bpf/progs/test_core_reloc_kernel.c') diff --git a/tools/testing/selftests/bpf/progs/test_core_reloc_kernel.c b/tools/testing/selftests/bpf/progs/test_core_reloc_kernel.c index 5d499ebdc4bd..270de441b60a 100644 --- a/tools/testing/selftests/bpf/progs/test_core_reloc_kernel.c +++ b/tools/testing/selftests/bpf/progs/test_core_reloc_kernel.c @@ -11,6 +11,7 @@ char _license[] SEC("license") = "GPL"; struct { char in[256]; char out[256]; + uint64_t my_pid_tgid; } data = {}; struct core_reloc_kernel_output { @@ -38,6 +39,9 @@ int test_core_kernel(void *ctx) uint32_t real_tgid = (uint32_t)pid_tgid; int pid, tgid; + if (data.my_pid_tgid != pid_tgid) + return 0; + if (CORE_READ(&pid, &task->pid) || CORE_READ(&tgid, &task->tgid)) return 1; -- cgit v1.2.3-59-g8ed1b