2 * Check how seccomp SECCOMP_SET_MODE_STRICT is decoded.
4 * Copyright (c) 2016 Dmitry V. Levin <ldv@altlinux.org>
7 * SPDX-License-Identifier: GPL-2.0-or-later
11 #include <asm/unistd.h>
13 #if defined __NR_seccomp && defined __NR_exit
21 static const char text1[] =
22 "seccomp(SECCOMP_SET_MODE_STRICT, 0, NULL) = 0\n";
23 static const char text2[] = "+++ exited with 0 +++\n";
24 const kernel_ulong_t addr = (kernel_ulong_t) 0xfacefeeddeadbeefULL;
27 rc = syscall(__NR_seccomp, -1L, -1L, addr);
28 printf("seccomp(%#x /* SECCOMP_SET_MODE_??? */, %u, %#llx)"
29 " = %s\n", -1, -1, (unsigned long long) addr, sprintrc(rc));
32 rc = syscall(__NR_seccomp, 0, 0, 0);
34 printf("seccomp(SECCOMP_SET_MODE_STRICT, 0, NULL) = %s\n",
40 * If kernel implementaton of SECCOMP_MODE_STRICT is buggy,
41 * the following syscall will result to SIGKILL.
43 rc = write(1, text1, LENGTH_OF(text1)) != LENGTH_OF(text1);
46 rc += write(1, text2, LENGTH_OF(text2)) != LENGTH_OF(text2);
47 return !!syscall(__NR_exit, rc);
52 SKIP_MAIN_UNDEFINED("__NR_seccomp && __NR_exit")