syscall.c 920 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. /*
  2. * Copyright (C) 2002 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
  3. * Licensed under the GPL
  4. */
  5. #include <linux/kernel.h>
  6. #include <linux/ptrace.h>
  7. #include <linux/seccomp.h>
  8. #include <kern_util.h>
  9. #include <sysdep/ptrace.h>
  10. #include <sysdep/ptrace_user.h>
  11. #include <sysdep/syscalls.h>
  12. void handle_syscall(struct uml_pt_regs *r)
  13. {
  14. struct pt_regs *regs = container_of(r, struct pt_regs, regs);
  15. int syscall;
  16. /* Initialize the syscall number and default return value. */
  17. UPT_SYSCALL_NR(r) = PT_SYSCALL_NR(r->gp);
  18. PT_REGS_SET_SYSCALL_RETURN(regs, -ENOSYS);
  19. if (syscall_trace_enter(regs))
  20. goto out;
  21. /* Do the seccomp check after ptrace; failures should be fast. */
  22. if (secure_computing(NULL) == -1)
  23. goto out;
  24. syscall = UPT_SYSCALL_NR(r);
  25. if (syscall >= 0 && syscall <= __NR_syscall_max)
  26. PT_REGS_SET_SYSCALL_RETURN(regs,
  27. EXECUTE_SYSCALL(syscall, regs));
  28. out:
  29. syscall_trace_leave(regs);
  30. }