Skip to content

Commit 1027cd8

Browse files
oleg-nesterovkees
authored andcommitted
seccomp: remove the 'sd' argument from __secure_computing()
After the previous changes 'sd' is always NULL. Signed-off-by: Oleg Nesterov <[email protected]> Reviewed-by: Kees Cook <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Kees Cook <[email protected]>
1 parent b37778b commit 1027cd8

File tree

4 files changed

+10
-12
lines changed

4 files changed

+10
-12
lines changed

arch/powerpc/kernel/ptrace/ptrace.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ static int do_seccomp(struct pt_regs *regs)
215215
* have already loaded -ENOSYS into r3, or seccomp has put
216216
* something else in r3 (via SECCOMP_RET_ERRNO/TRACE).
217217
*/
218-
if (__secure_computing(NULL))
218+
if (__secure_computing())
219219
return -1;
220220

221221
/*

include/linux/seccomp.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,13 @@
2222
#include <linux/atomic.h>
2323
#include <asm/seccomp.h>
2424

25-
extern int __secure_computing(const struct seccomp_data *sd);
25+
extern int __secure_computing(void);
2626

2727
#ifdef CONFIG_HAVE_ARCH_SECCOMP_FILTER
2828
static inline int secure_computing(void)
2929
{
3030
if (unlikely(test_syscall_work(SECCOMP)))
31-
return __secure_computing(NULL);
31+
return __secure_computing();
3232
return 0;
3333
}
3434
#else
@@ -54,7 +54,7 @@ static inline int secure_computing(void) { return 0; }
5454
#else
5555
static inline void secure_computing_strict(int this_syscall) { return; }
5656
#endif
57-
static inline int __secure_computing(const struct seccomp_data *sd) { return 0; }
57+
static inline int __secure_computing(void) { return 0; }
5858

5959
static inline long prctl_get_seccomp(void)
6060
{

kernel/entry/common.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ long syscall_trace_enter(struct pt_regs *regs, long syscall,
4949

5050
/* Do seccomp after ptrace, to catch any tracer changes. */
5151
if (work & SYSCALL_WORK_SECCOMP) {
52-
ret = __secure_computing(NULL);
52+
ret = __secure_computing();
5353
if (ret == -1L)
5454
return ret;
5555
}

kernel/seccomp.c

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1072,10 +1072,9 @@ void secure_computing_strict(int this_syscall)
10721072
else
10731073
BUG();
10741074
}
1075-
int __secure_computing(const struct seccomp_data *sd)
1075+
int __secure_computing(void)
10761076
{
1077-
int this_syscall = sd ? sd->nr :
1078-
syscall_get_nr(current, current_pt_regs());
1077+
int this_syscall = syscall_get_nr(current, current_pt_regs());
10791078

10801079
secure_computing_strict(this_syscall);
10811080
return 0;
@@ -1365,7 +1364,7 @@ static int __seccomp_filter(int this_syscall, const struct seccomp_data *sd,
13651364
}
13661365
#endif
13671366

1368-
int __secure_computing(const struct seccomp_data *sd)
1367+
int __secure_computing(void)
13691368
{
13701369
int mode = current->seccomp.mode;
13711370
int this_syscall;
@@ -1374,15 +1373,14 @@ int __secure_computing(const struct seccomp_data *sd)
13741373
unlikely(current->ptrace & PT_SUSPEND_SECCOMP))
13751374
return 0;
13761375

1377-
this_syscall = sd ? sd->nr :
1378-
syscall_get_nr(current, current_pt_regs());
1376+
this_syscall = syscall_get_nr(current, current_pt_regs());
13791377

13801378
switch (mode) {
13811379
case SECCOMP_MODE_STRICT:
13821380
__secure_computing_strict(this_syscall); /* may call do_exit */
13831381
return 0;
13841382
case SECCOMP_MODE_FILTER:
1385-
return __seccomp_filter(this_syscall, sd, false);
1383+
return __seccomp_filter(this_syscall, NULL, false);
13861384
/* Surviving SECCOMP_RET_KILL_* must be proactively impossible. */
13871385
case SECCOMP_MODE_DEAD:
13881386
WARN_ON_ONCE(1);

0 commit comments

Comments
 (0)