seccomp.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  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(const struct seccomp_data *sd);
  26. static inline int secure_computing(const struct seccomp_data *sd)
  27. {
  28. if (unlikely(test_thread_flag(TIF_SECCOMP)))
  29. return __secure_computing(sd);
  30. return 0;
  31. }
  32. #else
  33. extern void secure_computing_strict(int this_syscall);
  34. #endif
  35. extern long prctl_get_seccomp(void);
  36. extern long prctl_set_seccomp(unsigned long, char __user *);
  37. static inline int seccomp_mode(struct seccomp *s)
  38. {
  39. return s->mode;
  40. }
  41. #else /* CONFIG_SECCOMP */
  42. #include <linux/errno.h>
  43. struct seccomp { };
  44. struct seccomp_filter { };
  45. #ifdef CONFIG_HAVE_ARCH_SECCOMP_FILTER
  46. static inline int secure_computing(struct seccomp_data *sd) { return 0; }
  47. #else
  48. static inline void secure_computing_strict(int this_syscall) { return; }
  49. #endif
  50. static inline long prctl_get_seccomp(void)
  51. {
  52. return -EINVAL;
  53. }
  54. static inline long prctl_set_seccomp(unsigned long arg2, char __user *arg3)
  55. {
  56. return -EINVAL;
  57. }
  58. static inline int seccomp_mode(struct seccomp *s)
  59. {
  60. return SECCOMP_MODE_DISABLED;
  61. }
  62. #endif /* CONFIG_SECCOMP */
  63. #ifdef CONFIG_SECCOMP_FILTER
  64. extern void put_seccomp_filter(struct task_struct *tsk);
  65. extern void get_seccomp_filter(struct task_struct *tsk);
  66. #else /* CONFIG_SECCOMP_FILTER */
  67. static inline void put_seccomp_filter(struct task_struct *tsk)
  68. {
  69. return;
  70. }
  71. static inline void get_seccomp_filter(struct task_struct *tsk)
  72. {
  73. return;
  74. }
  75. #endif /* CONFIG_SECCOMP_FILTER */
  76. #if defined(CONFIG_SECCOMP_FILTER) && defined(CONFIG_CHECKPOINT_RESTORE)
  77. extern long seccomp_get_filter(struct task_struct *task,
  78. unsigned long filter_off, void __user *data);
  79. #else
  80. static inline long seccomp_get_filter(struct task_struct *task,
  81. unsigned long n, void __user *data)
  82. {
  83. return -EINVAL;
  84. }
  85. #endif /* CONFIG_SECCOMP_FILTER && CONFIG_CHECKPOINT_RESTORE */
  86. #endif /* _LINUX_SECCOMP_H */