Skip to content

Commit fbc5d38

Browse files
committed
selftests/seccomp: Handle arm32 corner cases better
It turns out arm32 doesn't handle syscall -1 gracefully, so skip testing for that. Additionally skip tests that depend on clone3 when it is not available (for example when building the seccomp selftests on an old arm image without clone3 headers). And improve error reporting for when nanosleep fails, as seen on arm32 since v5.15. Cc: Lecopzer Chen <[email protected]> Signed-off-by: Kees Cook <[email protected]>
1 parent 7d5cb68 commit fbc5d38

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

tools/testing/selftests/seccomp/seccomp_bpf.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2184,6 +2184,9 @@ FIXTURE_TEARDOWN(TRACE_syscall)
21842184

21852185
TEST(negative_ENOSYS)
21862186
{
2187+
#if defined(__arm__)
2188+
SKIP(return, "arm32 does not support calling syscall -1");
2189+
#endif
21872190
/*
21882191
* There should be no difference between an "internal" skip
21892192
* and userspace asking for syscall "-1".
@@ -3072,7 +3075,8 @@ TEST(syscall_restart)
30723075
timeout.tv_sec = 1;
30733076
errno = 0;
30743077
EXPECT_EQ(0, nanosleep(&timeout, NULL)) {
3075-
TH_LOG("Call to nanosleep() failed (errno %d)", errno);
3078+
TH_LOG("Call to nanosleep() failed (errno %d: %s)",
3079+
errno, strerror(errno));
30763080
}
30773081

30783082
/* Read final sync from parent. */
@@ -3908,6 +3912,9 @@ TEST(user_notification_filter_empty)
39083912
TH_LOG("Kernel does not support PR_SET_NO_NEW_PRIVS!");
39093913
}
39103914

3915+
if (__NR_clone3 < 0)
3916+
SKIP(return, "Test not built with clone3 support");
3917+
39113918
pid = sys_clone3(&args, sizeof(args));
39123919
ASSERT_GE(pid, 0);
39133920

@@ -3962,6 +3969,9 @@ TEST(user_notification_filter_empty_threaded)
39623969
TH_LOG("Kernel does not support PR_SET_NO_NEW_PRIVS!");
39633970
}
39643971

3972+
if (__NR_clone3 < 0)
3973+
SKIP(return, "Test not built with clone3 support");
3974+
39653975
pid = sys_clone3(&args, sizeof(args));
39663976
ASSERT_GE(pid, 0);
39673977

0 commit comments

Comments
 (0)