From: Vitaly _Vi Shukela <[email protected]>

Like 03-sim-basic_chains, but with seccomp_rule_add_array instead of
seccomp_rule_add.
---
 tests/.gitignore                      |  1 +
 tests/22-sim-basic_chains_array.c     | 89 +++++++++++++++++++++++++++++++++++
 tests/22-sim-basic_chains_array.tests | 27 +++++++++++
 tests/Makefile                        |  3 +-
 4 files changed, 119 insertions(+), 1 deletion(-)
 create mode 100644 tests/22-sim-basic_chains_array.c
 create mode 100644 tests/22-sim-basic_chains_array.tests

diff --git a/tests/.gitignore b/tests/.gitignore
index 8bbb158..3b68512 100644
--- a/tests/.gitignore
+++ b/tests/.gitignore
@@ -22,3 +22,4 @@ util.pyc
 19-sim-missing_syscalls
 20-live-basic_die
 21-live-basic_allow
+22-sim-basic_chains_array
diff --git a/tests/22-sim-basic_chains_array.c 
b/tests/22-sim-basic_chains_array.c
new file mode 100644
index 0000000..ae334d9
--- /dev/null
+++ b/tests/22-sim-basic_chains_array.c
@@ -0,0 +1,89 @@
+/**
+ * Seccomp Library test program
+ *
+ * Copyright (c) 2012 Red Hat <[email protected]>
+ * Author: Paul Moore <[email protected]>, Vitaly Shukela <[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 <unistd.h>
+
+#include <seccomp.h>
+
+#include "util.h"
+
+int main(int argc, char *argv[])
+{
+       int rc;
+       struct util_options opts;
+       scmp_filter_ctx ctx;
+
+       rc = util_getopt(argc, argv, &opts);
+       if (rc < 0)
+               goto out;
+
+       ctx = seccomp_init(SCMP_ACT_KILL);
+       if (ctx == NULL)
+               goto out;
+
+    {
+               struct scmp_arg_cmp filters[] = { SCMP_A0(SCMP_CMP_EQ, 
STDIN_FILENO) };
+               rc = seccomp_rule_add_exact_array(ctx, SCMP_ACT_ALLOW,
+                               SCMP_SYS(read), 1, filters);
+    }
+       if (rc != 0)
+               goto out;
+
+    {
+               struct scmp_arg_cmp filters[] = { SCMP_A0(SCMP_CMP_EQ, 
STDOUT_FILENO) };
+               rc = seccomp_rule_add_exact_array(ctx, SCMP_ACT_ALLOW,
+                               SCMP_SYS(write), 1, filters);
+    }
+       if (rc != 0)
+               goto out;
+
+       {
+               struct scmp_arg_cmp filters[] = { SCMP_A0(SCMP_CMP_EQ, 
STDERR_FILENO) };
+               rc = seccomp_rule_add_exact_array(ctx, SCMP_ACT_ALLOW,
+                               SCMP_SYS(write), 1, filters);
+    }
+       if (rc != 0)
+               goto out;
+
+       {
+               struct scmp_arg_cmp filters[] = {  };
+               rc = seccomp_rule_add_exact_array(ctx, SCMP_ACT_ALLOW,
+                               SCMP_SYS(close), 0, filters);
+    }
+       if (rc != 0)
+               goto out;
+
+       {
+               struct scmp_arg_cmp filters[] = { };
+               rc = seccomp_rule_add_exact_array(ctx, SCMP_ACT_ALLOW,
+                               SCMP_SYS(rt_sigreturn), 0, filters);
+    }
+       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/22-sim-basic_chains_array.tests 
b/tests/22-sim-basic_chains_array.tests
new file mode 100644
index 0000000..e664687
--- /dev/null
+++ b/tests/22-sim-basic_chains_array.tests
@@ -0,0 +1,27 @@
+#
+# libseccomp regression test automation data
+#
+# Copyright IBM Corp. 2012
+# Author: Corey Bryant <[email protected]>
+#
+
+test type: bpf-sim
+
+# Testname             Arch    Syscall         Arg0            Arg1            
Arg2    Arg3    Arg4    Arg5    Result
+22-sim-basic_chains_array      all     read            0               
0x856B008       10      N       N       N       ALLOW
+22-sim-basic_chains_array      all     read            1-10            
0x856B008       10      N       N       N       KILL
+22-sim-basic_chains_array      all     write           1-2             
0x856B008       10      N       N       N       ALLOW
+22-sim-basic_chains_array      all     write           3-10            
0x856B008       10      N       N       N       KILL
+22-sim-basic_chains_array      all     close           N               N       
        N       N       N       N       ALLOW
+22-sim-basic_chains_array      all     rt_sigreturn    N               N       
        N       N       N       N       ALLOW
+22-sim-basic_chains_array      all     open            0x856B008       4       
        N       N       N       N       KILL
+22-sim-basic_chains_array      x86     0-2             N               N       
        N       N       N       N       KILL
+22-sim-basic_chains_array      x86     7-172           N               N       
        N       N       N       N       KILL
+22-sim-basic_chains_array      x86     174-350         N               N       
        N       N       N       N       KILL
+22-sim-basic_chains_array      x86_64  4-14            N               N       
        N       N       N       N       KILL
+22-sim-basic_chains_array      x86_64  16-350          N               N       
        N       N       N       N       KILL
+
+test type: bpf-sim-fuzz
+
+# Testname             StressCount
+22-sim-basic_chains_array      50
diff --git a/tests/Makefile b/tests/Makefile
index 5d0a16f..57b7b5f 100644
--- a/tests/Makefile
+++ b/tests/Makefile
@@ -56,7 +56,8 @@ TESTS = 01-sim-allow \
        18-sim-basic_whitelist \
        19-sim-missing_syscalls \
        20-live-basic_die \
-       21-live-basic_allow
+       21-live-basic_allow \
+       22-sim-basic_chains_array
 
 DEPS_OBJS = $(OBJS:%.o=%.d)
 DEPS_TESTS = $(TESTS:%=%.d)
-- 
1.7.11.6.1.gada05e2


------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_mar
_______________________________________________
libseccomp-discuss mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/libseccomp-discuss

Reply via email to