Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

selftests/bpf: Fix pid check in fexit_sleep test

bpf_get_current_pid_tgid() returns u64, whose upper 32 bits are the same
as userspace getpid() return value.

Signed-off-by: Yucong Sun <sunyucong@gmail.com>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/bpf/20211006185619.364369-13-fallentree@fb.com

authored by

Yucong Sun and committed by
Andrii Nakryiko
5db02dd7 0f4feacc

+2 -2
+2 -2
tools/testing/selftests/bpf/progs/fexit_sleep.c
··· 13 13 SEC("fentry/__x64_sys_nanosleep") 14 14 int BPF_PROG(nanosleep_fentry, const struct pt_regs *regs) 15 15 { 16 - if ((int)bpf_get_current_pid_tgid() != pid) 16 + if (bpf_get_current_pid_tgid() >> 32 != pid) 17 17 return 0; 18 18 19 19 fentry_cnt++; ··· 23 23 SEC("fexit/__x64_sys_nanosleep") 24 24 int BPF_PROG(nanosleep_fexit, const struct pt_regs *regs, int ret) 25 25 { 26 - if ((int)bpf_get_current_pid_tgid() != pid) 26 + if (bpf_get_current_pid_tgid() >> 32 != pid) 27 27 return 0; 28 28 29 29 fexit_cnt++;