stub-data.h 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * Copyright (C) 2015 Thomas Meyer (thomas@m3y3r.de)
  4. * Copyright (C) 2005 Jeff Dike (jdike@karaya.com)
  5. */
  6. #ifndef __STUB_DATA_H
  7. #define __STUB_DATA_H
  8. #include <linux/compiler_types.h>
  9. #include <as-layout.h>
  10. #include <sysdep/tls.h>
  11. #include <sysdep/stub-data.h>
  12. #include <mm_id.h>
  13. #define FUTEX_IN_CHILD 0
  14. #define FUTEX_IN_KERN 1
  15. struct stub_init_data {
  16. int seccomp;
  17. unsigned long stub_start;
  18. int stub_code_fd;
  19. unsigned long stub_code_offset;
  20. int stub_data_fd;
  21. unsigned long stub_data_offset;
  22. unsigned long signal_handler;
  23. unsigned long signal_restorer;
  24. };
  25. #define STUB_NEXT_SYSCALL(s) \
  26. ((struct stub_syscall *) (((unsigned long) s) + (s)->cmd_len))
  27. enum stub_syscall_type {
  28. STUB_SYSCALL_UNSET = 0,
  29. STUB_SYSCALL_MMAP,
  30. STUB_SYSCALL_MUNMAP,
  31. };
  32. struct stub_syscall {
  33. struct {
  34. unsigned long addr;
  35. unsigned long length;
  36. unsigned long offset;
  37. int fd;
  38. int prot;
  39. } mem;
  40. enum stub_syscall_type syscall;
  41. };
  42. struct stub_data {
  43. long err;
  44. int syscall_data_len;
  45. /* 128 leaves enough room for additional fields in the struct */
  46. struct stub_syscall syscall_data[(UM_KERN_PAGE_SIZE - 128) / sizeof(struct stub_syscall)] __aligned(16);
  47. /* data shared with signal handler (only used in seccomp mode) */
  48. short restart_wait;
  49. unsigned int futex;
  50. int signal;
  51. unsigned short si_offset;
  52. unsigned short mctx_offset;
  53. /* seccomp architecture specific state restore */
  54. struct stub_data_arch arch_data;
  55. /* Stack for our signal handlers and for calling into . */
  56. unsigned char sigstack[UM_KERN_PAGE_SIZE] __aligned(UM_KERN_PAGE_SIZE);
  57. };
  58. #endif