2019-08-25 10:49:17 +01:00
|
|
|
// SPDX-License-Identifier: GPL-2.0
|
2005-09-03 15:57:42 -07:00
|
|
|
/*
|
2007-10-16 01:27:00 -07:00
|
|
|
* Copyright (C) 2002 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
|
2005-09-03 15:57:42 -07:00
|
|
|
*/
|
|
|
|
|
2012-10-08 03:27:32 +01:00
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/ptrace.h>
|
2015-12-29 21:35:47 +01:00
|
|
|
#include <linux/seccomp.h>
|
2012-10-08 03:27:32 +01:00
|
|
|
#include <kern_util.h>
|
|
|
|
#include <sysdep/ptrace.h>
|
2015-12-29 21:35:44 +01:00
|
|
|
#include <sysdep/ptrace_user.h>
|
2012-10-08 03:27:32 +01:00
|
|
|
#include <sysdep/syscalls.h>
|
2020-02-13 14:26:44 +01:00
|
|
|
#include <linux/time-internal.h>
|
2020-04-15 09:51:52 +02:00
|
|
|
#include <asm/unistd.h>
|
2005-09-03 15:57:42 -07:00
|
|
|
|
2007-10-16 01:26:58 -07:00
|
|
|
void handle_syscall(struct uml_pt_regs *r)
|
2005-09-03 15:57:42 -07:00
|
|
|
{
|
|
|
|
struct pt_regs *regs = container_of(r, struct pt_regs, regs);
|
|
|
|
int syscall;
|
|
|
|
|
2019-05-27 10:34:27 +02:00
|
|
|
/*
|
|
|
|
* If we have infinite CPU resources, then make every syscall also a
|
|
|
|
* preemption point, since we don't have any other preemption in this
|
|
|
|
* case, and kernel threads would basically never run until userspace
|
|
|
|
* went to sleep, even if said userspace interacts with the kernel in
|
|
|
|
* various ways.
|
|
|
|
*/
|
2020-02-13 14:26:47 +01:00
|
|
|
if (time_travel_mode == TT_MODE_INFCPU ||
|
|
|
|
time_travel_mode == TT_MODE_EXTERNAL)
|
2019-05-27 10:34:27 +02:00
|
|
|
schedule();
|
|
|
|
|
2015-12-29 21:35:44 +01: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-02 19:59:42 -07:00
|
|
|
if (syscall_trace_enter(regs))
|
2016-08-01 23:01:55 +02:00
|
|
|
goto out;
|
2015-12-29 21:35:47 +01:00
|
|
|
|
2016-06-02 19:59:42 -07:00
|
|
|
/* Do the seccomp check after ptrace; failures should be fast. */
|
2019-09-24 08:44:20 +02:00
|
|
|
if (secure_computing() == -1)
|
2016-08-01 23:01:55 +02:00
|
|
|
goto out;
|
2005-09-03 15:57:42 -07:00
|
|
|
|
2015-12-29 21:35:44 +01:00
|
|
|
syscall = UPT_SYSCALL_NR(r);
|
2021-05-17 16:38:13 +09:00
|
|
|
if (syscall >= 0 && syscall < __NR_syscalls)
|
2015-12-29 21:35:44 +01:00
|
|
|
PT_REGS_SET_SYSCALL_RETURN(regs,
|
|
|
|
EXECUTE_SYSCALL(syscall, regs));
|
2005-09-03 15:57:42 -07:00
|
|
|
|
2016-08-01 23:01:55 +02:00
|
|
|
out:
|
2012-05-23 00:18:33 -04:00
|
|
|
syscall_trace_leave(regs);
|
2005-09-03 15:57:42 -07:00
|
|
|
}
|