* [PATCH RESEND] selftests/seccomp: fix syscall_restart test for arm compat
@ 2025-04-27 9:40 Neill Kapron
2025-04-30 21:21 ` Kees Cook
0 siblings, 1 reply; 2+ messages in thread
From: Neill Kapron @ 2025-04-27 9:40 UTC (permalink / raw)
Cc: nkapron, Kees Cook, Andy Lutomirski, Will Drewry, Shuah Khan,
linux-kselftest, linux-kernel, bpf
The inconsistencies in the systcall ABI between arm and arm-compat can
can cause a failure in the syscall_restart test due to the logic
attempting to work around the differences. The 'machine' field for an
ARM64 device running in compat mode can report 'armv8l' or 'armv8b'
which matches with the string 'arm' when only examining the first three
characters of the string.
This change adds additional validation to the workaround logic to make
sure we only take the arm path when running natively, not in arm-compat.
Fixes: 256d0afb11d6 ("selftests/seccomp: build and pass on arm64")
Signed-off-by: Neill Kapron <nkapron@google.com>
---
tools/testing/selftests/seccomp/seccomp_bpf.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/tools/testing/selftests/seccomp/seccomp_bpf.c b/tools/testing/selftests/seccomp/seccomp_bpf.c
index b2f76a52215a..53bf6a9c801f 100644
--- a/tools/testing/selftests/seccomp/seccomp_bpf.c
+++ b/tools/testing/selftests/seccomp/seccomp_bpf.c
@@ -3166,12 +3166,15 @@ TEST(syscall_restart)
ret = get_syscall(_metadata, child_pid);
#if defined(__arm__)
/*
- * FIXME:
* - native ARM registers do NOT expose true syscall.
* - compat ARM registers on ARM64 DO expose true syscall.
+ * - values of utsbuf.machine include 'armv8l' or 'armb8b'
+ * for ARM64 running in compat mode.
*/
ASSERT_EQ(0, uname(&utsbuf));
- if (strncmp(utsbuf.machine, "arm", 3) == 0) {
+ if ((strncmp(utsbuf.machine, "arm", 3) == 0) &&
+ (strncmp(utsbuf.machine, "armv8l", 6) != 0) &&
+ (strncmp(utsbuf.machine, "armv8b", 6) != 0)) {
EXPECT_EQ(__NR_nanosleep, ret);
} else
#endif
--
2.49.0.850.g28803427d3-goog
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH RESEND] selftests/seccomp: fix syscall_restart test for arm compat
2025-04-27 9:40 [PATCH RESEND] selftests/seccomp: fix syscall_restart test for arm compat Neill Kapron
@ 2025-04-30 21:21 ` Kees Cook
0 siblings, 0 replies; 2+ messages in thread
From: Kees Cook @ 2025-04-30 21:21 UTC (permalink / raw)
To: Neill Kapron
Cc: Kees Cook, Andy Lutomirski, Will Drewry, Shuah Khan,
linux-kselftest, linux-kernel, bpf
On Sun, 27 Apr 2025 09:40:58 +0000, Neill Kapron wrote:
> The inconsistencies in the systcall ABI between arm and arm-compat can
> can cause a failure in the syscall_restart test due to the logic
> attempting to work around the differences. The 'machine' field for an
> ARM64 device running in compat mode can report 'armv8l' or 'armv8b'
> which matches with the string 'arm' when only examining the first three
> characters of the string.
>
> [...]
Applied to for-next/seccomp, thanks!
[1/1] selftests/seccomp: fix syscall_restart test for arm compat
https://git.kernel.org/kees/c/797002deed03
Take care,
--
Kees Cook
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-04-30 21:21 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-04-27 9:40 [PATCH RESEND] selftests/seccomp: fix syscall_restart test for arm compat Neill Kapron
2025-04-30 21:21 ` Kees Cook
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox