Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | #ifndef _LINUX_SECCOMP_H |
| 2 | #define _LINUX_SECCOMP_H |
| 3 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4 | |
| 5 | #ifdef CONFIG_SECCOMP |
| 6 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7 | #include <linux/thread_info.h> |
| 8 | #include <asm/seccomp.h> |
| 9 | |
Will Drewry | 932eceb | 2012-04-12 16:47:54 -0500 | [diff] [blame^] | 10 | struct seccomp { |
| 11 | int mode; |
| 12 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 13 | |
| 14 | extern void __secure_computing(int); |
| 15 | static inline void secure_computing(int this_syscall) |
| 16 | { |
| 17 | if (unlikely(test_thread_flag(TIF_SECCOMP))) |
| 18 | __secure_computing(this_syscall); |
| 19 | } |
| 20 | |
Andrea Arcangeli | 1d9d02f | 2007-07-15 23:41:32 -0700 | [diff] [blame] | 21 | extern long prctl_get_seccomp(void); |
| 22 | extern long prctl_set_seccomp(unsigned long); |
| 23 | |
Will Drewry | 932eceb | 2012-04-12 16:47:54 -0500 | [diff] [blame^] | 24 | static inline int seccomp_mode(struct seccomp *s) |
Andy Lutomirski | 5cec93c | 2011-06-05 13:50:24 -0400 | [diff] [blame] | 25 | { |
| 26 | return s->mode; |
| 27 | } |
| 28 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 29 | #else /* CONFIG_SECCOMP */ |
| 30 | |
Ralf Baechle | 42a17ad | 2009-04-18 11:30:56 +0200 | [diff] [blame] | 31 | #include <linux/errno.h> |
| 32 | |
Will Drewry | 932eceb | 2012-04-12 16:47:54 -0500 | [diff] [blame^] | 33 | struct seccomp { }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 34 | |
| 35 | #define secure_computing(x) do { } while (0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 36 | |
Andrea Arcangeli | 1d9d02f | 2007-07-15 23:41:32 -0700 | [diff] [blame] | 37 | static inline long prctl_get_seccomp(void) |
| 38 | { |
| 39 | return -EINVAL; |
| 40 | } |
| 41 | |
| 42 | static inline long prctl_set_seccomp(unsigned long arg2) |
| 43 | { |
| 44 | return -EINVAL; |
| 45 | } |
| 46 | |
Will Drewry | 932eceb | 2012-04-12 16:47:54 -0500 | [diff] [blame^] | 47 | static inline int seccomp_mode(struct seccomp *s) |
Andy Lutomirski | 5cec93c | 2011-06-05 13:50:24 -0400 | [diff] [blame] | 48 | { |
| 49 | return 0; |
| 50 | } |
| 51 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 52 | #endif /* CONFIG_SECCOMP */ |
| 53 | |
| 54 | #endif /* _LINUX_SECCOMP_H */ |