From b29eda913b11ca339a7c1727fdc7e3309dd2a9b6 Mon Sep 17 00:00:00 2001 From: Paul Moore Date: Thu, 7 Mar 2019 10:49:40 -0500 Subject: tests: add LT tests to 43-sim-a2_order We want to be able to test proper ordering for both LT and GT comparisons. Signed-off-by: Paul Moore --- tests/43-sim-a2_order.c | 44 ++++++++++++++++++++++++++++++++++++++++++-- tests/43-sim-a2_order.py | 12 +++++++++++- tests/43-sim-a2_order.tests | 23 +++++++++++++++++++++-- 3 files changed, 74 insertions(+), 5 deletions(-) diff --git a/tests/43-sim-a2_order.c b/tests/43-sim-a2_order.c index e567b11..89e6d11 100644 --- a/tests/43-sim-a2_order.c +++ b/tests/43-sim-a2_order.c @@ -44,7 +44,6 @@ int main(int argc, char *argv[]) * reads of this size should fall through to the default action - * SCMP_ACT_KILL in this test's case. */ - rc = seccomp_rule_add(ctx, SCMP_ACT_ALLOW, SCMP_SYS(read), 1, SCMP_A2(SCMP_CMP_LE, 64)); if (rc != 0) @@ -78,7 +77,48 @@ int main(int argc, char *argv[]) if (rc != 0) goto out; rc = seccomp_rule_add(ctx, SCMP_ACT_ERRNO(12), SCMP_SYS(read), 1, - SCMP_A2(SCMP_CMP_GT, 16536)); + SCMP_A2(SCMP_CMP_GT, 16384)); + if (rc != 0) + goto out; + + /* note - a "hole" was intentionally left between 16384 and 32768. + * writes of this size should fall through to the default action - + * SCMP_ACT_KILL in this test's case. + */ + rc = seccomp_rule_add(ctx, SCMP_ACT_ALLOW, SCMP_SYS(write), 1, + SCMP_A2(SCMP_CMP_GE, 32768)); + if (rc != 0) + goto out; + rc = seccomp_rule_add(ctx, SCMP_ACT_ERRNO(5), SCMP_SYS(write), 1, + SCMP_A2(SCMP_CMP_LT, 128)); + if (rc != 0) + goto out; + rc = seccomp_rule_add(ctx, SCMP_ACT_ERRNO(6), SCMP_SYS(write), 1, + SCMP_A2(SCMP_CMP_LT, 256)); + if (rc != 0) + goto out; + rc = seccomp_rule_add(ctx, SCMP_ACT_ERRNO(7), SCMP_SYS(write), 1, + SCMP_A2(SCMP_CMP_LT, 512)); + if (rc != 0) + goto out; + rc = seccomp_rule_add(ctx, SCMP_ACT_ERRNO(8), SCMP_SYS(write), 1, + SCMP_A2(SCMP_CMP_LT, 1024)); + if (rc != 0) + goto out; + rc = seccomp_rule_add(ctx, SCMP_ACT_ERRNO(9), SCMP_SYS(write), 1, + SCMP_A2(SCMP_CMP_LT, 2048)); + if (rc != 0) + goto out; + rc = seccomp_rule_add(ctx, SCMP_ACT_ERRNO(10), SCMP_SYS(write), 1, + SCMP_A2(SCMP_CMP_LT, 4096)); + if (rc != 0) + goto out; + rc = seccomp_rule_add(ctx, SCMP_ACT_ERRNO(11), SCMP_SYS(write), 1, + SCMP_A2(SCMP_CMP_LT, 8192)); + if (rc != 0) + goto out; + rc = seccomp_rule_add(ctx, SCMP_ACT_ERRNO(12), SCMP_SYS(write), 1, + SCMP_A2(SCMP_CMP_LT, 16384)); if (rc != 0) goto out; diff --git a/tests/43-sim-a2_order.py b/tests/43-sim-a2_order.py index 62632ff..7cc5f94 100755 --- a/tests/43-sim-a2_order.py +++ b/tests/43-sim-a2_order.py @@ -41,7 +41,17 @@ def test(args): f.add_rule(ERRNO(9), "read", Arg(2, GT, 2048)) f.add_rule(ERRNO(10), "read", Arg(2, GT, 4096)) f.add_rule(ERRNO(11), "read", Arg(2, GT, 8192)) - f.add_rule(ERRNO(12), "read", Arg(2, GT, 16536)) + f.add_rule(ERRNO(12), "read", Arg(2, GT, 16384)) + f.add_rule(ALLOW, "write", Arg(2, GE, 32768)) + f.add_rule(ERRNO(5), "write", Arg(2, LT, 128)) + f.add_rule(ERRNO(6), "write", Arg(2, LT, 256)) + f.add_rule(ERRNO(7), "write", Arg(2, LT, 512)) + f.add_rule(ERRNO(8), "write", Arg(2, LT, 1024)) + f.add_rule(ERRNO(9), "write", Arg(2, LT, 2048)) + f.add_rule(ERRNO(10), "write", Arg(2, LT, 4096)) + f.add_rule(ERRNO(11), "write", Arg(2, LT, 8192)) + f.add_rule(ERRNO(12), "write", Arg(2, LT, 16384)) + return f args = util.get_opt() diff --git a/tests/43-sim-a2_order.tests b/tests/43-sim-a2_order.tests index 5c41fd0..fe4427e 100644 --- a/tests/43-sim-a2_order.tests +++ b/tests/43-sim-a2_order.tests @@ -26,8 +26,27 @@ test type: bpf-sim 43-sim-a2_order all read 4 0x856B008 4097 N N N ERRNO(10) 43-sim-a2_order all read 4 0x856B008 8192 N N N ERRNO(10) 43-sim-a2_order all read 4 0x856B008 8193 N N N ERRNO(11) -43-sim-a2_order all read 4 0x856B008 16536 N N N ERRNO(11) -43-sim-a2_order all read 4 0x856B008 16537 N N N ERRNO(12) +43-sim-a2_order all read 4 0x856B008 16384 N N N ERRNO(11) +43-sim-a2_order all read 4 0x856B008 16385 N N N ERRNO(12) +43-sim-a2_order all write 4 0x856B008 65 N N N ERRNO(5) +43-sim-a2_order all write 4 0x856B008 128 N N N ERRNO(6) +43-sim-a2_order all write 4 0x856B008 129 N N N ERRNO(6) +43-sim-a2_order all write 4 0x856B008 250 N N N ERRNO(6) +43-sim-a2_order all write 4 0x856B008 256 N N N ERRNO(7) +43-sim-a2_order all write 4 0x856B008 257 N N N ERRNO(7) +43-sim-a2_order all write 4 0x856B008 512 N N N ERRNO(8) +43-sim-a2_order all write 4 0x856B008 513 N N N ERRNO(8) +43-sim-a2_order all write 4 0x856B008 1024 N N N ERRNO(9) +43-sim-a2_order all write 4 0x856B008 1025 N N N ERRNO(9) +43-sim-a2_order all write 4 0x856B008 2048 N N N ERRNO(10) +43-sim-a2_order all write 4 0x856B008 2049 N N N ERRNO(10) +43-sim-a2_order all write 4 0x856B008 4096 N N N ERRNO(11) +43-sim-a2_order all write 4 0x856B008 4097 N N N ERRNO(11) +43-sim-a2_order all write 4 0x856B008 8192 N N N ERRNO(12) +43-sim-a2_order all write 4 0x856B008 8193 N N N ERRNO(12) +43-sim-a2_order all write 4 0x856B008 16384 N N N KILL +43-sim-a2_order all write 4 0x856B008 16385 N N N KILL +43-sim-a2_order all write 4 0x856B008 32768 N N N ALLOW # Testname StressCount test type: bpf-valgrind -- cgit v1.2.1