Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0
0002 /*
0003  * Copyright (C) 2002 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
0004  */
0005 
0006 #include <linux/kernel.h>
0007 #include <linux/ptrace.h>
0008 #include <linux/seccomp.h>
0009 #include <kern_util.h>
0010 #include <sysdep/ptrace.h>
0011 #include <sysdep/ptrace_user.h>
0012 #include <sysdep/syscalls.h>
0013 #include <linux/time-internal.h>
0014 #include <asm/unistd.h>
0015 
0016 void handle_syscall(struct uml_pt_regs *r)
0017 {
0018     struct pt_regs *regs = container_of(r, struct pt_regs, regs);
0019     int syscall;
0020 
0021     /*
0022      * If we have infinite CPU resources, then make every syscall also a
0023      * preemption point, since we don't have any other preemption in this
0024      * case, and kernel threads would basically never run until userspace
0025      * went to sleep, even if said userspace interacts with the kernel in
0026      * various ways.
0027      */
0028     if (time_travel_mode == TT_MODE_INFCPU ||
0029         time_travel_mode == TT_MODE_EXTERNAL)
0030         schedule();
0031 
0032     /* Initialize the syscall number and default return value. */
0033     UPT_SYSCALL_NR(r) = PT_SYSCALL_NR(r->gp);
0034     PT_REGS_SET_SYSCALL_RETURN(regs, -ENOSYS);
0035 
0036     if (syscall_trace_enter(regs))
0037         goto out;
0038 
0039     /* Do the seccomp check after ptrace; failures should be fast. */
0040     if (secure_computing() == -1)
0041         goto out;
0042 
0043     syscall = UPT_SYSCALL_NR(r);
0044     if (syscall >= 0 && syscall < __NR_syscalls)
0045         PT_REGS_SET_SYSCALL_RETURN(regs,
0046                 EXECUTE_SYSCALL(syscall, regs));
0047 
0048 out:
0049     syscall_trace_leave(regs);
0050 }