seccomp.h 2.6 KB

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