Skip to content

Commit ab29b33

Browse files
committed
Merge tag 'seccomp-v4.8-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux
Pull seccomp fixes from Kees Cook: "Fix UM seccomp vs ptrace, after reordering landed" * tag 'seccomp-v4.8-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux: seccomp: Remove 2-phase API documentation um/ptrace: Fix the syscall number update after a ptrace um/ptrace: Fix the syscall_trace_leave call
2 parents 08411a7 + 4fadd04 commit ab29b33

4 files changed

Lines changed: 10 additions & 18 deletions

File tree

‎arch/Kconfig‎

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -336,17 +336,6 @@ config HAVE_ARCH_SECCOMP_FILTER
336336
results in the system call being skipped immediately.
337337
- seccomp syscall wired up
338338

339-
For best performance, an arch should use seccomp_phase1 and
340-
seccomp_phase2 directly. It should call seccomp_phase1 for all
341-
syscalls if TIF_SECCOMP is set, but seccomp_phase1 does not
342-
need to be called from a ptrace-safe context. It must then
343-
call seccomp_phase2 if seccomp_phase1 returns anything other
344-
than SECCOMP_PHASE1_OK or SECCOMP_PHASE1_SKIP.
345-
346-
As an additional optimization, an arch may provide seccomp_data
347-
directly to seccomp_phase1; this avoids multiple calls
348-
to the syscall_xyz helpers for every syscall.
349-
350339
config SECCOMP_FILTER
351340
def_bool y
352341
depends on HAVE_ARCH_SECCOMP_FILTER && SECCOMP && NET

‎arch/um/kernel/skas/syscall.c‎

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,21 +21,17 @@ void handle_syscall(struct uml_pt_regs *r)
2121
PT_REGS_SET_SYSCALL_RETURN(regs, -ENOSYS);
2222

2323
if (syscall_trace_enter(regs))
24-
return;
24+
goto out;
2525

2626
/* Do the seccomp check after ptrace; failures should be fast. */
2727
if (secure_computing(NULL) == -1)
28-
return;
28+
goto out;
2929

30-
/* Update the syscall number after orig_ax has potentially been updated
31-
* with ptrace.
32-
*/
33-
UPT_SYSCALL_NR(r) = PT_SYSCALL_NR(r->gp);
3430
syscall = UPT_SYSCALL_NR(r);
35-
3631
if (syscall >= 0 && syscall <= __NR_syscall_max)
3732
PT_REGS_SET_SYSCALL_RETURN(regs,
3833
EXECUTE_SYSCALL(syscall, regs));
3934

35+
out:
4036
syscall_trace_leave(regs);
4137
}

‎arch/x86/um/ptrace_32.c‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,10 @@ int putreg(struct task_struct *child, int regno, unsigned long value)
8484
case EAX:
8585
case EIP:
8686
case UESP:
87+
break;
8788
case ORIG_EAX:
89+
/* Update the syscall number. */
90+
UPT_SYSCALL_NR(&child->thread.regs.regs) = value;
8891
break;
8992
case FS:
9093
if (value && (value & 3) != 3)

‎arch/x86/um/ptrace_64.c‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,11 @@ int putreg(struct task_struct *child, int regno, unsigned long value)
7878
case RSI:
7979
case RDI:
8080
case RBP:
81+
break;
82+
8183
case ORIG_RAX:
84+
/* Update the syscall number. */
85+
UPT_SYSCALL_NR(&child->thread.regs.regs) = value;
8286
break;
8387

8488
case FS:

0 commit comments

Comments
 (0)