seccomp.h 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. #ifndef _LINUX_SECCOMP_H
  2. #define _LINUX_SECCOMP_H
  3. #include <uapi/linux/seccomp.h>
  4. #define SECCOMP_FILTER_FLAG_MASK (SECCOMP_FILTER_FLAG_TSYNC)
  5. #ifdef CONFIG_SECCOMP
  6. #include <linux/thread_info.h>
  7. #include <asm/seccomp.h>
  8. struct seccomp_filter;
  9. /**
  10. * struct seccomp - the state of a seccomp'ed process
  11. *
  12. * @mode: indicates one of the valid values above for controlled
  13. * system calls available to a process.
  14. * @filter: must always point to a valid seccomp-filter or NULL as it is
  15. * accessed without locking during system call entry.
  16. *
  17. * @filter must only be accessed from the context of current as there
  18. * is no read locking.
  19. */
  20. struct seccomp {
  21. int mode;
  22. struct seccomp_filter *filter;
  23. };
  24. #ifdef CONFIG_HAVE_ARCH_SECCOMP_FILTER
  25. extern int __secure_computing(void);
  26. static inline int secure_computing(void)
  27. {
  28. if (unlikely(test_thread_flag(TIF_SECCOMP)))
  29. return __secure_computing();
  30. return 0;
  31. }
  32. #define SECCOMP_PHASE1_OK 0
  33. #define SECCOMP_PHASE1_SKIP 1
  34. extern u32 seccomp_phase1(struct seccomp_data *sd);
  35. int seccomp_phase2(u32 phase1_result);
  36. #else
  37. extern void secure_computing_strict(int this_syscall);
  38. #endif
  39. extern long prctl_get_seccomp(void);
  40. extern long prctl_set_seccomp(unsigned long, char __user *);
  41. static inline int seccomp_mode(struct seccomp *s)
  42. {
  43. return s->mode;
  44. }
  45. #else /* CONFIG_SECCOMP */
  46. #include <linux/errno.h>
  47. struct seccomp { };
  48. struct seccomp_filter { };
  49. #ifdef CONFIG_HAVE_ARCH_SECCOMP_FILTER
  50. static inline int secure_computing(void) { return 0; }
  51. #else
  52. static inline void secure_computing_strict(int this_syscall) { return; }
  53. #endif
  54. static inline long prctl_get_seccomp(void)
  55. {
  56. return -EINVAL;
  57. }
  58. static inline long prctl_set_seccomp(unsigned long arg2, char __user *arg3)
  59. {
  60. return -EINVAL;
  61. }
  62. static inline int seccomp_mode(struct seccomp *s)
  63. {
  64. return 0;
  65. }
  66. #endif /* CONFIG_SECCOMP */
  67. #ifdef CONFIG_SECCOMP_FILTER
  68. extern void put_seccomp_filter(struct task_struct *tsk);
  69. extern void get_seccomp_filter(struct task_struct *tsk);
  70. #else /* CONFIG_SECCOMP_FILTER */
  71. static inline void put_seccomp_filter(struct task_struct *tsk)
  72. {
  73. return;
  74. }
  75. static inline void get_seccomp_filter(struct task_struct *tsk)
  76. {
  77. return;
  78. }
  79. #endif /* CONFIG_SECCOMP_FILTER */
  80. #endif /* _LINUX_SECCOMP_H */