2005-09-04 06:57:42 +08:00
|
|
|
/*
|
2007-10-16 16:27:00 +08:00
|
|
|
* Copyright (C) 2002 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
|
2005-09-04 06:57:42 +08:00
|
|
|
* Licensed under the GPL
|
|
|
|
*/
|
|
|
|
|
2012-10-08 10:27:32 +08:00
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/ptrace.h>
|
2015-12-30 04:35:47 +08:00
|
|
|
#include <linux/seccomp.h>
|
2012-10-08 10:27:32 +08:00
|
|
|
#include <kern_util.h>
|
|
|
|
#include <sysdep/ptrace.h>
|
2015-12-30 04:35:44 +08:00
|
|
|
#include <sysdep/ptrace_user.h>
|
2012-10-08 10:27:32 +08:00
|
|
|
#include <sysdep/syscalls.h>
|
2005-09-04 06:57:42 +08:00
|
|
|
|
2007-10-16 16:26:58 +08:00
|
|
|
void handle_syscall(struct uml_pt_regs *r)
|
2005-09-04 06:57:42 +08:00
|
|
|
{
|
|
|
|
struct pt_regs *regs = container_of(r, struct pt_regs, regs);
|
|
|
|
int syscall;
|
|
|
|
|
2015-12-30 04:35:44 +08:00
|
|
|
/* Initialize the syscall number and default return value. */
|
|
|
|
UPT_SYSCALL_NR(r) = PT_SYSCALL_NR(r->gp);
|
|
|
|
PT_REGS_SET_SYSCALL_RETURN(regs, -ENOSYS);
|
|
|
|
|
2016-06-03 10:59:42 +08:00
|
|
|
if (syscall_trace_enter(regs))
|
2016-08-02 05:01:55 +08:00
|
|
|
goto out;
|
2015-12-30 04:35:47 +08:00
|
|
|
|
2016-06-03 10:59:42 +08:00
|
|
|
/* Do the seccomp check after ptrace; failures should be fast. */
|
|
|
|
if (secure_computing(NULL) == -1)
|
2016-08-02 05:01:55 +08:00
|
|
|
goto out;
|
2005-09-04 06:57:42 +08:00
|
|
|
|
2015-12-30 04:35:44 +08:00
|
|
|
syscall = UPT_SYSCALL_NR(r);
|
|
|
|
if (syscall >= 0 && syscall <= __NR_syscall_max)
|
|
|
|
PT_REGS_SET_SYSCALL_RETURN(regs,
|
|
|
|
EXECUTE_SYSCALL(syscall, regs));
|
2005-09-04 06:57:42 +08:00
|
|
|
|
2016-08-02 05:01:55 +08:00
|
|
|
out:
|
2012-05-23 12:18:33 +08:00
|
|
|
syscall_trace_leave(regs);
|
2005-09-04 06:57:42 +08:00
|
|
|
}
|