Skip to content

Commit fefad9e

Browse files
Christian Braunerkees
authored andcommitted
seccomp: simplify secure_computing()
Afaict, the struct seccomp_data argument to secure_computing() is unused by all current callers. So let's remove it. The argument was added in [1]. It was added because having the arch supply the syscall arguments used to be faster than having it done by secure_computing() (cf. Andy's comment in [2]). This is not true anymore though. /* References */ [1]: 2f275de ("seccomp: Add a seccomp_data parameter secure_computing()") [2]: https://lore.kernel.org/r/CALCETrU_fs_At-hTpr231kpaAd0z7xJN4ku-DvzhRU6cvcJA_w@mail.gmail.com Signed-off-by: Christian Brauner <[email protected]> Cc: Andy Lutomirski <[email protected]> Cc: Thomas Gleixner <[email protected]> Cc: Will Drewry <[email protected]> Cc: Oleg Nesterov <[email protected]> Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Acked-by: Borislav Petkov <[email protected]> Acked-by: Andy Lutomirski <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Kees Cook <[email protected]>
1 parent 0eebfed commit fefad9e

File tree

7 files changed

+9
-9
lines changed

7 files changed

+9
-9
lines changed

arch/arm/kernel/ptrace.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -923,7 +923,7 @@ asmlinkage int syscall_trace_enter(struct pt_regs *regs, int scno)
923923

924924
/* Do seccomp after ptrace; syscall may have changed. */
925925
#ifdef CONFIG_HAVE_ARCH_SECCOMP_FILTER
926-
if (secure_computing(NULL) == -1)
926+
if (secure_computing() == -1)
927927
return -1;
928928
#else
929929
/* XXX: remove this once OABI gets fixed */

arch/arm64/kernel/ptrace.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1816,7 +1816,7 @@ int syscall_trace_enter(struct pt_regs *regs)
18161816
}
18171817

18181818
/* Do the secure computing after ptrace; failures should be fast. */
1819-
if (secure_computing(NULL) == -1)
1819+
if (secure_computing() == -1)
18201820
return -1;
18211821

18221822
if (test_thread_flag(TIF_SYSCALL_TRACEPOINT))

arch/parisc/kernel/ptrace.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ long do_syscall_trace_enter(struct pt_regs *regs)
342342
}
343343

344344
/* Do the secure computing check after ptrace. */
345-
if (secure_computing(NULL) == -1)
345+
if (secure_computing() == -1)
346346
return -1;
347347

348348
#ifdef CONFIG_HAVE_SYSCALL_TRACEPOINTS

arch/s390/kernel/ptrace.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -856,7 +856,7 @@ asmlinkage long do_syscall_trace_enter(struct pt_regs *regs)
856856
}
857857

858858
/* Do the secure computing check after ptrace. */
859-
if (secure_computing(NULL)) {
859+
if (secure_computing()) {
860860
/* seccomp failures shouldn't expose any additional code. */
861861
return -1;
862862
}

arch/um/kernel/skas/syscall.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ void handle_syscall(struct uml_pt_regs *r)
3535
goto out;
3636

3737
/* Do the seccomp check after ptrace; failures should be fast. */
38-
if (secure_computing(NULL) == -1)
38+
if (secure_computing() == -1)
3939
goto out;
4040

4141
syscall = UPT_SYSCALL_NR(r);

arch/x86/entry/vsyscall/vsyscall_64.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ bool emulate_vsyscall(unsigned long error_code,
222222
*/
223223
regs->orig_ax = syscall_nr;
224224
regs->ax = -ENOSYS;
225-
tmp = secure_computing(NULL);
225+
tmp = secure_computing();
226226
if ((!tmp && regs->orig_ax != syscall_nr) || regs->ip != address) {
227227
warn_bad_vsyscall(KERN_DEBUG, regs,
228228
"seccomp tried to change syscall nr or ip");

include/linux/seccomp.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,10 @@ struct seccomp {
3333

3434
#ifdef CONFIG_HAVE_ARCH_SECCOMP_FILTER
3535
extern int __secure_computing(const struct seccomp_data *sd);
36-
static inline int secure_computing(const struct seccomp_data *sd)
36+
static inline int secure_computing(void)
3737
{
3838
if (unlikely(test_thread_flag(TIF_SECCOMP)))
39-
return __secure_computing(sd);
39+
return __secure_computing(NULL);
4040
return 0;
4141
}
4242
#else
@@ -59,7 +59,7 @@ struct seccomp { };
5959
struct seccomp_filter { };
6060

6161
#ifdef CONFIG_HAVE_ARCH_SECCOMP_FILTER
62-
static inline int secure_computing(struct seccomp_data *sd) { return 0; }
62+
static inline int secure_computing(void) { return 0; }
6363
#else
6464
static inline void secure_computing_strict(int this_syscall) { return; }
6565
#endif

0 commit comments

Comments
 (0)