Commit fbc5d382 authored by Kees Cook's avatar Kees Cook

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 <lecopzer.chen@mediatek.com>
Signed-off-by: default avatarKees Cook <keescook@chromium.org>
parent 7d5cb68a
...@@ -2184,6 +2184,9 @@ FIXTURE_TEARDOWN(TRACE_syscall) ...@@ -2184,6 +2184,9 @@ FIXTURE_TEARDOWN(TRACE_syscall)
TEST(negative_ENOSYS) TEST(negative_ENOSYS)
{ {
#if defined(__arm__)
SKIP(return, "arm32 does not support calling syscall -1");
#endif
/* /*
* There should be no difference between an "internal" skip * There should be no difference between an "internal" skip
* and userspace asking for syscall "-1". * and userspace asking for syscall "-1".
...@@ -3072,7 +3075,8 @@ TEST(syscall_restart) ...@@ -3072,7 +3075,8 @@ TEST(syscall_restart)
timeout.tv_sec = 1; timeout.tv_sec = 1;
errno = 0; errno = 0;
EXPECT_EQ(0, nanosleep(&timeout, NULL)) { EXPECT_EQ(0, nanosleep(&timeout, NULL)) {
TH_LOG("Call to nanosleep() failed (errno %d)", errno); TH_LOG("Call to nanosleep() failed (errno %d: %s)",
errno, strerror(errno));
} }
/* Read final sync from parent. */ /* Read final sync from parent. */
...@@ -3908,6 +3912,9 @@ TEST(user_notification_filter_empty) ...@@ -3908,6 +3912,9 @@ TEST(user_notification_filter_empty)
TH_LOG("Kernel does not support PR_SET_NO_NEW_PRIVS!"); TH_LOG("Kernel does not support PR_SET_NO_NEW_PRIVS!");
} }
if (__NR_clone3 < 0)
SKIP(return, "Test not built with clone3 support");
pid = sys_clone3(&args, sizeof(args)); pid = sys_clone3(&args, sizeof(args));
ASSERT_GE(pid, 0); ASSERT_GE(pid, 0);
...@@ -3962,6 +3969,9 @@ TEST(user_notification_filter_empty_threaded) ...@@ -3962,6 +3969,9 @@ TEST(user_notification_filter_empty_threaded)
TH_LOG("Kernel does not support PR_SET_NO_NEW_PRIVS!"); TH_LOG("Kernel does not support PR_SET_NO_NEW_PRIVS!");
} }
if (__NR_clone3 < 0)
SKIP(return, "Test not built with clone3 support");
pid = sys_clone3(&args, sizeof(args)); pid = sys_clone3(&args, sizeof(args));
ASSERT_GE(pid, 0); ASSERT_GE(pid, 0);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment