mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-12-18 13:16:55 +07:00
ce29856a5e
Update the syscall number after each PTRACE_SETREGS on ORIG_*AX.
This is needed to get the potentially altered syscall number in the
seccomp filters after RET_TRACE.
This fix four seccomp_bpf tests:
> [ RUN ] TRACE_syscall.skip_after_RET_TRACE
> seccomp_bpf.c:1560:TRACE_syscall.skip_after_RET_TRACE:Expected -1 (18446744073709551615) == syscall(39) (26)
> seccomp_bpf.c:1561:TRACE_syscall.skip_after_RET_TRACE:Expected 1 (1) == (*__errno_location ()) (22)
> [ FAIL ] TRACE_syscall.skip_after_RET_TRACE
> [ RUN ] TRACE_syscall.kill_after_RET_TRACE
> TRACE_syscall.kill_after_RET_TRACE: Test exited normally instead of by signal (code: 1)
> [ FAIL ] TRACE_syscall.kill_after_RET_TRACE
> [ RUN ] TRACE_syscall.skip_after_ptrace
> seccomp_bpf.c:1622:TRACE_syscall.skip_after_ptrace:Expected -1 (18446744073709551615) == syscall(39) (26)
> seccomp_bpf.c:1623:TRACE_syscall.skip_after_ptrace:Expected 1 (1) == (*__errno_location ()) (22)
> [ FAIL ] TRACE_syscall.skip_after_ptrace
> [ RUN ] TRACE_syscall.kill_after_ptrace
> TRACE_syscall.kill_after_ptrace: Test exited normally instead of by signal (code: 1)
> [ FAIL ] TRACE_syscall.kill_after_ptrace
Fixes: 26703c636c
("um/ptrace: run seccomp after ptrace")
Signed-off-by: Mickaël Salaün <mic@digikod.net>
Acked-by: Kees Cook <keescook@chromium.org>
Cc: Jeff Dike <jdike@addtoit.com>
Cc: Richard Weinberger <richard@nod.at>
Cc: James Morris <jmorris@namei.org>
Cc: user-mode-linux-devel@lists.sourceforge.net
Signed-off-by: James Morris <james.l.morris@oracle.com>
Signed-off-by: Kees Cook <keescook@chromium.org>
38 lines
920 B
C
38 lines
920 B
C
/*
|
|
* Copyright (C) 2002 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
|
|
* Licensed under the GPL
|
|
*/
|
|
|
|
#include <linux/kernel.h>
|
|
#include <linux/ptrace.h>
|
|
#include <linux/seccomp.h>
|
|
#include <kern_util.h>
|
|
#include <sysdep/ptrace.h>
|
|
#include <sysdep/ptrace_user.h>
|
|
#include <sysdep/syscalls.h>
|
|
|
|
void handle_syscall(struct uml_pt_regs *r)
|
|
{
|
|
struct pt_regs *regs = container_of(r, struct pt_regs, regs);
|
|
int syscall;
|
|
|
|
/* Initialize the syscall number and default return value. */
|
|
UPT_SYSCALL_NR(r) = PT_SYSCALL_NR(r->gp);
|
|
PT_REGS_SET_SYSCALL_RETURN(regs, -ENOSYS);
|
|
|
|
if (syscall_trace_enter(regs))
|
|
goto out;
|
|
|
|
/* Do the seccomp check after ptrace; failures should be fast. */
|
|
if (secure_computing(NULL) == -1)
|
|
goto out;
|
|
|
|
syscall = UPT_SYSCALL_NR(r);
|
|
if (syscall >= 0 && syscall <= __NR_syscall_max)
|
|
PT_REGS_SET_SYSCALL_RETURN(regs,
|
|
EXECUTE_SYSCALL(syscall, regs));
|
|
|
|
out:
|
|
syscall_trace_leave(regs);
|
|
}
|