Skip to contentSkip to conversation

selftests/bpf: fix attach point for non-x86 arches in test_progs/lsm

PATCH Superseded Artem Savkov 3 participants 4 messages Aug 15, 2022 – Aug 16, 2022

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 selftests/bpf: fix attach point for non-x86 arches in test_progs/lsm

Use SYS_PREFIX macro from bpf_misc.h instead of hard-coded '__x64_' prefix for sys_setdomainname attach point in lsm test.

---
 tools/testing/selftests/bpf/progs/lsm.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
tools/testing/selftests/bpf/progs/lsm.c +2 -1
index 33694ef8acfa..d8d8af623bc2 100644
@@ -4,6 +4,7 @@
  * Copyright 2020 Google LLC.
  */
 
+#include "bpf_misc.h"
 #include "vmlinux.h"
 #include <bpf/bpf_helpers.h>
 #include <bpf/bpf_tracing.h>
@@ -160,7 +161,7 @@ int BPF_PROG(test_task_free, struct task_struct *task)
 
 int copy_test = 0;
 
-SEC("fentry.s/__x64_sys_setdomainname")
+SEC("fentry.s/" SYS_PREFIX "sys_setdomainname")
 int BPF_PROG(test_sys_setdomainname, struct pt_regs *regs)
 {
 	void *ptr = (void *)PT_REGS_PARM1(regs);
Signature · 1 line
2.37.1
maintainer
#1 lore raw
Quoted 22 lines · Artem Savkov

Use SYS_PREFIX macro from bpf_misc.h instead of hard-coded '__x64_' prefix for sys_setdomainname attach point in lsm test.

---
  tools/testing/selftests/bpf/progs/lsm.c | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)
tools/testing/selftests/bpf/progs/lsm.c +1 -0
index 33694ef8acfa..d8d8af623bc2 100644
@@ -4,6 +4,7 @@
   * Copyright 2020 Google LLC.
   */
 
+#include "bpf_misc.h"
  #include "vmlinux.h"
  #include <bpf/bpf_helpers.h>
  #include <bpf/bpf_tracing.h>

tools/testing/selftests/bpf/progs/lsm.c int BPF_PROG(test_task_free, struct task_struct *task) · line 167

Quoted 8 lines
tools/testing/selftests/bpf/progs/lsm.c +1 -1
@@ -160,7 +161,7 @@ int BPF_PROG(test_task_free, struct task_struct *task)
 
  int copy_test = 0;
 
-SEC("fentry.s/__x64_sys_setdomainname")
+SEC("fentry.s/" SYS_PREFIX "sys_setdomainname")
  int BPF_PROG(test_sys_setdomainname, struct pt_regs *regs)
  {
  	void *ptr = (void *)PT_REGS_PARM1(regs);

Good catch! Could you also update the comment in tools/testing/selftests/bpf/DENYLIST.s390x +46 :

[...]
test_lsm # failed to find kernel BTF type ID of '__x64_sys_setdomainname': -3 (?)
[...]

It should likely say sth like attach fentry unexpected error: -524 (trampoline).

Thanks,
Daniel

#2 lore raw

PATCH v2 1/1 selftests/bpf: fix attach point for non-x86 arches in test_progs/lsm

Use SYS_PREFIX macro from bpf_misc.h instead of hard-coded '__x64_' prefix for sys_setdomainname attach point in lsm test.

---
 tools/testing/selftests/bpf/DENYLIST.s390x | 2 +-
 tools/testing/selftests/bpf/progs/lsm.c    | 3 ++-
 2 files changed, 3 insertions(+), 2 deletions(-)
tools/testing/selftests/bpf/DENYLIST.s390x +1 -1
index e33cab34d22f..9d8de15e725e 100644
@@ -43,7 +43,7 @@ test_bpffs                               # bpffs test  failed 255
 test_bprm_opts                           # failed to auto-attach program 'secure_exec': -524                           (trampoline)
 test_ima                                 # failed to auto-attach program 'ima': -524                                   (trampoline)
 test_local_storage                       # failed to auto-attach program 'unlink_hook': -524                           (trampoline)
-test_lsm                                 # failed to find kernel BTF type ID of '__x64_sys_setdomainname': -3          (?)
+test_lsm                                 # attach unexpected error: -524                                               (trampoline)
 test_overhead                            # attach_fentry unexpected error: -524                                        (trampoline)
 test_profiler                            # unknown func bpf_probe_read_str#45                                          (overlapping)
 timer                                    # failed to auto-attach program 'test1': -524                                 (trampoline)
tools/testing/selftests/bpf/progs/lsm.c +2 -1
index 33694ef8acfa..d8d8af623bc2 100644
@@ -4,6 +4,7 @@
  * Copyright 2020 Google LLC.
  */
 
+#include "bpf_misc.h"
 #include "vmlinux.h"
 #include <bpf/bpf_helpers.h>
 #include <bpf/bpf_tracing.h>
@@ -160,7 +161,7 @@ int BPF_PROG(test_task_free, struct task_struct *task)
 
 int copy_test = 0;
 
-SEC("fentry.s/__x64_sys_setdomainname")
+SEC("fentry.s/" SYS_PREFIX "sys_setdomainname")
 int BPF_PROG(test_sys_setdomainname, struct pt_regs *regs)
 {
 	void *ptr = (void *)PT_REGS_PARM1(regs);
Signature · 1 line
2.37.1
#3 lore raw
This patch was applied to bpf/bpf-next.git (master) by Andrii Nakryiko <[email protected]>:

Hello:

This patch was applied to bpf/bpf-next.git (master) by Andrii Nakryiko <[email protected]>:

Quoted 8 lines · On Tue, 16 Aug 2022 07:52:31 +0200 you wrote:

Use SYS_PREFIX macro from bpf_misc.h instead of hard-coded '__x64_' prefix for sys_setdomainname attach point in lsm test.

---
 tools/testing/selftests/bpf/DENYLIST.s390x | 2 +-
 tools/testing/selftests/bpf/progs/lsm.c    | 3 ++-
 2 files changed, 3 insertions(+), 2 deletions(-)

Here is the summary with links:
- [bpf-next,v2] selftests/bpf: fix attach point for non-x86 arches in test_progs/lsm

    https://git.kernel.org/bpf/bpf-next/c/807662cac66a

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html