]> git.proxmox.com Git - mirror_libseccomp.git/commitdiff
tests: add SCMP_ACT_LOG test to 06-sim-actions
authorTyler Hicks <tyhicks@canonical.com>
Wed, 18 Oct 2017 06:16:57 +0000 (06:16 +0000)
committerPaul Moore <paul@paul-moore.com>
Wed, 1 Nov 2017 16:50:52 +0000 (12:50 -0400)
Extend the 06-sim-actions set of tests to include tests for
SCMP_ACT_LOG. The CTL_KCHECKACTS global attribute must be set to prevent
test errors when running under an old kernel that doesn't support
SECCOMP_RET_LOG.

Signed-off-by: Tyler Hicks <tyhicks@canonical.com>
Signed-off-by: Paul Moore <paul@paul-moore.com>
tests/06-sim-actions.c
tests/06-sim-actions.py
tests/06-sim-actions.tests

index 6561cde4a5b1491de0649c4a3c0558e174915b3a..d81e52115ecf92e6879c31daa088731d03f11456 100644 (file)
@@ -36,6 +36,10 @@ int main(int argc, char *argv[])
        if (rc < 0)
                goto out;
 
+       rc = seccomp_api_set(3);
+       if (rc != 0)
+               return EOPNOTSUPP;
+
        ctx = seccomp_init(SCMP_ACT_KILL);
        if (ctx == NULL)
                return ENOMEM;
@@ -44,6 +48,10 @@ int main(int argc, char *argv[])
        if (rc != 0)
                goto out;
 
+       rc = seccomp_rule_add(ctx, SCMP_ACT_LOG, SCMP_SYS(rt_sigreturn), 0);
+       if (rc != 0)
+               goto out;
+
        rc = seccomp_rule_add(ctx, SCMP_ACT_ERRNO(EPERM), SCMP_SYS(write), 0);
        if (rc != 0)
                goto out;
index c59813b4140f4d7829e09d291af6aa6ba69fea52..e3f91e98b5ad1c3c847a2e4223a51f6be388c9f1 100755 (executable)
@@ -30,8 +30,11 @@ import util
 from seccomp import *
 
 def test(args):
+    set_api(3)
+
     f = SyscallFilter(KILL)
     f.add_rule(ALLOW, "read")
+    f.add_rule(LOG, "rt_sigreturn")
     f.add_rule(ERRNO(errno.EPERM), "write")
     f.add_rule(TRAP, "close")
     f.add_rule(TRACE(1234), "open")
index d0c2e444ef8bc282bcda999697fba5eb356da5b8..1402e213ca2101fc884671df104135fae1be9d92 100644 (file)
@@ -7,14 +7,17 @@
 
 test type: bpf-sim
 
-# Testname     Arch            Syscall Arg0            Arg1            Arg2    Arg3    Arg4    Arg5    Result
-06-sim-actions all             read    4               0x856B008       80      N       N       N       ALLOW
-06-sim-actions all             write   1               0x856B008       N       N       N       N       ERRNO(1)
-06-sim-actions all             close   4               N               N       N       N       N       TRAP
-06-sim-actions all,-aarch64    open    0x856B008       4               N       N       N       N       TRACE(1234)
-06-sim-actions x86             0-2     N               N               N       N       N       N       KILL
-06-sim-actions x86             7-350   N               N               N       N       N       N       KILL
-06-sim-actions x86_64          4-350   N               N               N       N       N       N       KILL
+# Testname     Arch            Syscall         Arg0            Arg1            Arg2    Arg3    Arg4    Arg5    Result
+06-sim-actions all             read            4               0x856B008       80      N       N       N       ALLOW
+06-sim-actions all             write           1               0x856B008       N       N       N       N       ERRNO(1)
+06-sim-actions all             close           4               N               N       N       N       N       TRAP
+06-sim-actions all,-aarch64    open            0x856B008       4               N       N       N       N       TRACE(1234)
+06-sim-actions all             rt_sigreturn    N               N               N       N       N       N       LOG
+06-sim-actions x86             0-2             N               N               N       N       N       N       KILL
+06-sim-actions x86             7-172           N               N               N       N       N       N       KILL
+06-sim-actions x86             174-350         N               N               N       N       N       N       KILL
+06-sim-actions x86_64          4-14            N               N               N       N       N       N       KILL
+06-sim-actions x86_64          16-350          N               N               N       N       N       N       KILL
 
 test type: bpf-sim-fuzz