diff options
author | Kir Kolyshkin <kolyshkin@gmail.com> | 2022-03-14 18:37:50 -0700 |
---|---|---|
committer | Paul Moore <paul@paul-moore.com> | 2022-03-15 22:36:21 -0400 |
commit | 5731b3c338f8f18b1d2b3aa300bbcb97af0fb34c (patch) | |
tree | 6bcaf845eea60347e321618660c5e8d35248141c | |
parent | 7a28dfa86e684197aad2f858ed24a14d63313411 (diff) | |
download | libseccomp-5731b3c338f8f18b1d2b3aa300bbcb97af0fb34c.tar.gz |
tests: fix 54-live-binary_tree to use binary tree
Apparently, an early implementation of the binary tree optimization
used to enable the feature when the number of rules added was > 16.
The code was later changed to add and use SCMP_FLTATR_CTL_OPTIMIZE,
but the 54-live-binary_tree test case was left as is. So, despite
its name, it is not testing the binary tree.
Fix this, and remove the comment that referred to the old
implementation.
Fixes: 38f04da84748 ("tests: add tests for the binary tree")
Reviewed-by: Tom Hromatka <tom.hromatka@oracle.com>
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
[PM: restyled the "Fixes" tag]
Signed-off-by: Paul Moore <paul@paul-moore.com>
-rw-r--r-- | tests/54-live-binary_tree.c | 4 | ||||
-rwxr-xr-x | tests/54-live-binary_tree.py | 1 |
2 files changed, 4 insertions, 1 deletions
diff --git a/tests/54-live-binary_tree.c b/tests/54-live-binary_tree.c index cd4e9e4..16378dc 100644 --- a/tests/54-live-binary_tree.c +++ b/tests/54-live-binary_tree.c @@ -30,7 +30,6 @@ #include "util.h" -/* arbitrary list of syscalls to force seccomp to generate a binary tree */ static const int denylist[] = { SCMP_SYS(times), SCMP_SYS(ptrace), @@ -87,6 +86,9 @@ int main(int argc, char *argv[]) if (ctx == NULL) return ENOMEM; + rc = seccomp_attr_set(ctx, SCMP_FLTATR_CTL_OPTIMIZE, 2); + if (rc < 0) + goto out; rc = seccomp_rule_add(ctx, SCMP_ACT_ALLOW, SCMP_SYS(write), 1, SCMP_A0(SCMP_CMP_EQ, fd)); if (rc != 0) diff --git a/tests/54-live-binary_tree.py b/tests/54-live-binary_tree.py index 2250938..2bc7386 100755 --- a/tests/54-live-binary_tree.py +++ b/tests/54-live-binary_tree.py @@ -62,6 +62,7 @@ def test(): util.install_trap() f = SyscallFilter(TRAP) f.set_attr(Attr.CTL_TSYNC, 1) + f.set_attr(Attr.CTL_OPTIMIZE, 2) # NOTE: additional syscalls required for python f.add_rule(ALLOW, "stat") f.add_rule(ALLOW, "fstat") |