syscall.c 1.0 KB
Newer Older
1
/*
J
Jeff Dike 已提交
2
 * Copyright (C) 2002 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
3 4 5
 * Licensed under the GPL
 */

6 7
#include <linux/kernel.h>
#include <linux/ptrace.h>
M
Mickaël Salaün 已提交
8
#include <linux/seccomp.h>
9 10
#include <kern_util.h>
#include <sysdep/ptrace.h>
11
#include <sysdep/ptrace_user.h>
12
#include <sysdep/syscalls.h>
13

14
void handle_syscall(struct uml_pt_regs *r)
15 16 17 18
{
	struct pt_regs *regs = container_of(r, struct pt_regs, regs);
	int syscall;

19 20 21 22
	/* Initialize the syscall number and default return value. */
	UPT_SYSCALL_NR(r) = PT_SYSCALL_NR(r->gp);
	PT_REGS_SET_SYSCALL_RETURN(regs, -ENOSYS);

M
Mickaël Salaün 已提交
23
	/* Do the secure computing check first; failures should be fast. */
24
	if (secure_computing(NULL) == -1)
M
Mickaël Salaün 已提交
25 26
		return;

27
	if (syscall_trace_enter(regs))
28
		goto out;
29

30 31 32 33 34
	/* Update the syscall number after orig_ax has potentially been updated
	 * with ptrace.
	 */
	UPT_SYSCALL_NR(r) = PT_SYSCALL_NR(r->gp);
	syscall = UPT_SYSCALL_NR(r);
35

36 37 38
	if (syscall >= 0 && syscall <= __NR_syscall_max)
		PT_REGS_SET_SYSCALL_RETURN(regs,
				EXECUTE_SYSCALL(syscall, regs));
39

40
out:
41
	syscall_trace_leave(regs);
42
}