2 * Copyright (c) 2016 Dmitry V. Levin <ldv@altlinux.org>
5 * SPDX-License-Identifier: GPL-2.0-or-later
9 #include <asm/unistd.h>
11 # include <sys/prctl.h>
14 #if defined HAVE_PRCTL && defined PR_SET_SECCOMP && defined __NR_exit
22 static const char text1[] =
23 "prctl(PR_SET_SECCOMP, SECCOMP_MODE_STRICT) = 0\n";
24 static const char text2[] = "+++ exited with 0 +++\n";
26 int rc = prctl(PR_SET_SECCOMP, -1L, 1, 2, 3);
27 printf("prctl(PR_SET_SECCOMP, %#lx /* SECCOMP_MODE_??? */, 0x1, 0x2, 0x3)"
28 " = %d %s (%m)\n", -1L, rc, errno2name());
31 rc = prctl(PR_SET_SECCOMP, 1);
33 printf("prctl(PR_SET_SECCOMP, SECCOMP_MODE_STRICT)"
34 " = %d %s (%m)\n", rc, errno2name());
39 * If kernel implementaton of SECCOMP_MODE_STRICT is buggy,
40 * the following syscall will result to SIGKILL.
42 rc = write(1, text1, LENGTH_OF(text1)) != LENGTH_OF(text1);
45 rc += write(1, text2, LENGTH_OF(text2)) != LENGTH_OF(text2);
46 return !!syscall(__NR_exit, rc);
51 SKIP_MAIN_UNDEFINED("HAVE_PRCTL && PR_SET_SECCOMP && __NR_exit")