script_core 0.2.6 → 0.2.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/ext/enterprise_script_service/libseccomp/.travis.yml +21 -7
- data/ext/enterprise_script_service/libseccomp/CHANGELOG +22 -0
- data/ext/enterprise_script_service/libseccomp/CONTRIBUTING.md +37 -26
- data/ext/enterprise_script_service/libseccomp/CREDITS +8 -0
- data/ext/enterprise_script_service/libseccomp/README.md +3 -1
- data/ext/enterprise_script_service/libseccomp/configure.ac +13 -8
- data/ext/enterprise_script_service/libseccomp/doc/Makefile.am +6 -0
- data/ext/enterprise_script_service/libseccomp/doc/man/man3/seccomp_api_get.3 +12 -2
- data/ext/enterprise_script_service/libseccomp/doc/man/man3/seccomp_arch_add.3 +38 -6
- data/ext/enterprise_script_service/libseccomp/doc/man/man3/seccomp_attr_set.3 +53 -2
- data/ext/enterprise_script_service/libseccomp/doc/man/man3/seccomp_export_bpf.3 +20 -2
- data/ext/enterprise_script_service/libseccomp/doc/man/man3/seccomp_init.3 +9 -2
- data/ext/enterprise_script_service/libseccomp/doc/man/man3/seccomp_load.3 +32 -2
- data/ext/enterprise_script_service/libseccomp/doc/man/man3/seccomp_merge.3 +16 -2
- data/ext/enterprise_script_service/libseccomp/doc/man/man3/seccomp_notify_alloc.3 +113 -0
- data/ext/enterprise_script_service/libseccomp/doc/man/man3/seccomp_notify_fd.3 +1 -0
- data/ext/enterprise_script_service/libseccomp/doc/man/man3/seccomp_notify_free.3 +1 -0
- data/ext/enterprise_script_service/libseccomp/doc/man/man3/seccomp_notify_id_valid.3 +1 -0
- data/ext/enterprise_script_service/libseccomp/doc/man/man3/seccomp_notify_receive.3 +1 -0
- data/ext/enterprise_script_service/libseccomp/doc/man/man3/seccomp_notify_respond.3 +1 -0
- data/ext/enterprise_script_service/libseccomp/doc/man/man3/seccomp_rule_add.3 +64 -3
- data/ext/enterprise_script_service/libseccomp/doc/man/man3/seccomp_syscall_priority.3 +18 -3
- data/ext/enterprise_script_service/libseccomp/include/seccomp-syscalls.h +12 -0
- data/ext/enterprise_script_service/libseccomp/include/seccomp.h.in +116 -0
- data/ext/enterprise_script_service/libseccomp/src/.gitignore +2 -0
- data/ext/enterprise_script_service/libseccomp/src/Makefile.am +31 -17
- data/ext/enterprise_script_service/libseccomp/src/api.c +254 -58
- data/ext/enterprise_script_service/libseccomp/src/arch-aarch64.h +1 -9
- data/ext/enterprise_script_service/libseccomp/src/arch-arm.c +47 -2
- data/ext/enterprise_script_service/libseccomp/src/arch-arm.h +1 -9
- data/ext/enterprise_script_service/libseccomp/src/arch-gperf-generate +40 -0
- data/ext/enterprise_script_service/libseccomp/src/arch-mips.c +41 -4
- data/ext/enterprise_script_service/libseccomp/src/arch-mips.h +2 -10
- data/ext/enterprise_script_service/libseccomp/src/arch-mips64.c +41 -4
- data/ext/enterprise_script_service/libseccomp/src/arch-mips64.h +3 -11
- data/ext/enterprise_script_service/libseccomp/src/arch-mips64n32.c +41 -4
- data/ext/enterprise_script_service/libseccomp/src/arch-mips64n32.h +2 -10
- data/ext/enterprise_script_service/libseccomp/src/arch-parisc.h +1 -10
- data/ext/enterprise_script_service/libseccomp/src/arch-parisc64.c +3 -3
- data/ext/enterprise_script_service/libseccomp/src/arch-parisc64.h +29 -0
- data/ext/enterprise_script_service/libseccomp/src/arch-ppc.h +1 -9
- data/ext/enterprise_script_service/libseccomp/src/arch-ppc64.c +606 -8
- data/ext/enterprise_script_service/libseccomp/src/arch-ppc64.h +2 -10
- data/ext/enterprise_script_service/libseccomp/src/arch-riscv64.c +31 -0
- data/ext/enterprise_script_service/libseccomp/src/arch-riscv64.h +22 -0
- data/ext/enterprise_script_service/libseccomp/src/arch-s390.c +171 -12
- data/ext/enterprise_script_service/libseccomp/src/arch-s390.h +1 -17
- data/ext/enterprise_script_service/libseccomp/src/arch-s390x.c +166 -10
- data/ext/enterprise_script_service/libseccomp/src/arch-s390x.h +1 -20
- data/ext/enterprise_script_service/libseccomp/src/arch-syscall-dump.c +8 -1
- data/ext/enterprise_script_service/libseccomp/src/arch-syscall-validate +359 -143
- data/ext/enterprise_script_service/libseccomp/src/arch-x32.c +36 -2
- data/ext/enterprise_script_service/libseccomp/src/arch-x32.h +2 -10
- data/ext/enterprise_script_service/libseccomp/src/arch-x86.c +172 -10
- data/ext/enterprise_script_service/libseccomp/src/arch-x86.h +1 -14
- data/ext/enterprise_script_service/libseccomp/src/arch-x86_64.h +1 -9
- data/ext/enterprise_script_service/libseccomp/src/arch.c +11 -3
- data/ext/enterprise_script_service/libseccomp/src/arch.h +7 -0
- data/ext/enterprise_script_service/libseccomp/src/db.c +268 -57
- data/ext/enterprise_script_service/libseccomp/src/db.h +16 -2
- data/ext/enterprise_script_service/libseccomp/src/gen_bpf.c +503 -148
- data/ext/enterprise_script_service/libseccomp/src/gen_bpf.h +2 -1
- data/ext/enterprise_script_service/libseccomp/src/gen_pfc.c +165 -37
- data/ext/enterprise_script_service/libseccomp/src/python/libseccomp.pxd +37 -1
- data/ext/enterprise_script_service/libseccomp/src/python/seccomp.pyx +295 -5
- data/ext/enterprise_script_service/libseccomp/src/syscalls.c +56 -0
- data/ext/enterprise_script_service/libseccomp/src/syscalls.csv +470 -0
- data/ext/enterprise_script_service/libseccomp/src/syscalls.h +62 -0
- data/ext/enterprise_script_service/libseccomp/src/syscalls.perf.template +82 -0
- data/ext/enterprise_script_service/libseccomp/src/system.c +196 -16
- data/ext/enterprise_script_service/libseccomp/src/system.h +68 -13
- data/ext/enterprise_script_service/libseccomp/tests/.gitignore +9 -2
- data/ext/enterprise_script_service/libseccomp/tests/06-sim-actions.tests +1 -1
- data/ext/enterprise_script_service/libseccomp/tests/11-basic-basic_errors.c +5 -5
- data/ext/enterprise_script_service/libseccomp/tests/13-basic-attrs.c +35 -1
- data/ext/enterprise_script_service/libseccomp/tests/13-basic-attrs.py +10 -1
- data/ext/enterprise_script_service/libseccomp/tests/15-basic-resolver.c +1 -0
- data/ext/enterprise_script_service/libseccomp/tests/16-sim-arch_basic.c +12 -0
- data/ext/enterprise_script_service/libseccomp/tests/16-sim-arch_basic.py +1 -0
- data/ext/enterprise_script_service/libseccomp/tests/{18-sim-basic_whitelist.c → 18-sim-basic_allowlist.c} +0 -0
- data/ext/enterprise_script_service/libseccomp/tests/{18-sim-basic_whitelist.py → 18-sim-basic_allowlist.py} +0 -0
- data/ext/enterprise_script_service/libseccomp/tests/18-sim-basic_allowlist.tests +32 -0
- data/ext/enterprise_script_service/libseccomp/tests/23-sim-arch_all_le_basic.c +3 -0
- data/ext/enterprise_script_service/libseccomp/tests/23-sim-arch_all_le_basic.py +1 -0
- data/ext/enterprise_script_service/libseccomp/tests/30-sim-socket_syscalls.c +3 -0
- data/ext/enterprise_script_service/libseccomp/tests/30-sim-socket_syscalls.py +1 -0
- data/ext/enterprise_script_service/libseccomp/tests/30-sim-socket_syscalls.tests +33 -17
- data/ext/enterprise_script_service/libseccomp/tests/{34-sim-basic_blacklist.c → 34-sim-basic_denylist.c} +0 -0
- data/ext/enterprise_script_service/libseccomp/tests/{34-sim-basic_blacklist.py → 34-sim-basic_denylist.py} +0 -0
- data/ext/enterprise_script_service/libseccomp/tests/34-sim-basic_denylist.tests +32 -0
- data/ext/enterprise_script_service/libseccomp/tests/36-sim-ipc_syscalls.c +3 -0
- data/ext/enterprise_script_service/libseccomp/tests/36-sim-ipc_syscalls.py +1 -0
- data/ext/enterprise_script_service/libseccomp/tests/36-sim-ipc_syscalls.tests +25 -25
- data/ext/enterprise_script_service/libseccomp/tests/39-basic-api_level.c +24 -3
- data/ext/enterprise_script_service/libseccomp/tests/39-basic-api_level.py +16 -1
- data/ext/enterprise_script_service/libseccomp/tests/47-live-kill_process.c +3 -3
- data/ext/enterprise_script_service/libseccomp/tests/51-live-user_notification.c +112 -0
- data/ext/enterprise_script_service/libseccomp/tests/51-live-user_notification.py +60 -0
- data/ext/enterprise_script_service/libseccomp/tests/51-live-user_notification.tests +11 -0
- data/ext/enterprise_script_service/libseccomp/tests/53-sim-binary_tree.c +156 -0
- data/ext/enterprise_script_service/libseccomp/tests/53-sim-binary_tree.py +95 -0
- data/ext/enterprise_script_service/libseccomp/tests/53-sim-binary_tree.tests +65 -0
- data/ext/enterprise_script_service/libseccomp/tests/54-live-binary_tree.c +128 -0
- data/ext/enterprise_script_service/libseccomp/tests/54-live-binary_tree.py +95 -0
- data/ext/enterprise_script_service/libseccomp/tests/54-live-binary_tree.tests +11 -0
- data/ext/enterprise_script_service/libseccomp/tests/55-basic-pfc_binary_tree.c +134 -0
- data/ext/enterprise_script_service/libseccomp/tests/55-basic-pfc_binary_tree.sh +46 -0
- data/ext/enterprise_script_service/libseccomp/tests/55-basic-pfc_binary_tree.tests +11 -0
- data/ext/enterprise_script_service/libseccomp/tests/56-basic-iterate_syscalls.c +90 -0
- data/ext/enterprise_script_service/libseccomp/tests/56-basic-iterate_syscalls.py +65 -0
- data/ext/enterprise_script_service/libseccomp/tests/56-basic-iterate_syscalls.tests +11 -0
- data/ext/enterprise_script_service/libseccomp/tests/57-basic-rawsysrc.c +64 -0
- data/ext/enterprise_script_service/libseccomp/tests/57-basic-rawsysrc.py +46 -0
- data/ext/enterprise_script_service/libseccomp/tests/57-basic-rawsysrc.tests +11 -0
- data/ext/enterprise_script_service/libseccomp/tests/58-live-tsync_notify.c +116 -0
- data/ext/enterprise_script_service/libseccomp/tests/58-live-tsync_notify.py +61 -0
- data/ext/enterprise_script_service/libseccomp/tests/58-live-tsync_notify.tests +11 -0
- data/ext/enterprise_script_service/libseccomp/tests/Makefile.am +31 -10
- data/ext/enterprise_script_service/libseccomp/tests/regression +6 -3
- data/ext/enterprise_script_service/libseccomp/tests/util.c +3 -3
- data/ext/enterprise_script_service/libseccomp/tools/check-syntax +1 -1
- data/ext/enterprise_script_service/libseccomp/tools/scmp_arch_detect.c +3 -0
- data/ext/enterprise_script_service/libseccomp/tools/scmp_bpf_disasm.c +4 -2
- data/ext/enterprise_script_service/libseccomp/tools/scmp_bpf_sim.c +2 -0
- data/ext/enterprise_script_service/libseccomp/tools/util.c +14 -12
- data/ext/enterprise_script_service/libseccomp/tools/util.h +7 -0
- data/ext/enterprise_script_service/mruby/.github/workflows/codeql-analysis.yml +51 -0
- data/ext/enterprise_script_service/mruby/Doxyfile +1 -1
- data/ext/enterprise_script_service/mruby/README.md +1 -1
- data/ext/enterprise_script_service/mruby/doc/guides/debugger.md +1 -1
- data/ext/enterprise_script_service/mruby/doc/limitations.md +10 -10
- data/ext/enterprise_script_service/mruby/include/mruby.h +13 -0
- data/ext/enterprise_script_service/mruby/include/mruby/boxing_word.h +0 -1
- data/ext/enterprise_script_service/mruby/include/mruby/proc.h +13 -8
- data/ext/enterprise_script_service/mruby/include/mruby/value.h +25 -29
- data/ext/enterprise_script_service/mruby/include/mruby/version.h +3 -3
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-array-ext/src/array.c +5 -8
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-bin-mirb/tools/mirb/mirb.c +2 -2
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-bin-mrbc/tools/mrbc/mrbc.c +17 -10
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-complex/mrblib/complex.rb +1 -1
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-complex/src/complex.c +1 -2
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-eval/src/eval.c +1 -1
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-fiber/src/fiber.c +1 -2
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-inline-struct/test/inline.c +3 -4
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-io/src/file.c +1 -2
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-io/src/file_test.c +9 -26
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-io/src/io.c +1 -2
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-kernel-ext/src/kernel.c +6 -8
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-method/src/method.c +3 -4
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-objectspace/src/mruby_objectspace.c +0 -1
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-print/src/print.c +1 -2
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-range-ext/src/range.c +1 -3
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-rational/mrblib/rational.rb +1 -3
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-sprintf/src/sprintf.c +3 -3
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-string-ext/src/string.c +1 -2
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-struct/src/struct.c +5 -11
- data/ext/enterprise_script_service/mruby/mrbgems/mruby-time/src/time.c +5 -10
- data/ext/enterprise_script_service/mruby/mrblib/00class.rb +10 -0
- data/ext/enterprise_script_service/mruby/src/array.c +14 -11
- data/ext/enterprise_script_service/mruby/src/class.c +22 -21
- data/ext/enterprise_script_service/mruby/src/error.c +1 -2
- data/ext/enterprise_script_service/mruby/src/etc.c +0 -1
- data/ext/enterprise_script_service/mruby/src/gc.c +5 -5
- data/ext/enterprise_script_service/mruby/src/hash.c +8 -15
- data/ext/enterprise_script_service/mruby/src/kernel.c +4 -7
- data/ext/enterprise_script_service/mruby/src/numeric.c +28 -60
- data/ext/enterprise_script_service/mruby/src/object.c +11 -1
- data/ext/enterprise_script_service/mruby/src/proc.c +7 -8
- data/ext/enterprise_script_service/mruby/src/range.c +4 -12
- data/ext/enterprise_script_service/mruby/src/string.c +24 -21
- data/ext/enterprise_script_service/mruby/src/symbol.c +1 -2
- data/ext/enterprise_script_service/mruby/src/vm.c +28 -24
- data/ext/enterprise_script_service/mruby/test/t/kernel.rb +7 -0
- data/lib/script_core/version.rb +1 -1
- metadata +45 -21
- data/ext/enterprise_script_service/libseccomp/src/arch-aarch64-syscalls.c +0 -559
- data/ext/enterprise_script_service/libseccomp/src/arch-arm-syscalls.c +0 -570
- data/ext/enterprise_script_service/libseccomp/src/arch-mips-syscalls.c +0 -562
- data/ext/enterprise_script_service/libseccomp/src/arch-mips64-syscalls.c +0 -562
- data/ext/enterprise_script_service/libseccomp/src/arch-mips64n32-syscalls.c +0 -562
- data/ext/enterprise_script_service/libseccomp/src/arch-parisc-syscalls.c +0 -542
- data/ext/enterprise_script_service/libseccomp/src/arch-ppc-syscalls.c +0 -559
- data/ext/enterprise_script_service/libseccomp/src/arch-ppc64-syscalls.c +0 -559
- data/ext/enterprise_script_service/libseccomp/src/arch-s390-syscalls.c +0 -642
- data/ext/enterprise_script_service/libseccomp/src/arch-s390x-syscalls.c +0 -642
- data/ext/enterprise_script_service/libseccomp/src/arch-x32-syscalls.c +0 -558
- data/ext/enterprise_script_service/libseccomp/src/arch-x86-syscalls.c +0 -692
- data/ext/enterprise_script_service/libseccomp/src/arch-x86_64-syscalls.c +0 -559
- data/ext/enterprise_script_service/libseccomp/tests/18-sim-basic_whitelist.tests +0 -32
- data/ext/enterprise_script_service/libseccomp/tests/34-sim-basic_blacklist.tests +0 -32
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
|
|
3
|
+
#
|
|
4
|
+
# libseccomp regression test automation data
|
|
5
|
+
#
|
|
6
|
+
# Copyright (c) 2019 Oracle and/or its affiliates. All rights reserved.
|
|
7
|
+
# Author: Tom Hromatka <tom.hromatka@oracle.com>
|
|
8
|
+
#
|
|
9
|
+
|
|
10
|
+
####
|
|
11
|
+
# functions
|
|
12
|
+
|
|
13
|
+
#
|
|
14
|
+
# Dependency check
|
|
15
|
+
#
|
|
16
|
+
# Arguments:
|
|
17
|
+
# 1 Dependency to check for
|
|
18
|
+
#
|
|
19
|
+
function check_deps() {
|
|
20
|
+
[[ -z "$1" ]] && return
|
|
21
|
+
which "$1" >& /dev/null
|
|
22
|
+
return $?
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
#
|
|
26
|
+
# Dependency verification
|
|
27
|
+
#
|
|
28
|
+
# Arguments:
|
|
29
|
+
# 1 Dependency to check for
|
|
30
|
+
#
|
|
31
|
+
function verify_deps() {
|
|
32
|
+
[[ -z "$1" ]] && return
|
|
33
|
+
if ! check_deps "$1"; then
|
|
34
|
+
echo "error: install \"$1\" and include it in your \$PATH"
|
|
35
|
+
exit 1
|
|
36
|
+
fi
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
####
|
|
40
|
+
# functions
|
|
41
|
+
|
|
42
|
+
verify_deps diff
|
|
43
|
+
|
|
44
|
+
# compare output to the known good output, fail if different
|
|
45
|
+
./55-basic-pfc_binary_tree | \
|
|
46
|
+
diff -q ${srcdir:=.}/55-basic-pfc_binary_tree.pfc - > /dev/null
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Seccomp Library test program
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2020 Red Hat <gscrivan@redhat.com>
|
|
5
|
+
* Author: Giuseppe Scrivano <gscrivan@redhat.com>
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
/*
|
|
9
|
+
* This library is free software; you can redistribute it and/or modify it
|
|
10
|
+
* under the terms of version 2.1 of the GNU Lesser General Public License as
|
|
11
|
+
* published by the Free Software Foundation.
|
|
12
|
+
*
|
|
13
|
+
* This library is distributed in the hope that it will be useful, but WITHOUT
|
|
14
|
+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
15
|
+
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
|
16
|
+
* for more details.
|
|
17
|
+
*
|
|
18
|
+
* You should have received a copy of the GNU Lesser General Public License
|
|
19
|
+
* along with this library; if not, see <http://www.gnu.org/licenses>.
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
#include <errno.h>
|
|
23
|
+
#include <string.h>
|
|
24
|
+
#include <stdlib.h>
|
|
25
|
+
#include <stdio.h>
|
|
26
|
+
|
|
27
|
+
#include <seccomp.h>
|
|
28
|
+
|
|
29
|
+
unsigned int arch_list[] = {
|
|
30
|
+
SCMP_ARCH_NATIVE,
|
|
31
|
+
SCMP_ARCH_X86,
|
|
32
|
+
SCMP_ARCH_X86_64,
|
|
33
|
+
SCMP_ARCH_X32,
|
|
34
|
+
SCMP_ARCH_ARM,
|
|
35
|
+
SCMP_ARCH_AARCH64,
|
|
36
|
+
SCMP_ARCH_MIPS,
|
|
37
|
+
SCMP_ARCH_MIPS64,
|
|
38
|
+
SCMP_ARCH_MIPS64N32,
|
|
39
|
+
SCMP_ARCH_MIPSEL,
|
|
40
|
+
SCMP_ARCH_MIPSEL64,
|
|
41
|
+
SCMP_ARCH_MIPSEL64N32,
|
|
42
|
+
SCMP_ARCH_PPC,
|
|
43
|
+
SCMP_ARCH_PPC64,
|
|
44
|
+
SCMP_ARCH_PPC64LE,
|
|
45
|
+
SCMP_ARCH_S390,
|
|
46
|
+
SCMP_ARCH_S390X,
|
|
47
|
+
SCMP_ARCH_PARISC,
|
|
48
|
+
SCMP_ARCH_PARISC64,
|
|
49
|
+
SCMP_ARCH_RISCV64,
|
|
50
|
+
-1
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
static int test_arch(int arch, int init)
|
|
54
|
+
{
|
|
55
|
+
int n, iter = 0;
|
|
56
|
+
|
|
57
|
+
for (iter = init; iter < init + 1000; iter++) {
|
|
58
|
+
char *name;
|
|
59
|
+
|
|
60
|
+
name = seccomp_syscall_resolve_num_arch(arch, iter);
|
|
61
|
+
if (name == NULL)
|
|
62
|
+
continue;
|
|
63
|
+
|
|
64
|
+
n = seccomp_syscall_resolve_name_arch(arch, name);
|
|
65
|
+
if (n != iter)
|
|
66
|
+
return 1;
|
|
67
|
+
}
|
|
68
|
+
return 0;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
int main(int argc, char *argv[])
|
|
72
|
+
{
|
|
73
|
+
int iter = 0;
|
|
74
|
+
|
|
75
|
+
for (iter = 0; arch_list[iter] != -1; iter++) {
|
|
76
|
+
int init = 0;
|
|
77
|
+
if (arch_list[iter] == SCMP_ARCH_X32)
|
|
78
|
+
init = 0x40000000;
|
|
79
|
+
else if (arch_list[iter] == SCMP_ARCH_MIPS)
|
|
80
|
+
init = 4000;
|
|
81
|
+
else if (arch_list[iter] == SCMP_ARCH_MIPS64)
|
|
82
|
+
init = 5000;
|
|
83
|
+
else if (arch_list[iter] == SCMP_ARCH_MIPS64N32)
|
|
84
|
+
init = 6000;
|
|
85
|
+
if (test_arch(arch_list[iter], init) < 0)
|
|
86
|
+
return 1;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
return 0;
|
|
90
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
#!/usr/bin/env python
|
|
2
|
+
|
|
3
|
+
#
|
|
4
|
+
# Seccomp Library test program
|
|
5
|
+
#
|
|
6
|
+
# Copyright (c) 2020 Red Hat <gscrivan@redhat.com>
|
|
7
|
+
# Author: Giuseppe Scrivano <gscrivan@redhat.com>
|
|
8
|
+
#
|
|
9
|
+
|
|
10
|
+
#
|
|
11
|
+
# This library is free software; you can redistribute it and/or modify it
|
|
12
|
+
# under the terms of version 2.1 of the GNU Lesser General Public License as
|
|
13
|
+
# published by the Free Software Foundation.
|
|
14
|
+
#
|
|
15
|
+
# This library is distributed in the hope that it will be useful, but WITHOUT
|
|
16
|
+
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
17
|
+
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
|
18
|
+
# for more details.
|
|
19
|
+
#
|
|
20
|
+
# You should have received a copy of the GNU Lesser General Public License
|
|
21
|
+
# along with this library; if not, see <http://www.gnu.org/licenses>.
|
|
22
|
+
#
|
|
23
|
+
|
|
24
|
+
import argparse
|
|
25
|
+
import sys
|
|
26
|
+
|
|
27
|
+
import util
|
|
28
|
+
|
|
29
|
+
from seccomp import *
|
|
30
|
+
|
|
31
|
+
arch_list = ["x86",
|
|
32
|
+
"x86_64",
|
|
33
|
+
"x32",
|
|
34
|
+
"arm",
|
|
35
|
+
"aarch64",
|
|
36
|
+
"mipsel",
|
|
37
|
+
"mipsel64",
|
|
38
|
+
"mipsel64n32",
|
|
39
|
+
"ppc64le",
|
|
40
|
+
"riscv64"]
|
|
41
|
+
|
|
42
|
+
def test_arch(arch, init):
|
|
43
|
+
for i in range(init, init + 1000):
|
|
44
|
+
sys_name = resolve_syscall(arch, i)
|
|
45
|
+
if sys_name is None:
|
|
46
|
+
continue
|
|
47
|
+
n = resolve_syscall(i, sys_name)
|
|
48
|
+
if i != n:
|
|
49
|
+
raise RuntimeError("Test failure")
|
|
50
|
+
|
|
51
|
+
def test():
|
|
52
|
+
for i in arch_list:
|
|
53
|
+
init = 0
|
|
54
|
+
if i == "x32":
|
|
55
|
+
init = 0x40000000
|
|
56
|
+
elif i == "mipsel":
|
|
57
|
+
init = 4000
|
|
58
|
+
elif i == "mipsel64":
|
|
59
|
+
init = 5000
|
|
60
|
+
elif i == "mipsel64n32":
|
|
61
|
+
init = 6000
|
|
62
|
+
test_arch(Arch(i), init)
|
|
63
|
+
|
|
64
|
+
# kate: syntax python;
|
|
65
|
+
# kate: indent-mode python; space-indent on; indent-width 4; mixedindent off;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Seccomp Library test program
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2020 Cisco Systems, Inc. <pmoore2@cisco.com>
|
|
5
|
+
* Author: Paul Moore <paul@paul-moore.com>
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
/*
|
|
9
|
+
* This library is free software; you can redistribute it and/or modify it
|
|
10
|
+
* under the terms of version 2.1 of the GNU Lesser General Public License as
|
|
11
|
+
* published by the Free Software Foundation.
|
|
12
|
+
*
|
|
13
|
+
* This library is distributed in the hope that it will be useful, but WITHOUT
|
|
14
|
+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
15
|
+
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
|
16
|
+
* for more details.
|
|
17
|
+
*
|
|
18
|
+
* You should have received a copy of the GNU Lesser General Public License
|
|
19
|
+
* along with this library; if not, see <http://www.gnu.org/licenses>.
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
#include <errno.h>
|
|
23
|
+
#include <fcntl.h>
|
|
24
|
+
#include <unistd.h>
|
|
25
|
+
#include <sys/types.h>
|
|
26
|
+
#include <sys/stat.h>
|
|
27
|
+
|
|
28
|
+
#include <seccomp.h>
|
|
29
|
+
|
|
30
|
+
#include "util.h"
|
|
31
|
+
|
|
32
|
+
int main(int argc, char *argv[])
|
|
33
|
+
{
|
|
34
|
+
int rc;
|
|
35
|
+
int fd;
|
|
36
|
+
scmp_filter_ctx ctx = NULL;
|
|
37
|
+
|
|
38
|
+
rc = seccomp_api_set(3);
|
|
39
|
+
if (rc != 0)
|
|
40
|
+
return EOPNOTSUPP;
|
|
41
|
+
|
|
42
|
+
ctx = seccomp_init(SCMP_ACT_ALLOW);
|
|
43
|
+
if (ctx == NULL) {
|
|
44
|
+
rc = ENOMEM;
|
|
45
|
+
goto out;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
rc = seccomp_attr_set(ctx, SCMP_FLTATR_API_SYSRAWRC, 1);
|
|
49
|
+
if (rc != 0)
|
|
50
|
+
goto out;
|
|
51
|
+
|
|
52
|
+
/* we must use a closed/invalid fd for this to work */
|
|
53
|
+
fd = dup(2);
|
|
54
|
+
close(fd);
|
|
55
|
+
rc = seccomp_export_pfc(ctx, fd);
|
|
56
|
+
if (rc == -EBADF)
|
|
57
|
+
rc = 0;
|
|
58
|
+
else
|
|
59
|
+
rc = -1;
|
|
60
|
+
|
|
61
|
+
out:
|
|
62
|
+
seccomp_release(ctx);
|
|
63
|
+
return (rc < 0 ? -rc : rc);
|
|
64
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
#!/usr/bin/env python
|
|
2
|
+
|
|
3
|
+
#
|
|
4
|
+
# Seccomp Library test program
|
|
5
|
+
#
|
|
6
|
+
# Copyright (c) 2020 Cisco Systems, Inc. <pmoore2@cisco.com>
|
|
7
|
+
# Author: Paul Moore <paul@paul-moore.com>
|
|
8
|
+
#
|
|
9
|
+
|
|
10
|
+
#
|
|
11
|
+
# This library is free software; you can redistribute it and/or modify it
|
|
12
|
+
# under the terms of version 2.1 of the GNU Lesser General Public License as
|
|
13
|
+
# published by the Free Software Foundation.
|
|
14
|
+
#
|
|
15
|
+
# This library is distributed in the hope that it will be useful, but WITHOUT
|
|
16
|
+
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
17
|
+
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
|
18
|
+
# for more details.
|
|
19
|
+
#
|
|
20
|
+
# You should have received a copy of the GNU Lesser General Public License
|
|
21
|
+
# along with this library; if not, see <http://www.gnu.org/licenses>.
|
|
22
|
+
#
|
|
23
|
+
|
|
24
|
+
import argparse
|
|
25
|
+
import sys
|
|
26
|
+
import os
|
|
27
|
+
|
|
28
|
+
import util
|
|
29
|
+
|
|
30
|
+
from seccomp import *
|
|
31
|
+
|
|
32
|
+
def test():
|
|
33
|
+
# this test really isn't conclusive, but considering how python does error
|
|
34
|
+
# handling it may be the best we can do
|
|
35
|
+
f = SyscallFilter(ALLOW)
|
|
36
|
+
dummy = open("/dev/null", "w")
|
|
37
|
+
os.close(dummy.fileno())
|
|
38
|
+
try:
|
|
39
|
+
f = f.export_pfc(dummy)
|
|
40
|
+
except RuntimeError:
|
|
41
|
+
pass
|
|
42
|
+
|
|
43
|
+
test()
|
|
44
|
+
|
|
45
|
+
# kate: syntax python;
|
|
46
|
+
# kate: indent-mode python; space-indent on; indent-width 4; mixedindent off;
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Seccomp Library test program
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2019 Cisco Systems, Inc. <pmoore2@cisco.com>
|
|
5
|
+
* Author: Paul Moore <paul@paul-moore.com>
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
/*
|
|
9
|
+
* This library is free software; you can redistribute it and/or modify it
|
|
10
|
+
* under the terms of version 2.1 of the GNU Lesser General Public License as
|
|
11
|
+
* published by the Free Software Foundation.
|
|
12
|
+
*
|
|
13
|
+
* This library is distributed in the hope that it will be useful, but WITHOUT
|
|
14
|
+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
15
|
+
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
|
16
|
+
* for more details.
|
|
17
|
+
*
|
|
18
|
+
* You should have received a copy of the GNU Lesser General Public License
|
|
19
|
+
* along with this library; if not, see <http://www.gnu.org/licenses>.
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
#include <sys/types.h>
|
|
23
|
+
#include <sys/wait.h>
|
|
24
|
+
#include <unistd.h>
|
|
25
|
+
#include <seccomp.h>
|
|
26
|
+
#include <signal.h>
|
|
27
|
+
#include <syscall.h>
|
|
28
|
+
#include <errno.h>
|
|
29
|
+
#include <stdlib.h>
|
|
30
|
+
|
|
31
|
+
#include "util.h"
|
|
32
|
+
|
|
33
|
+
#define MAGIC 0x1122334455667788UL
|
|
34
|
+
|
|
35
|
+
int main(int argc, char *argv[])
|
|
36
|
+
{
|
|
37
|
+
int rc, fd = -1, status;
|
|
38
|
+
struct seccomp_notif *req = NULL;
|
|
39
|
+
struct seccomp_notif_resp *resp = NULL;
|
|
40
|
+
scmp_filter_ctx ctx = NULL;
|
|
41
|
+
pid_t pid = 0;
|
|
42
|
+
|
|
43
|
+
ctx = seccomp_init(SCMP_ACT_ALLOW);
|
|
44
|
+
if (ctx == NULL)
|
|
45
|
+
return ENOMEM;
|
|
46
|
+
|
|
47
|
+
rc = seccomp_attr_set(ctx, SCMP_FLTATR_CTL_TSYNC, 1);
|
|
48
|
+
if (rc)
|
|
49
|
+
goto out;
|
|
50
|
+
|
|
51
|
+
rc = seccomp_rule_add(ctx, SCMP_ACT_NOTIFY, SCMP_SYS(getpid), 0, NULL);
|
|
52
|
+
if (rc)
|
|
53
|
+
goto out;
|
|
54
|
+
|
|
55
|
+
rc = seccomp_load(ctx);
|
|
56
|
+
if (rc < 0)
|
|
57
|
+
goto out;
|
|
58
|
+
|
|
59
|
+
rc = seccomp_notify_fd(ctx);
|
|
60
|
+
if (rc < 0)
|
|
61
|
+
goto out;
|
|
62
|
+
fd = rc;
|
|
63
|
+
|
|
64
|
+
pid = fork();
|
|
65
|
+
if (pid == 0)
|
|
66
|
+
exit(syscall(SCMP_SYS(getpid)) != MAGIC);
|
|
67
|
+
|
|
68
|
+
rc = seccomp_notify_alloc(&req, &resp);
|
|
69
|
+
if (rc)
|
|
70
|
+
goto out;
|
|
71
|
+
|
|
72
|
+
rc = seccomp_notify_receive(fd, req);
|
|
73
|
+
if (rc)
|
|
74
|
+
goto out;
|
|
75
|
+
if (req->data.nr != SCMP_SYS(getpid)) {
|
|
76
|
+
rc = -EFAULT;
|
|
77
|
+
goto out;
|
|
78
|
+
}
|
|
79
|
+
rc = seccomp_notify_id_valid(fd, req->id);
|
|
80
|
+
if (rc)
|
|
81
|
+
goto out;
|
|
82
|
+
|
|
83
|
+
resp->id = req->id;
|
|
84
|
+
resp->val = MAGIC;
|
|
85
|
+
resp->error = 0;
|
|
86
|
+
resp->flags = 0;
|
|
87
|
+
rc = seccomp_notify_respond(fd, resp);
|
|
88
|
+
if (rc)
|
|
89
|
+
goto out;
|
|
90
|
+
|
|
91
|
+
if (waitpid(pid, &status, 0) != pid) {
|
|
92
|
+
rc = -EFAULT;
|
|
93
|
+
goto out;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
if (!WIFEXITED(status)) {
|
|
97
|
+
rc = -EFAULT;
|
|
98
|
+
goto out;
|
|
99
|
+
}
|
|
100
|
+
if (WEXITSTATUS(status)) {
|
|
101
|
+
rc = -EFAULT;
|
|
102
|
+
goto out;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
out:
|
|
106
|
+
if (fd >= 0)
|
|
107
|
+
close(fd);
|
|
108
|
+
if (pid)
|
|
109
|
+
kill(pid, SIGKILL);
|
|
110
|
+
seccomp_notify_free(req, resp);
|
|
111
|
+
seccomp_release(ctx);
|
|
112
|
+
|
|
113
|
+
if (rc != 0)
|
|
114
|
+
return (rc < 0 ? -rc : rc);
|
|
115
|
+
return 160;
|
|
116
|
+
}
|