提交 5db02dd7 编写于 作者: Y Yucong Sun 提交者: Andrii Nakryiko

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: NYucong Sun <sunyucong@gmail.com>
Signed-off-by: NAndrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/bpf/20211006185619.364369-13-fallentree@fb.com
上级 0f4feacc
...@@ -13,7 +13,7 @@ int fexit_cnt = 0; ...@@ -13,7 +13,7 @@ int fexit_cnt = 0;
SEC("fentry/__x64_sys_nanosleep") SEC("fentry/__x64_sys_nanosleep")
int BPF_PROG(nanosleep_fentry, const struct pt_regs *regs) int BPF_PROG(nanosleep_fentry, const struct pt_regs *regs)
{ {
if ((int)bpf_get_current_pid_tgid() != pid) if (bpf_get_current_pid_tgid() >> 32 != pid)
return 0; return 0;
fentry_cnt++; fentry_cnt++;
...@@ -23,7 +23,7 @@ int BPF_PROG(nanosleep_fentry, const struct pt_regs *regs) ...@@ -23,7 +23,7 @@ int BPF_PROG(nanosleep_fentry, const struct pt_regs *regs)
SEC("fexit/__x64_sys_nanosleep") SEC("fexit/__x64_sys_nanosleep")
int BPF_PROG(nanosleep_fexit, const struct pt_regs *regs, int ret) int BPF_PROG(nanosleep_fexit, const struct pt_regs *regs, int ret)
{ {
if ((int)bpf_get_current_pid_tgid() != pid) if (bpf_get_current_pid_tgid() >> 32 != pid)
return 0; return 0;
fexit_cnt++; fexit_cnt++;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册