Skip to content

Commit

Permalink
tests: fix 54-live-binary_tree to use binary tree
Browse files Browse the repository at this point in the history
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: 38f04da ("tests: add tests for the binary tree")
Reviewed-by: Tom Hromatka <[email protected]>
Signed-off-by: Kir Kolyshkin <[email protected]>
[PM: restyled the "Fixes" tag]
Signed-off-by: Paul Moore <[email protected]>
  • Loading branch information
kolyshkin authored and pcmoore committed Mar 16, 2022
1 parent 7a28dfa commit 5731b3c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
4 changes: 3 additions & 1 deletion tests/54-live-binary_tree.c
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions tests/54-live-binary_tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down

0 comments on commit 5731b3c

Please sign in to comment.