selftests/bpf: Skip test_bpf_syscall_macro's syscall_arg1 on arm64 and s390

These architectures can provide access to the first syscall argument
only through PT_REGS_PARM1_CORE_SYSCALL().

Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/bpf/20220209021745.2215452-8-iii@linux.ibm.com
This commit is contained in:
Ilya Leoshkevich 2022-02-09 03:17:42 +01:00 committed by Andrii Nakryiko
parent cf0b5b2769
commit 9e45a377f2
2 changed files with 7 additions and 1 deletions

View File

@ -33,7 +33,11 @@ void test_bpf_syscall_macro(void)
/* check whether args of syscall are copied correctly */ /* check whether args of syscall are copied correctly */
prctl(exp_arg1, exp_arg2, exp_arg3, exp_arg4, exp_arg5); prctl(exp_arg1, exp_arg2, exp_arg3, exp_arg4, exp_arg5);
#if defined(__aarch64__) || defined(__s390__)
ASSERT_NEQ(skel->bss->arg1, exp_arg1, "syscall_arg1");
#else
ASSERT_EQ(skel->bss->arg1, exp_arg1, "syscall_arg1"); ASSERT_EQ(skel->bss->arg1, exp_arg1, "syscall_arg1");
#endif
ASSERT_EQ(skel->bss->arg2, exp_arg2, "syscall_arg2"); ASSERT_EQ(skel->bss->arg2, exp_arg2, "syscall_arg2");
ASSERT_EQ(skel->bss->arg3, exp_arg3, "syscall_arg3"); ASSERT_EQ(skel->bss->arg3, exp_arg3, "syscall_arg3");
/* it cannot copy arg4 when uses PT_REGS_PARM4 on x86_64 */ /* it cannot copy arg4 when uses PT_REGS_PARM4 on x86_64 */

View File

@ -28,7 +28,7 @@ int BPF_KPROBE(handle_sys_prctl)
{ {
struct pt_regs *real_regs; struct pt_regs *real_regs;
pid_t pid = bpf_get_current_pid_tgid() >> 32; pid_t pid = bpf_get_current_pid_tgid() >> 32;
unsigned long tmp; unsigned long tmp = 0;
if (pid != filter_pid) if (pid != filter_pid)
return 0; return 0;
@ -37,7 +37,9 @@ int BPF_KPROBE(handle_sys_prctl)
/* test for PT_REGS_PARM */ /* test for PT_REGS_PARM */
#if !defined(bpf_target_arm64) && !defined(bpf_target_s390)
bpf_probe_read_kernel(&tmp, sizeof(tmp), &PT_REGS_PARM1_SYSCALL(real_regs)); bpf_probe_read_kernel(&tmp, sizeof(tmp), &PT_REGS_PARM1_SYSCALL(real_regs));
#endif
arg1 = tmp; arg1 = tmp;
bpf_probe_read_kernel(&arg2, sizeof(arg2), &PT_REGS_PARM2_SYSCALL(real_regs)); bpf_probe_read_kernel(&arg2, sizeof(arg2), &PT_REGS_PARM2_SYSCALL(real_regs));
bpf_probe_read_kernel(&arg3, sizeof(arg3), &PT_REGS_PARM3_SYSCALL(real_regs)); bpf_probe_read_kernel(&arg3, sizeof(arg3), &PT_REGS_PARM3_SYSCALL(real_regs));