Skip to content

Commit 08229f3

Browse files
committed
seccomp: skip redundant rules
Signed-off-by: Giuseppe Scrivano <[email protected]>
1 parent b636d3e commit 08229f3

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/libcrun/seccomp.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ libcrun_generate_and_load_seccomp (libcrun_container *container, int outfd, libc
136136
int ret;
137137
size_t i;
138138
cleanup_seccomp scmp_filter_ctx ctx = NULL;
139-
int action;
139+
int action, default_action;
140140
const char *def_action = "SCMP_ACT_ALLOW";
141141

142142
if (seccomp == NULL)
@@ -149,11 +149,11 @@ libcrun_generate_and_load_seccomp (libcrun_container *container, int outfd, libc
149149
if (seccomp->default_action != NULL)
150150
def_action = seccomp->default_action;
151151

152-
action = get_seccomp_action (def_action, err);
153-
if (UNLIKELY (action == 0))
152+
default_action = get_seccomp_action (def_action, err);
153+
if (UNLIKELY (default_action == 0))
154154
return crun_make_error (err, 0, "invalid seccomp action '%s'", seccomp->default_action);
155155

156-
ctx = seccomp_init (action);
156+
ctx = seccomp_init (default_action);
157157
if (ctx == NULL)
158158
return crun_make_error (err, 0, "error seccomp_init");
159159

@@ -186,6 +186,9 @@ libcrun_generate_and_load_seccomp (libcrun_container *container, int outfd, libc
186186
if (UNLIKELY (action == 0))
187187
return crun_make_error (err, 0, "invalid seccomp action '%s'", seccomp->syscalls[i]->action);
188188

189+
if (action == default_action)
190+
continue;
191+
189192
for (j = 0; j < seccomp->syscalls[i]->names_len; j++)
190193
{
191194
int syscall = seccomp_syscall_resolve_name (seccomp->syscalls[i]->names[j]);

0 commit comments

Comments
 (0)