Skip to content

Commit 8156b45

Browse files
redpigJames Morris
authored andcommitted
seccomp: fix build warnings when there is no CONFIG_SECCOMP_FILTER
If both audit and seccomp filter support are disabled, 'ret' is marked as unused. If just seccomp filter support is disabled, data and skip are considered unused. This change fixes those build warnings. Reported-by: Stephen Rothwell <sfr@canb.auug.org.au> Signed-off-by: Will Drewry <wad@chromium.org> Acked-by: Kees Cook <keescook@chromium.org> Signed-off-by: James Morris <james.l.morris@oracle.com>
1 parent e4da89d commit 8156b45

1 file changed

Lines changed: 9 additions & 4 deletions

File tree

‎kernel/seccomp.c‎

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -377,8 +377,7 @@ int __secure_computing(int this_syscall)
377377
int mode = current->seccomp.mode;
378378
int exit_sig = 0;
379379
int *syscall;
380-
u32 ret = SECCOMP_RET_KILL;
381-
int data;
380+
u32 ret;
382381

383382
switch (mode) {
384383
case SECCOMP_MODE_STRICT:
@@ -392,12 +391,15 @@ int __secure_computing(int this_syscall)
392391
return 0;
393392
} while (*++syscall);
394393
exit_sig = SIGKILL;
394+
ret = SECCOMP_RET_KILL;
395395
break;
396396
#ifdef CONFIG_SECCOMP_FILTER
397-
case SECCOMP_MODE_FILTER:
397+
case SECCOMP_MODE_FILTER: {
398+
int data;
398399
ret = seccomp_run_filters(this_syscall);
399400
data = ret & SECCOMP_RET_DATA;
400-
switch (ret & SECCOMP_RET_ACTION) {
401+
ret &= SECCOMP_RET_ACTION;
402+
switch (ret) {
401403
case SECCOMP_RET_ERRNO:
402404
/* Set the low-order 16-bits as a errno. */
403405
syscall_set_return_value(current, task_pt_regs(current),
@@ -432,6 +434,7 @@ int __secure_computing(int this_syscall)
432434
}
433435
exit_sig = SIGSYS;
434436
break;
437+
}
435438
#endif
436439
default:
437440
BUG();
@@ -442,8 +445,10 @@ int __secure_computing(int this_syscall)
442445
#endif
443446
audit_seccomp(this_syscall, exit_sig, ret);
444447
do_exit(exit_sig);
448+
#ifdef CONFIG_SECCOMP_FILTER
445449
skip:
446450
audit_seccomp(this_syscall, exit_sig, ret);
451+
#endif
447452
return -1;
448453
}
449454

0 commit comments

Comments
 (0)