-
Notifications
You must be signed in to change notification settings - Fork 169
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tests: sort out simulation blacklist/whitelist
This commit sorts out a mismatch between simulation tests, properly laying down a blacklist and a whitelist simulation. Signed-off-by: Luca Bruno <[email protected]>
- Loading branch information
Showing
8 changed files
with
182 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,3 +38,4 @@ util.pyc | |
31-basic-version_check | ||
32-live-tsync_allow | ||
33-sim-socket_syscalls_be | ||
34-sim-basic_blacklist |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
/** | ||
* Seccomp Library test program | ||
* | ||
* Copyright (c) 2013 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:https://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_ALLOW); | ||
if (ctx == NULL) | ||
return ENOMEM; | ||
|
||
rc = seccomp_rule_add_exact(ctx, SCMP_ACT_KILL, SCMP_SYS(read), 1, | ||
SCMP_A0(SCMP_CMP_EQ, STDIN_FILENO)); | ||
if (rc != 0) | ||
goto out; | ||
|
||
rc = seccomp_rule_add_exact(ctx, SCMP_ACT_KILL, SCMP_SYS(write), 1, | ||
SCMP_A0(SCMP_CMP_EQ, STDOUT_FILENO)); | ||
if (rc != 0) | ||
goto out; | ||
|
||
rc = seccomp_rule_add_exact(ctx, SCMP_ACT_KILL, SCMP_SYS(write), 1, | ||
SCMP_A0(SCMP_CMP_EQ, STDERR_FILENO)); | ||
if (rc != 0) | ||
goto out; | ||
|
||
rc = seccomp_rule_add_exact(ctx, SCMP_ACT_KILL, SCMP_SYS(close), 0); | ||
if (rc != 0) | ||
goto out; | ||
|
||
rc = seccomp_rule_add_exact(ctx, | ||
SCMP_ACT_KILL, SCMP_SYS(rt_sigreturn), 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); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
#!/usr/bin/env python | ||
|
||
# | ||
# Seccomp Library test program | ||
# | ||
# Copyright (c) 2013 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:https://www.gnu.org/licenses>. | ||
# | ||
|
||
import argparse | ||
import sys | ||
|
||
import util | ||
|
||
from seccomp import * | ||
|
||
def test(args): | ||
f = SyscallFilter(ALLOW) | ||
f.add_rule_exactly(KILL, "read", Arg(0, EQ, sys.stdin.fileno())) | ||
f.add_rule_exactly(KILL, "write", Arg(0, EQ, sys.stdout.fileno())) | ||
f.add_rule_exactly(KILL, "write", Arg(0, EQ, sys.stderr.fileno())) | ||
f.add_rule_exactly(KILL, "close") | ||
f.add_rule_exactly(KILL, "rt_sigreturn") | ||
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# | ||
# libseccomp regression test automation data | ||
# | ||
# Copyright (c) 2013 Red Hat <[email protected]> | ||
# Author: Paul Moore <[email protected]> | ||
# | ||
|
||
test type: bpf-sim | ||
|
||
# Testname Arch Syscall Arg0 Arg1 Arg2 Arg3 Arg4 Arg5 Result | ||
34-sim-basic_blacklist all read 0 0x856B008 10 N N N KILL | ||
34-sim-basic_blacklist all read 1-10 0x856B008 10 N N N ALLOW | ||
34-sim-basic_blacklist all write 1-2 0x856B008 10 N N N KILL | ||
34-sim-basic_blacklist all write 3-10 0x856B008 10 N N N ALLOW | ||
34-sim-basic_blacklist all close N N N N N N KILL | ||
34-sim-basic_blacklist all rt_sigreturn N N N N N N KILL | ||
34-sim-basic_blacklist all open 0x856B008 4 N N N N ALLOW | ||
34-sim-basic_blacklist x86 0-2 N N N N N N ALLOW | ||
34-sim-basic_blacklist x86 7-172 N N N N N N ALLOW | ||
34-sim-basic_blacklist x86 174-350 N N N N N N ALLOW | ||
34-sim-basic_blacklist x86_64 4-14 N N N N N N ALLOW | ||
34-sim-basic_blacklist x86_64 16-350 N N N N N N ALLOW | ||
|
||
test type: bpf-sim-fuzz | ||
|
||
# Testname StressCount | ||
34-sim-basic_blacklist 50 | ||
|
||
test type: bpf-valgrind | ||
|
||
# Testname | ||
34-sim-basic_blacklist |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters