Skip to content

Commit 797002d

Browse files
nkapronkees
authored andcommitted
selftests/seccomp: fix syscall_restart test for arm compat
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: 256d0af ("selftests/seccomp: build and pass on arm64") Signed-off-by: Neill Kapron <nkapron@google.com> Link: https://lore.kernel.org/r/20250427094103.3488304-2-nkapron@google.com Signed-off-by: Kees Cook <kees@kernel.org>
1 parent 8ffd015 commit 797002d

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

tools/testing/selftests/seccomp/seccomp_bpf.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3166,12 +3166,15 @@ TEST(syscall_restart)
31663166
ret = get_syscall(_metadata, child_pid);
31673167
#if defined(__arm__)
31683168
/*
3169-
* FIXME:
31703169
* - native ARM registers do NOT expose true syscall.
31713170
* - compat ARM registers on ARM64 DO expose true syscall.
3171+
* - values of utsbuf.machine include 'armv8l' or 'armb8b'
3172+
* for ARM64 running in compat mode.
31723173
*/
31733174
ASSERT_EQ(0, uname(&utsbuf));
3174-
if (strncmp(utsbuf.machine, "arm", 3) == 0) {
3175+
if ((strncmp(utsbuf.machine, "arm", 3) == 0) &&
3176+
(strncmp(utsbuf.machine, "armv8l", 6) != 0) &&
3177+
(strncmp(utsbuf.machine, "armv8b", 6) != 0)) {
31753178
EXPECT_EQ(__NR_nanosleep, ret);
31763179
} else
31773180
#endif

0 commit comments

Comments
 (0)