From: Paul Moore <[email protected]> Signed-off-by: Paul Moore <[email protected]> --- tests/.gitignore | 2 + tests/36-sim-ipc_syscalls.c | 112 ++++++++++++++++++++++++++++++++++++ tests/36-sim-ipc_syscalls.py | 56 ++++++++++++++++++ tests/36-sim-ipc_syscalls.tests | 39 +++++++++++++ tests/37-sim-ipc_syscalls_be.c | 109 +++++++++++++++++++++++++++++++++++ tests/37-sim-ipc_syscalls_be.py | 55 ++++++++++++++++++ tests/37-sim-ipc_syscalls_be.tests | 27 +++++++++ tests/Makefile.am | 12 +++- 8 files changed, 409 insertions(+), 3 deletions(-) create mode 100644 tests/36-sim-ipc_syscalls.c create mode 100755 tests/36-sim-ipc_syscalls.py create mode 100644 tests/36-sim-ipc_syscalls.tests create mode 100644 tests/37-sim-ipc_syscalls_be.c create mode 100755 tests/37-sim-ipc_syscalls_be.py create mode 100644 tests/37-sim-ipc_syscalls_be.tests
diff --git a/tests/.gitignore b/tests/.gitignore index 49465755..ae228ea8 100644 --- a/tests/.gitignore +++ b/tests/.gitignore @@ -40,3 +40,5 @@ util.pyc 33-sim-socket_syscalls_be 34-sim-basic_blacklist 35-sim-negative_one +36-sim-ipc_syscalls +37-sim-ipc_syscalls_be diff --git a/tests/36-sim-ipc_syscalls.c b/tests/36-sim-ipc_syscalls.c new file mode 100644 index 00000000..c3ff332d --- /dev/null +++ b/tests/36-sim-ipc_syscalls.c @@ -0,0 +1,112 @@ +/** + * Seccomp Library test program + * + * Copyright (c) 2017 Red Hat <[email protected]> + * Author: Paul Moore <[email protected]> + */ + +/* + * This library is free software; you can redistribute it and/or modify it + * under the terms of version 2.1 of the GNU Lesser General Public License as + * published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License + * for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library; if not, see <http://www.gnu.org/licenses>. + */ + +#include <errno.h> +#include <unistd.h> + +#include <seccomp.h> + +#include "util.h" + +int main(int argc, char *argv[]) +{ + int rc; + struct util_options opts; + scmp_filter_ctx ctx = NULL; + + rc = util_getopt(argc, argv, &opts); + if (rc < 0) + goto out; + + ctx = seccomp_init(SCMP_ACT_KILL); + if (ctx == NULL) + return ENOMEM; + + rc = seccomp_arch_remove(ctx, SCMP_ARCH_NATIVE); + if (rc != 0) + goto out; + + rc = seccomp_arch_add(ctx, SCMP_ARCH_X86); + if (rc != 0) + goto out; + rc = seccomp_arch_add(ctx, SCMP_ARCH_X86_64); + if (rc != 0) + goto out; + rc = seccomp_arch_add(ctx, SCMP_ARCH_X32); + if (rc != 0) + goto out; + + rc = seccomp_rule_add(ctx, SCMP_ACT_ALLOW, SCMP_SYS(semop), 0); + if (rc != 0) + goto out; + + rc = seccomp_rule_add(ctx, SCMP_ACT_ALLOW, SCMP_SYS(semtimedop), 0); + if (rc != 0) + goto out; + + rc = seccomp_rule_add(ctx, SCMP_ACT_ALLOW, SCMP_SYS(semget), 0); + if (rc != 0) + goto out; + + rc = seccomp_rule_add(ctx, SCMP_ACT_ALLOW, SCMP_SYS(semctl), 0); + if (rc != 0) + goto out; + + rc = seccomp_rule_add(ctx, SCMP_ACT_ALLOW, SCMP_SYS(msgsnd), 0); + if (rc != 0) + goto out; + + rc = seccomp_rule_add(ctx, SCMP_ACT_ALLOW, SCMP_SYS(msgrcv), 0); + if (rc != 0) + goto out; + + rc = seccomp_rule_add(ctx, SCMP_ACT_ALLOW, SCMP_SYS(msgget), 0); + if (rc != 0) + goto out; + + rc = seccomp_rule_add(ctx, SCMP_ACT_ALLOW, SCMP_SYS(msgctl), 0); + if (rc != 0) + goto out; + + rc = seccomp_rule_add(ctx, SCMP_ACT_ALLOW, SCMP_SYS(shmat), 0); + if (rc != 0) + goto out; + + rc = seccomp_rule_add(ctx, SCMP_ACT_ALLOW, SCMP_SYS(shmdt), 0); + if (rc != 0) + goto out; + + rc = seccomp_rule_add(ctx, SCMP_ACT_ALLOW, SCMP_SYS(shmget), 0); + if (rc != 0) + goto out; + + rc = seccomp_rule_add(ctx, SCMP_ACT_ALLOW, SCMP_SYS(shmctl), 0); + if (rc != 0) + goto out; + + rc = util_filter_output(&opts, ctx); + if (rc) + goto out; + +out: + seccomp_release(ctx); + return (rc < 0 ? -rc : rc); +} diff --git a/tests/36-sim-ipc_syscalls.py b/tests/36-sim-ipc_syscalls.py new file mode 100755 index 00000000..369a80ef --- /dev/null +++ b/tests/36-sim-ipc_syscalls.py @@ -0,0 +1,56 @@ +#!/usr/bin/env python + +# +# Seccomp Library test program +# +# Copyright (c) 2017 Red Hat <[email protected]> +# Author: Paul Moore <[email protected]> +# + +# +# This library is free software; you can redistribute it and/or modify it +# under the terms of version 2.1 of the GNU Lesser General Public License as +# published by the Free Software Foundation. +# +# This library is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License +# for more details. +# +# You should have received a copy of the GNU Lesser General Public License +# along with this library; if not, see <http://www.gnu.org/licenses>. +# + +import argparse +import sys + +import util + +from seccomp import * + +def test(args): + f = SyscallFilter(KILL) + f.remove_arch(Arch()) + f.add_arch(Arch("x86")) + f.add_arch(Arch("x86_64")) + f.add_arch(Arch("x32")) + f.add_rule(ALLOW, "semop") + f.add_rule(ALLOW, "semtimedop") + f.add_rule(ALLOW, "semget") + f.add_rule(ALLOW, "semctl") + f.add_rule(ALLOW, "msgsnd") + f.add_rule(ALLOW, "msgrcv") + f.add_rule(ALLOW, "msgget") + f.add_rule(ALLOW, "msgctl") + f.add_rule(ALLOW, "shmat") + f.add_rule(ALLOW, "shmdt") + f.add_rule(ALLOW, "shmget") + f.add_rule(ALLOW, "shmctl") + return f + +args = util.get_opt() +ctx = test(args) +util.filter_output(args, ctx) + +# kate: syntax python; +# kate: indent-mode python; space-indent on; indent-width 4; mixedindent off; diff --git a/tests/36-sim-ipc_syscalls.tests b/tests/36-sim-ipc_syscalls.tests new file mode 100644 index 00000000..8e0ded74 --- /dev/null +++ b/tests/36-sim-ipc_syscalls.tests @@ -0,0 +1,39 @@ +# +# libseccomp regression test automation data +# +# Copyright (c) 2017 Red Hat <[email protected]> +# Author: Paul Moore <[email protected]> +# + +test type: bpf-sim + +# Testname Arch Syscall Arg0 Arg1 Arg2 Arg3 Arg4 Arg5 Result +36-sim-ipc_syscalls +x86 ipc 1 N N N N N ALLOW +36-sim-ipc_syscalls +x86 ipc 2 N N N N N ALLOW +36-sim-ipc_syscalls +x86 ipc 3 N N N N N ALLOW +36-sim-ipc_syscalls +x86 ipc 4 N N N N N ALLOW +36-sim-ipc_syscalls +x86 ipc 11 N N N N N ALLOW +36-sim-ipc_syscalls +x86 ipc 12 N N N N N ALLOW +36-sim-ipc_syscalls +x86 ipc 13 N N N N N ALLOW +36-sim-ipc_syscalls +x86 ipc 14 N N N N N ALLOW +36-sim-ipc_syscalls +x86 ipc 21 N N N N N ALLOW +36-sim-ipc_syscalls +x86 ipc 22 N N N N N ALLOW +36-sim-ipc_syscalls +x86 ipc 23 N N N N N ALLOW +36-sim-ipc_syscalls +x86 ipc 24 N N N N N ALLOW +36-sim-ipc_syscalls +x86_64 semop N N N N N N ALLOW +36-sim-ipc_syscalls +x86_64 semget N N N N N N ALLOW +36-sim-ipc_syscalls +x86_64 semctl N N N N N N ALLOW +36-sim-ipc_syscalls +x86_64 semtimedop N N N N N N ALLOW +36-sim-ipc_syscalls +x86_64 msgsnd N N N N N N ALLOW +36-sim-ipc_syscalls +x86_64 msgrcv N N N N N N ALLOW +36-sim-ipc_syscalls +x86_64 msgget N N N N N N ALLOW +36-sim-ipc_syscalls +x86_64 msgctl N N N N N N ALLOW +36-sim-ipc_syscalls +x86_64 shmat N N N N N N ALLOW +36-sim-ipc_syscalls +x86_64 shmdt N N N N N N ALLOW +36-sim-ipc_syscalls +x86_64 shmget N N N N N N ALLOW +36-sim-ipc_syscalls +x86_64 shmctl N N N N N N ALLOW + +test type: bpf-valgrind + +# Testname +36-sim-ipc_syscalls diff --git a/tests/37-sim-ipc_syscalls_be.c b/tests/37-sim-ipc_syscalls_be.c new file mode 100644 index 00000000..e82a2aa1 --- /dev/null +++ b/tests/37-sim-ipc_syscalls_be.c @@ -0,0 +1,109 @@ +/** + * Seccomp Library test program + * + * Copyright (c) 2017 Red Hat <[email protected]> + * Author: Paul Moore <[email protected]> + */ + +/* + * This library is free software; you can redistribute it and/or modify it + * under the terms of version 2.1 of the GNU Lesser General Public License as + * published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License + * for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library; if not, see <http://www.gnu.org/licenses>. + */ + +#include <errno.h> +#include <unistd.h> + +#include <seccomp.h> + +#include "util.h" + +int main(int argc, char *argv[]) +{ + int rc; + struct util_options opts; + scmp_filter_ctx ctx = NULL; + + rc = util_getopt(argc, argv, &opts); + if (rc < 0) + goto out; + + ctx = seccomp_init(SCMP_ACT_KILL); + if (ctx == NULL) + return ENOMEM; + + rc = seccomp_arch_remove(ctx, SCMP_ARCH_NATIVE); + if (rc != 0) + goto out; + + rc = seccomp_arch_add(ctx, SCMP_ARCH_S390); + if (rc != 0) + goto out; + rc = seccomp_arch_add(ctx, SCMP_ARCH_S390X); + if (rc != 0) + goto out; + + rc = seccomp_rule_add(ctx, SCMP_ACT_ALLOW, SCMP_SYS(semop), 0); + if (rc != 0) + goto out; + + rc = seccomp_rule_add(ctx, SCMP_ACT_ALLOW, SCMP_SYS(semtimedop), 0); + if (rc != 0) + goto out; + + rc = seccomp_rule_add(ctx, SCMP_ACT_ALLOW, SCMP_SYS(semget), 0); + if (rc != 0) + goto out; + + rc = seccomp_rule_add(ctx, SCMP_ACT_ALLOW, SCMP_SYS(semctl), 0); + if (rc != 0) + goto out; + + rc = seccomp_rule_add(ctx, SCMP_ACT_ALLOW, SCMP_SYS(msgsnd), 0); + if (rc != 0) + goto out; + + rc = seccomp_rule_add(ctx, SCMP_ACT_ALLOW, SCMP_SYS(msgrcv), 0); + if (rc != 0) + goto out; + + rc = seccomp_rule_add(ctx, SCMP_ACT_ALLOW, SCMP_SYS(msgget), 0); + if (rc != 0) + goto out; + + rc = seccomp_rule_add(ctx, SCMP_ACT_ALLOW, SCMP_SYS(msgctl), 0); + if (rc != 0) + goto out; + + rc = seccomp_rule_add(ctx, SCMP_ACT_ALLOW, SCMP_SYS(shmat), 0); + if (rc != 0) + goto out; + + rc = seccomp_rule_add(ctx, SCMP_ACT_ALLOW, SCMP_SYS(shmdt), 0); + if (rc != 0) + goto out; + + rc = seccomp_rule_add(ctx, SCMP_ACT_ALLOW, SCMP_SYS(shmget), 0); + if (rc != 0) + goto out; + + rc = seccomp_rule_add(ctx, SCMP_ACT_ALLOW, SCMP_SYS(shmctl), 0); + if (rc != 0) + goto out; + + rc = util_filter_output(&opts, ctx); + if (rc) + goto out; + +out: + seccomp_release(ctx); + return (rc < 0 ? -rc : rc); +} diff --git a/tests/37-sim-ipc_syscalls_be.py b/tests/37-sim-ipc_syscalls_be.py new file mode 100755 index 00000000..40ae279a --- /dev/null +++ b/tests/37-sim-ipc_syscalls_be.py @@ -0,0 +1,55 @@ +#!/usr/bin/env python + +# +# Seccomp Library test program +# +# Copyright (c) 2017 Red Hat <[email protected]> +# Author: Paul Moore <[email protected]> +# + +# +# This library is free software; you can redistribute it and/or modify it +# under the terms of version 2.1 of the GNU Lesser General Public License as +# published by the Free Software Foundation. +# +# This library is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License +# for more details. +# +# You should have received a copy of the GNU Lesser General Public License +# along with this library; if not, see <http://www.gnu.org/licenses>. +# + +import argparse +import sys + +import util + +from seccomp import * + +def test(args): + f = SyscallFilter(KILL) + f.remove_arch(Arch()) + f.add_arch(Arch("s390")) + f.add_arch(Arch("s390x")) + f.add_rule(ALLOW, "semop") + f.add_rule(ALLOW, "semtimedop") + f.add_rule(ALLOW, "semget") + f.add_rule(ALLOW, "semctl") + f.add_rule(ALLOW, "msgsnd") + f.add_rule(ALLOW, "msgrcv") + f.add_rule(ALLOW, "msgget") + f.add_rule(ALLOW, "msgctl") + f.add_rule(ALLOW, "shmat") + f.add_rule(ALLOW, "shmdt") + f.add_rule(ALLOW, "shmget") + f.add_rule(ALLOW, "shmctl") + return f + +args = util.get_opt() +ctx = test(args) +util.filter_output(args, ctx) + +# kate: syntax python; +# kate: indent-mode python; space-indent on; indent-width 4; mixedindent off; diff --git a/tests/37-sim-ipc_syscalls_be.tests b/tests/37-sim-ipc_syscalls_be.tests new file mode 100644 index 00000000..ff98cec5 --- /dev/null +++ b/tests/37-sim-ipc_syscalls_be.tests @@ -0,0 +1,27 @@ +# +# libseccomp regression test automation data +# +# Copyright (c) 2017 Red Hat <[email protected]> +# Author: Paul Moore <[email protected]> +# + +test type: bpf-sim + +# Testname Arch Syscall Arg0 Arg1 Arg2 Arg3 Arg4 Arg5 Result +37-sim-ipc_syscalls_be +s390,+s390x ipc 1 N N N N N ALLOW +37-sim-ipc_syscalls_be +s390,+s390x ipc 2 N N N N N ALLOW +37-sim-ipc_syscalls_be +s390,+s390x ipc 3 N N N N N ALLOW +37-sim-ipc_syscalls_be +s390,+s390x ipc 4 N N N N N ALLOW +37-sim-ipc_syscalls_be +s390,+s390x ipc 11 N N N N N ALLOW +37-sim-ipc_syscalls_be +s390,+s390x ipc 12 N N N N N ALLOW +37-sim-ipc_syscalls_be +s390,+s390x ipc 13 N N N N N ALLOW +37-sim-ipc_syscalls_be +s390,+s390x ipc 14 N N N N N ALLOW +37-sim-ipc_syscalls_be +s390,+s390x ipc 21 N N N N N ALLOW +37-sim-ipc_syscalls_be +s390,+s390x ipc 22 N N N N N ALLOW +37-sim-ipc_syscalls_be +s390,+s390x ipc 23 N N N N N ALLOW +37-sim-ipc_syscalls_be +s390,+s390x ipc 24 N N N N N ALLOW + +test type: bpf-valgrind + +# Testname +37-sim-ipc_syscalls_be diff --git a/tests/Makefile.am b/tests/Makefile.am index 683f7b67..99ece2b6 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -72,7 +72,9 @@ check_PROGRAMS = \ 32-live-tsync_allow \ 33-sim-socket_syscalls_be \ 34-sim-basic_blacklist \ - 35-sim-negative_one + 35-sim-negative_one \ + 36-sim-ipc_syscalls \ + 37-sim-ipc_syscalls_be EXTRA_DIST_TESTPYTHON = \ util.py \ @@ -110,7 +112,9 @@ EXTRA_DIST_TESTPYTHON = \ 32-live-tsync_allow.py \ 33-sim-socket_syscalls_be.py \ 34-sim-basic_blacklist.py \ - 35-sim-negative_one.py + 35-sim-negative_one.py \ + 36-sim-ipc_syscalls.py \ + 37-sim-ipc_syscalls_be.py EXTRA_DIST_TESTCFGS = \ 01-sim-allow.tests \ @@ -147,7 +151,9 @@ EXTRA_DIST_TESTCFGS = \ 32-live-tsync_allow.tests \ 33-sim-socket_syscalls_be.tests \ 34-sim-basic_blacklist.tests \ - 35-sim-negative_one.tests + 35-sim-negative_one.tests \ + 36-sim-ipc_syscalls.tests \ + 37-sim-ipc_syscalls_be.tests EXTRA_DIST_TESTSCRIPTS = regression testdiff testgen -- You received this message because you are subscribed to the Google Groups "libseccomp" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. For more options, visit https://groups.google.com/d/optout.
