Skip to content

Commit

Permalink
seccomp: Add a seccomp_data parameter secure_computing()
Browse files Browse the repository at this point in the history
Currently, if arch code wants to supply seccomp_data directly to
seccomp (which is generally much faster than having seccomp do it
using the syscall_get_xyz() API), it has to use the two-phase
seccomp hooks. Add it to the easy hooks, too.

Cc: [email protected]
Signed-off-by: Andy Lutomirski <[email protected]>
Signed-off-by: Kees Cook <[email protected]>
  • Loading branch information
amluto authored and kees committed Jun 14, 2016
1 parent 58d0a86 commit 2f275de
Show file tree
Hide file tree
Showing 11 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion arch/arm/kernel/ptrace.c
Original file line number Diff line number Diff line change
Expand Up @@ -934,7 +934,7 @@ asmlinkage int syscall_trace_enter(struct pt_regs *regs, int scno)

/* Do the secure computing check first; failures should be fast. */
#ifdef CONFIG_HAVE_ARCH_SECCOMP_FILTER
if (secure_computing() == -1)
if (secure_computing(NULL) == -1)
return -1;
#else
/* XXX: remove this once OABI gets fixed */
Expand Down
2 changes: 1 addition & 1 deletion arch/arm64/kernel/ptrace.c
Original file line number Diff line number Diff line change
Expand Up @@ -1247,7 +1247,7 @@ static void tracehook_report_syscall(struct pt_regs *regs,
asmlinkage int syscall_trace_enter(struct pt_regs *regs)
{
/* Do the secure computing check first; failures should be fast. */
if (secure_computing() == -1)
if (secure_computing(NULL) == -1)
return -1;

if (test_thread_flag(TIF_SYSCALL_TRACE))
Expand Down
2 changes: 1 addition & 1 deletion arch/mips/kernel/ptrace.c
Original file line number Diff line number Diff line change
Expand Up @@ -893,7 +893,7 @@ asmlinkage long syscall_trace_enter(struct pt_regs *regs, long syscall)

current_thread_info()->syscall = syscall;

if (secure_computing() == -1)
if (secure_computing(NULL) == -1)
return -1;

if (test_thread_flag(TIF_SYSCALL_TRACE) &&
Expand Down
2 changes: 1 addition & 1 deletion arch/parisc/kernel/ptrace.c
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ long compat_arch_ptrace(struct task_struct *child, compat_long_t request,
long do_syscall_trace_enter(struct pt_regs *regs)
{
/* Do the secure computing check first. */
if (secure_computing() == -1)
if (secure_computing(NULL) == -1)
return -1;

if (test_thread_flag(TIF_SYSCALL_TRACE) &&
Expand Down
2 changes: 1 addition & 1 deletion arch/powerpc/kernel/ptrace.c
Original file line number Diff line number Diff line change
Expand Up @@ -1783,7 +1783,7 @@ static int do_seccomp(struct pt_regs *regs)
* have already loaded -ENOSYS into r3, or seccomp has put
* something else in r3 (via SECCOMP_RET_ERRNO/TRACE).
*/
if (__secure_computing())
if (__secure_computing(NULL))
return -1;

/*
Expand Down
2 changes: 1 addition & 1 deletion arch/s390/kernel/ptrace.c
Original file line number Diff line number Diff line change
Expand Up @@ -824,7 +824,7 @@ asmlinkage long do_syscall_trace_enter(struct pt_regs *regs)
long ret = 0;

/* Do the secure computing check first. */
if (secure_computing()) {
if (secure_computing(NULL)) {
/* seccomp failures shouldn't expose any additional code. */
ret = -1;
goto out;
Expand Down
2 changes: 1 addition & 1 deletion arch/tile/kernel/ptrace.c
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ int do_syscall_trace_enter(struct pt_regs *regs)
{
u32 work = ACCESS_ONCE(current_thread_info()->flags);

if (secure_computing() == -1)
if (secure_computing(NULL) == -1)
return -1;

if (work & _TIF_SYSCALL_TRACE) {
Expand Down
2 changes: 1 addition & 1 deletion arch/um/kernel/skas/syscall.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ void handle_syscall(struct uml_pt_regs *r)
PT_REGS_SET_SYSCALL_RETURN(regs, -ENOSYS);

/* Do the secure computing check first; failures should be fast. */
if (secure_computing() == -1)
if (secure_computing(NULL) == -1)
return;

if (syscall_trace_enter(regs))
Expand Down
2 changes: 1 addition & 1 deletion arch/x86/entry/vsyscall/vsyscall_64.c
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ bool emulate_vsyscall(struct pt_regs *regs, unsigned long address)
*/
regs->orig_ax = syscall_nr;
regs->ax = -ENOSYS;
tmp = secure_computing();
tmp = secure_computing(NULL);
if ((!tmp && regs->orig_ax != syscall_nr) || regs->ip != address) {
warn_bad_vsyscall(KERN_DEBUG, regs,
"seccomp tried to change syscall nr or ip");
Expand Down
8 changes: 4 additions & 4 deletions include/linux/seccomp.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ struct seccomp {
};

#ifdef CONFIG_HAVE_ARCH_SECCOMP_FILTER
extern int __secure_computing(void);
static inline int secure_computing(void)
extern int __secure_computing(const struct seccomp_data *sd);
static inline int secure_computing(const struct seccomp_data *sd)
{
if (unlikely(test_thread_flag(TIF_SECCOMP)))
return __secure_computing();
return __secure_computing(sd);
return 0;
}

Expand Down Expand Up @@ -61,7 +61,7 @@ struct seccomp { };
struct seccomp_filter { };

#ifdef CONFIG_HAVE_ARCH_SECCOMP_FILTER
static inline int secure_computing(void) { return 0; }
static inline int secure_computing(struct seccomp_data *sd) { return 0; }
#else
static inline void secure_computing_strict(int this_syscall) { return; }
#endif
Expand Down
4 changes: 2 additions & 2 deletions kernel/seccomp.c
Original file line number Diff line number Diff line change
Expand Up @@ -554,9 +554,9 @@ void secure_computing_strict(int this_syscall)
BUG();
}
#else
int __secure_computing(void)
int __secure_computing(const struct seccomp_data *sd)
{
u32 phase1_result = seccomp_phase1(NULL);
u32 phase1_result = seccomp_phase1(sd);

if (likely(phase1_result == SECCOMP_PHASE1_OK))
return 0;
Expand Down

0 comments on commit 2f275de

Please sign in to comment.