summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKir Kolyshkin <kolyshkin@gmail.com>2022-03-14 18:37:50 -0700
committerPaul Moore <paul@paul-moore.com>2022-03-15 22:40:04 -0400
commit861e2dc0945c1c7994e3e18ac5f1249aac3c2c1e (patch)
tree56acb75a569444bf5af482eb0b3b2b1ea477fc9f
parent83ff237f9b96d0056c64afef0a360a7feb65b0d6 (diff)
downloadlibseccomp-861e2dc0945c1c7994e3e18ac5f1249aac3c2c1e.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> (imported from commit 5731b3c338f8f18b1d2b3aa300bbcb97af0fb34c)
-rw-r--r--tests/54-live-binary_tree.c4
-rwxr-xr-xtests/54-live-binary_tree.py1
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")