History

seccomp: remove the 'sd' argument from __secure_computing()

After the previous changes 'sd' is always NULL.

Oleg Nesterov committed 1 year ago

Commit 1027cd81 parent b37778b4 files · +10 −12Browse files

Unified · Split

4 files
  1. arch/powerpc/kernel/ptrace/ptrace.c +1 −1
  2. include/linux/seccomp.h +3 −3
  3. kernel/entry/common.c +1 −1
  4. kernel/seccomp.c +5 −7
arch/powerpc/kernel/ptrace/ptrace.c+1−1
@@ -215,7 +215,7 @@ static int do_seccomp(struct pt_regs *regs) · 214 unmodified lines
215 * have already loaded -ENOSYS into r3, or seccomp has put215 * have already loaded -ENOSYS into r3, or seccomp has put
216 * something else in r3 (via SECCOMP_RET_ERRNO/TRACE).216 * something else in r3 (via SECCOMP_RET_ERRNO/TRACE).
217 */217 */
218 if (__secure_computing(NULL))218 if (__secure_computing())
219 return -1;219 return -1;
220 220
221 /*221 /*
include/linux/seccomp.h+3−3
@@ -22,13 +22,13 @@ · 21 unmodified lines
22#include <linux/atomic.h>22#include <linux/atomic.h>
23#include <asm/seccomp.h>23#include <asm/seccomp.h>
24 24
25extern int __secure_computing(const struct seccomp_data *sd);25extern int __secure_computing(void);
26 26
27#ifdef CONFIG_HAVE_ARCH_SECCOMP_FILTER27#ifdef CONFIG_HAVE_ARCH_SECCOMP_FILTER
28static inline int secure_computing(void)28static inline int secure_computing(void)
29{29{
30 if (unlikely(test_syscall_work(SECCOMP)))30 if (unlikely(test_syscall_work(SECCOMP)))
31 return __secure_computing(NULL);31 return __secure_computing();
32 return 0;32 return 0;
33}33}
34#else34#else
@@ -54,7 +54,7 @@ static inline int secure_computing(void) { return 0; } · 19 unmodified lines
54#else54#else
55static inline void secure_computing_strict(int this_syscall) { return; }55static inline void secure_computing_strict(int this_syscall) { return; }
56#endif56#endif
57static inline int __secure_computing(const struct seccomp_data *sd) { return 0; }57static inline int __secure_computing(void) { return 0; }
58 58
59static inline long prctl_get_seccomp(void)59static inline long prctl_get_seccomp(void)
60{60{
kernel/entry/common.c+1−1
@@ -49,7 +49,7 @@ long syscall_trace_enter(struct pt_regs *regs, long syscall, · 48 unmodified lines
49 49
50 /* Do seccomp after ptrace, to catch any tracer changes. */50 /* Do seccomp after ptrace, to catch any tracer changes. */
51 if (work & SYSCALL_WORK_SECCOMP) {51 if (work & SYSCALL_WORK_SECCOMP) {
52 ret = __secure_computing(NULL);52 ret = __secure_computing();
53 if (ret == -1L)53 if (ret == -1L)
54 return ret;54 return ret;
55 }55 }
kernel/seccomp.c+5−7
@@ -1072,10 +1072,9 @@ void secure_computing_strict(int this_syscall) · 1071 unmodified lines
1072 else1072 else
1073 BUG();1073 BUG();
1074}1074}
1075int __secure_computing(const struct seccomp_data *sd)1075int __secure_computing(void)
1076{1076{
1077 int this_syscall = sd ? sd->nr :1077 int this_syscall = syscall_get_nr(current, current_pt_regs());
1078 syscall_get_nr(current, current_pt_regs());
1079 1078
1080 secure_computing_strict(this_syscall);1079 secure_computing_strict(this_syscall);
1081 return 0;1080 return 0;
@@ -1365,7 +1364,7 @@ static int __seccomp_filter(int this_syscall, const struct seccomp_data *sd, · 283 unmodified lines
1365}1364}
1366#endif1365#endif
1367 1366
1368int __secure_computing(const struct seccomp_data *sd)1367int __secure_computing(void)
1369{1368{
1370 int mode = current->seccomp.mode;1369 int mode = current->seccomp.mode;
1371 int this_syscall;1370 int this_syscall;
@@ -1374,15 +1373,14 @@ int __secure_computing(const struct seccomp_data *sd) · 2 unmodified lines
1374 unlikely(current->ptrace & PT_SUSPEND_SECCOMP))1373 unlikely(current->ptrace & PT_SUSPEND_SECCOMP))
1375 return 0;1374 return 0;
1376 1375
1377 this_syscall = sd ? sd->nr :1376 this_syscall = syscall_get_nr(current, current_pt_regs());
1378 syscall_get_nr(current, current_pt_regs());
1379 1377
1380 switch (mode) {1378 switch (mode) {
1381 case SECCOMP_MODE_STRICT:1379 case SECCOMP_MODE_STRICT:
1382 __secure_computing_strict(this_syscall); /* may call do_exit */1380 __secure_computing_strict(this_syscall); /* may call do_exit */
1383 return 0;1381 return 0;
1384 case SECCOMP_MODE_FILTER:1382 case SECCOMP_MODE_FILTER:
1385 return __seccomp_filter(this_syscall, sd, false);1383 return __seccomp_filter(this_syscall, NULL, false);
1386 /* Surviving SECCOMP_RET_KILL_* must be proactively impossible. */1384 /* Surviving SECCOMP_RET_KILL_* must be proactively impossible. */
1387 case SECCOMP_MODE_DEAD:1385 case SECCOMP_MODE_DEAD:
1388 WARN_ON_ONCE(1);1386 WARN_ON_ONCE(1);