seccomp.c 1.2 KB

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