[PATCH RFC v2 3/3] tests: test cases for seccomp-assisted syscall filtering

Paul Chaignon paul.chaignon at gmail.com
Wed Jul 31 15:36:59 UTC 2019


From: Chen Jingpiao <chenjingpiao at gmail.com>

* tests/status-none-f.c: New file.
* tests/pure_executables.list: Add status-none-f.
* tests/.gitignore: Add status-none-f.
* tests/init.sh (test_prog_set): New function.
* tests/filter_seccomp.in: New file.
* tests/Makefile.am (EXTRA_DIST): Add filter_seccomp.in.
* tests/gen_tests.in: Add threads-execve test with -n and filter_seccomp
test_prog_set.

Co-authored-by: Paul Chaignon <paul.chaignon at gmail.com>
---
 tests/.gitignore            |  1 +
 tests/Makefile.am           |  1 +
 tests/filter_seccomp.in     |  4 ++++
 tests/gen_tests.in          |  2 ++
 tests/init.sh               |  5 +++++
 tests/pure_executables.list |  1 +
 tests/status-none-f.c       | 20 ++++++++++++++++++++
 7 files changed, 34 insertions(+)
 create mode 100644 tests/filter_seccomp.in
 create mode 100644 tests/status-none-f.c

diff --git a/tests/.gitignore b/tests/.gitignore
index 7774ceec..9c905021 100644
--- a/tests/.gitignore
+++ b/tests/.gitignore
@@ -582,6 +582,7 @@ statfs64
 status-all
 status-failed
 status-none
+status-none-f
 status-none-threads
 status-successful
 status-unfinished
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 05aede5d..b3287627 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -393,6 +393,7 @@ EXTRA_DIST = \
 	eventfd.expected \
 	fadvise.h \
 	fcntl-common.c \
+	filter_seccomp.in \
 	filter-unavailable.expected \
 	fstatat.c \
 	fstatx.c \
diff --git a/tests/filter_seccomp.in b/tests/filter_seccomp.in
new file mode 100644
index 00000000..dc741911
--- /dev/null
+++ b/tests/filter_seccomp.in
@@ -0,0 +1,4 @@
+fork-f	-a26 -qq -f -e signal=none -e trace=chdir
+vfork-f	-a26 -qq -f -e signal=none -e trace=chdir
+fork-f	-a26 -qq -f -e signal=none -e trace=chdir,%memory,%ipc,%pure,%signal,%network -e status=failed
+status-none-f	-f -e trace=!ptrace -e status=none
diff --git a/tests/gen_tests.in b/tests/gen_tests.in
index f90910f1..31436d3e 100644
--- a/tests/gen_tests.in
+++ b/tests/gen_tests.in
@@ -65,6 +65,7 @@ fcntl64	-a8
 fdatasync	-a14
 file_handle	-e trace=name_to_handle_at,open_by_handle_at
 file_ioctl	+ioctl.test
+filter_seccomp test_prog_set -n
 finit_module	-a25
 flock	-a19
 fork-f	-a26 -qq -f -e signal=none -e trace=chdir
@@ -500,6 +501,7 @@ sync_file_range2
 sysinfo	-a14
 syslog	-a36
 tee
+threads-execve +threads-execve.test -n
 time	-a10
 timer_create
 timer_xettime	-e trace=timer_create,timer_settime,timer_gettime
diff --git a/tests/init.sh b/tests/init.sh
index 40e62188..4cd2d153 100644
--- a/tests/init.sh
+++ b/tests/init.sh
@@ -324,6 +324,11 @@ test_trace_expr()
 		< negative.list
 }
 
+test_prog_set()
+{
+	test_pure_prog_set "$@" < "$srcdir/$NAME.in"
+}
+
 check_prog cat
 check_prog rm
 
diff --git a/tests/pure_executables.list b/tests/pure_executables.list
index 3224999e..d7427011 100755
--- a/tests/pure_executables.list
+++ b/tests/pure_executables.list
@@ -494,6 +494,7 @@ statfs64
 status-all
 status-failed
 status-none
+status-none-f
 status-successful
 status-unfinished
 statx
diff --git a/tests/status-none-f.c b/tests/status-none-f.c
new file mode 100644
index 00000000..c4305d66
--- /dev/null
+++ b/tests/status-none-f.c
@@ -0,0 +1,20 @@
+/*
+ * Check basic seccomp filtering with large number of traced syscalls.
+ *
+ * Copyright (c) 2019 The strace developers.
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+#include "tests.h"
+#include <stdio.h>
+#include <unistd.h>
+
+int
+main(void)
+{
+	printf("%-5d +++ exited with 0 +++\n", getpid());
+	return 0;
+}
+
-- 
2.17.1



More information about the Strace-devel mailing list