Skip to content

Commit e4da89d

Browse files
redpigJames Morris
authored andcommitted
seccomp: ignore secure_computing return values
This change is inspired by https://lkml.org/lkml/2012/4/16/14 which fixes the build warnings for arches that don't support CONFIG_HAVE_ARCH_SECCOMP_FILTER. In particular, there is no requirement for the return value of secure_computing() to be checked unless the architecture supports seccomp filter. Instead of silencing the warnings with (void) a new static inline is added to encode the expected behavior in a compiler and human friendly way. v2: - cleans things up with a static inline - removes sfr's signed-off-by since it is a different approach v1: - matches sfr's original change 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 b1fa650 commit e4da89d

8 files changed

Lines changed: 14 additions & 7 deletions

File tree

‎arch/microblaze/kernel/ptrace.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ asmlinkage long do_syscall_trace_enter(struct pt_regs *regs)
136136
{
137137
long ret = 0;
138138

139-
secure_computing(regs->r12);
139+
secure_computing_strict(regs->r12);
140140

141141
if (test_thread_flag(TIF_SYSCALL_TRACE) &&
142142
tracehook_report_syscall_entry(regs))

‎arch/mips/kernel/ptrace.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -535,7 +535,7 @@ static inline int audit_arch(void)
535535
asmlinkage void syscall_trace_enter(struct pt_regs *regs)
536536
{
537537
/* do the secure computing check first */
538-
secure_computing(regs->regs[2]);
538+
secure_computing_strict(regs->regs[2]);
539539

540540
if (!(current->ptrace & PT_PTRACED))
541541
goto out;

‎arch/powerpc/kernel/ptrace.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1710,7 +1710,7 @@ long do_syscall_trace_enter(struct pt_regs *regs)
17101710
{
17111711
long ret = 0;
17121712

1713-
secure_computing(regs->gpr[0]);
1713+
secure_computing_strict(regs->gpr[0]);
17141714

17151715
if (test_thread_flag(TIF_SYSCALL_TRACE) &&
17161716
tracehook_report_syscall_entry(regs))

‎arch/s390/kernel/ptrace.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -719,7 +719,7 @@ asmlinkage long do_syscall_trace_enter(struct pt_regs *regs)
719719
long ret = 0;
720720

721721
/* Do the secure computing check first. */
722-
secure_computing(regs->gprs[2]);
722+
secure_computing_strict(regs->gprs[2]);
723723

724724
/*
725725
* The sysc_tracesys code in entry.S stored the system

‎arch/sh/kernel/ptrace_32.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -503,7 +503,7 @@ asmlinkage long do_syscall_trace_enter(struct pt_regs *regs)
503503
{
504504
long ret = 0;
505505

506-
secure_computing(regs->regs[0]);
506+
secure_computing_strict(regs->regs[0]);
507507

508508
if (test_thread_flag(TIF_SYSCALL_TRACE) &&
509509
tracehook_report_syscall_entry(regs))

‎arch/sh/kernel/ptrace_64.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -522,7 +522,7 @@ asmlinkage long long do_syscall_trace_enter(struct pt_regs *regs)
522522
{
523523
long long ret = 0;
524524

525-
secure_computing(regs->regs[9]);
525+
secure_computing_strict(regs->regs[9]);
526526

527527
if (test_thread_flag(TIF_SYSCALL_TRACE) &&
528528
tracehook_report_syscall_entry(regs))

‎arch/sparc/kernel/ptrace_64.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1062,7 +1062,7 @@ asmlinkage int syscall_trace_enter(struct pt_regs *regs)
10621062
int ret = 0;
10631063

10641064
/* do the secure computing check first */
1065-
secure_computing(regs->u_regs[UREG_G1]);
1065+
secure_computing_strict(regs->u_regs[UREG_G1]);
10661066

10671067
if (test_thread_flag(TIF_SYSCALL_TRACE))
10681068
ret = tracehook_report_syscall_entry(regs);

‎include/linux/seccomp.h‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,12 @@ static inline int secure_computing(int this_syscall)
7575
return 0;
7676
}
7777

78+
/* A wrapper for architectures supporting only SECCOMP_MODE_STRICT. */
79+
static inline void secure_computing_strict(int this_syscall)
80+
{
81+
BUG_ON(secure_computing(this_syscall) != 0);
82+
}
83+
7884
extern long prctl_get_seccomp(void);
7985
extern long prctl_set_seccomp(unsigned long, char __user *);
8086

@@ -91,6 +97,7 @@ struct seccomp { };
9197
struct seccomp_filter { };
9298

9399
static inline int secure_computing(int this_syscall) { return 0; }
100+
static inline void secure_computing_strict(int this_syscall) { return; }
94101

95102
static inline long prctl_get_seccomp(void)
96103
{

0 commit comments

Comments
 (0)