1 #include <linux/seccomp.h> 2 3 #ifndef SECCOMP_SET_MODE_STRICT 4 #define SECCOMP_SET_MODE_STRICT 0 5 #endif 6 #ifndef SECCOMP_SET_MODE_FILTER 7 #define SECCOMP_SET_MODE_FILTER 1 8 #endif 9 10 static size_t syscall_arg__scnprintf_seccomp_op(char *bf, size_t size, struct syscall_arg *arg) 11 { 12 int op = arg->val; 13 size_t printed = 0; 14 15 switch (op) { 16 #define P_SECCOMP_SET_MODE_OP(n) case SECCOMP_SET_MODE_##n: printed = scnprintf(bf, size, #n); break 17 P_SECCOMP_SET_MODE_OP(STRICT); 18 P_SECCOMP_SET_MODE_OP(FILTER); 19 #undef P_SECCOMP_SET_MODE_OP 20 default: printed = scnprintf(bf, size, "%#x", op); break; 21 } 22 23 return printed; 24 } 25 26 #define SCA_SECCOMP_OP syscall_arg__scnprintf_seccomp_op 27 28 #ifndef SECCOMP_FILTER_FLAG_TSYNC 29 #define SECCOMP_FILTER_FLAG_TSYNC 1 30 #endif 31 32 static size_t syscall_arg__scnprintf_seccomp_flags(char *bf, size_t size, 33 struct syscall_arg *arg) 34 { 35 int printed = 0, flags = arg->val; 36 37 #define P_FLAG(n) \ 38 if (flags & SECCOMP_FILTER_FLAG_##n) { \ 39 printed += scnprintf(bf + printed, size - printed, "%s%s", printed ? "|" : "", #n); \ 40 flags &= ~SECCOMP_FILTER_FLAG_##n; \ 41 } 42 43 P_FLAG(TSYNC); 44 #undef P_FLAG 45 46 if (flags) 47 printed += scnprintf(bf + printed, size - printed, "%s%#x", printed ? "|" : "", flags); 48 49 return printed; 50 } 51 52 #define SCA_SECCOMP_FLAGS syscall_arg__scnprintf_seccomp_flags 53