Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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: Kees Cook <keescook@chromium.org>

+11 -1
+11 -1
tools/testing/selftests/seccomp/seccomp_bpf.c
··· 2184 2184 2185 2185 TEST(negative_ENOSYS) 2186 2186 { 2187 + #if defined(__arm__) 2188 + SKIP(return, "arm32 does not support calling syscall -1"); 2189 + #endif 2187 2190 /* 2188 2191 * There should be no difference between an "internal" skip 2189 2192 * and userspace asking for syscall "-1". ··· 3075 3072 timeout.tv_sec = 1; 3076 3073 errno = 0; 3077 3074 EXPECT_EQ(0, nanosleep(&timeout, NULL)) { 3078 - TH_LOG("Call to nanosleep() failed (errno %d)", errno); 3075 + TH_LOG("Call to nanosleep() failed (errno %d: %s)", 3076 + errno, strerror(errno)); 3079 3077 } 3080 3078 3081 3079 /* Read final sync from parent. */ ··· 3912 3908 TH_LOG("Kernel does not support PR_SET_NO_NEW_PRIVS!"); 3913 3909 } 3914 3910 3911 + if (__NR_clone3 < 0) 3912 + SKIP(return, "Test not built with clone3 support"); 3913 + 3915 3914 pid = sys_clone3(&args, sizeof(args)); 3916 3915 ASSERT_GE(pid, 0); 3917 3916 ··· 3968 3961 ASSERT_EQ(0, ret) { 3969 3962 TH_LOG("Kernel does not support PR_SET_NO_NEW_PRIVS!"); 3970 3963 } 3964 + 3965 + if (__NR_clone3 < 0) 3966 + SKIP(return, "Test not built with clone3 support"); 3971 3967 3972 3968 pid = sys_clone3(&args, sizeof(args)); 3973 3969 ASSERT_GE(pid, 0);