audit.c 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. // SPDX-License-Identifier: GPL-2.0
  2. #include <linux/init.h>
  3. #include <linux/types.h>
  4. #include <linux/audit.h>
  5. #include <asm/unistd.h>
  6. static unsigned dir_class[] = {
  7. #include <asm-generic/audit_dir_write.h>
  8. ~0U
  9. };
  10. static unsigned read_class[] = {
  11. #include <asm-generic/audit_read.h>
  12. ~0U
  13. };
  14. static unsigned write_class[] = {
  15. #include <asm-generic/audit_write.h>
  16. ~0U
  17. };
  18. static unsigned chattr_class[] = {
  19. #include <asm-generic/audit_change_attr.h>
  20. ~0U
  21. };
  22. static unsigned signal_class[] = {
  23. #include <asm-generic/audit_signal.h>
  24. ~0U
  25. };
  26. int audit_classify_arch(int arch)
  27. {
  28. return 0;
  29. }
  30. int audit_classify_syscall(int abi, unsigned syscall)
  31. {
  32. switch(syscall) {
  33. case __NR_open:
  34. return 2;
  35. case __NR_openat:
  36. return 3;
  37. case __NR_execve:
  38. return 5;
  39. default:
  40. return 0;
  41. }
  42. }
  43. static int __init audit_classes_init(void)
  44. {
  45. audit_register_class(AUDIT_CLASS_WRITE, write_class);
  46. audit_register_class(AUDIT_CLASS_READ, read_class);
  47. audit_register_class(AUDIT_CLASS_DIR_WRITE, dir_class);
  48. audit_register_class(AUDIT_CLASS_CHATTR, chattr_class);
  49. audit_register_class(AUDIT_CLASS_SIGNAL, signal_class);
  50. return 0;
  51. }
  52. __initcall(audit_classes_init);