]> Pileus Git - ~andy/linux/commitdiff
seccomp: ignore secure_computing return values
authorWill Drewry <wad@chromium.org>
Tue, 17 Apr 2012 19:48:57 +0000 (14:48 -0500)
committerJames Morris <james.l.morris@oracle.com>
Wed, 18 Apr 2012 02:24:50 +0000 (12:24 +1000)
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>
arch/microblaze/kernel/ptrace.c
arch/mips/kernel/ptrace.c
arch/powerpc/kernel/ptrace.c
arch/s390/kernel/ptrace.c
arch/sh/kernel/ptrace_32.c
arch/sh/kernel/ptrace_64.c
arch/sparc/kernel/ptrace_64.c
include/linux/seccomp.h

index 6eb2aa927d8966b842f388b219ae19b8dadd7309..ab1b9db661f3ced3173c29e305f7cbc726054f71 100644 (file)
@@ -136,7 +136,7 @@ asmlinkage long do_syscall_trace_enter(struct pt_regs *regs)
 {
        long ret = 0;
 
-       secure_computing(regs->r12);
+       secure_computing_strict(regs->r12);
 
        if (test_thread_flag(TIF_SYSCALL_TRACE) &&
            tracehook_report_syscall_entry(regs))
index 7c24c2973c6d2ec7d5092a57b4d447aaa935a541..4812c6d916e4c5af7bf36f12aa7f1cdce4ad533f 100644 (file)
@@ -535,7 +535,7 @@ static inline int audit_arch(void)
 asmlinkage void syscall_trace_enter(struct pt_regs *regs)
 {
        /* do the secure computing check first */
-       secure_computing(regs->regs[2]);
+       secure_computing_strict(regs->regs[2]);
 
        if (!(current->ptrace & PT_PTRACED))
                goto out;
index 8d8e028893be6e89346d89e984ae76b0a4cfb583..dd5e214cdf21ec13ce19a6448572a0c937794d65 100644 (file)
@@ -1710,7 +1710,7 @@ long do_syscall_trace_enter(struct pt_regs *regs)
 {
        long ret = 0;
 
-       secure_computing(regs->gpr[0]);
+       secure_computing_strict(regs->gpr[0]);
 
        if (test_thread_flag(TIF_SYSCALL_TRACE) &&
            tracehook_report_syscall_entry(regs))
index 02f300fbf070ac5abbfe667023237ca0a45f6fcf..4993e689b2c2bd19135e873234d699c9a2da8f16 100644 (file)
@@ -719,7 +719,7 @@ asmlinkage long do_syscall_trace_enter(struct pt_regs *regs)
        long ret = 0;
 
        /* Do the secure computing check first. */
-       secure_computing(regs->gprs[2]);
+       secure_computing_strict(regs->gprs[2]);
 
        /*
         * The sysc_tracesys code in entry.S stored the system
index 9698671444e6706c1cb7e7d5599416a091cf9e64..81f999a672f68b88b547e013d3d25e0c4a8557f4 100644 (file)
@@ -503,7 +503,7 @@ asmlinkage long do_syscall_trace_enter(struct pt_regs *regs)
 {
        long ret = 0;
 
-       secure_computing(regs->regs[0]);
+       secure_computing_strict(regs->regs[0]);
 
        if (test_thread_flag(TIF_SYSCALL_TRACE) &&
            tracehook_report_syscall_entry(regs))
index bc81e07dc098369485fc22800960c33976b56bc9..af90339dadcd7aa5f02dd0f4a59c10a61ccf98d6 100644 (file)
@@ -522,7 +522,7 @@ asmlinkage long long do_syscall_trace_enter(struct pt_regs *regs)
 {
        long long ret = 0;
 
-       secure_computing(regs->regs[9]);
+       secure_computing_strict(regs->regs[9]);
 
        if (test_thread_flag(TIF_SYSCALL_TRACE) &&
            tracehook_report_syscall_entry(regs))
index 6f97c07679950aa730cb79f6c9810d9f0fb50bda..484dabac7045aa2177df26f625ffabf9f6f523c7 100644 (file)
@@ -1062,7 +1062,7 @@ asmlinkage int syscall_trace_enter(struct pt_regs *regs)
        int ret = 0;
 
        /* do the secure computing check first */
-       secure_computing(regs->u_regs[UREG_G1]);
+       secure_computing_strict(regs->u_regs[UREG_G1]);
 
        if (test_thread_flag(TIF_SYSCALL_TRACE))
                ret = tracehook_report_syscall_entry(regs);
index 60f2b350ead7d3ea62e9932808ac8b4c41a80329..84f6320da50f0a9fe03f30154b9137f9b42dfc74 100644 (file)
@@ -75,6 +75,12 @@ static inline int secure_computing(int this_syscall)
        return 0;
 }
 
+/* A wrapper for architectures supporting only SECCOMP_MODE_STRICT. */
+static inline void secure_computing_strict(int this_syscall)
+{
+       BUG_ON(secure_computing(this_syscall) != 0);
+}
+
 extern long prctl_get_seccomp(void);
 extern long prctl_set_seccomp(unsigned long, char __user *);
 
@@ -91,6 +97,7 @@ struct seccomp { };
 struct seccomp_filter { };
 
 static inline int secure_computing(int this_syscall) { return 0; }
+static inline void secure_computing_strict(int this_syscall) { return; }
 
 static inline long prctl_get_seccomp(void)
 {