audit.c 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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. #include "audit.h"
  7. static unsigned dir_class[] = {
  8. #include <asm-generic/audit_dir_write.h>
  9. ~0U
  10. };
  11. static unsigned read_class[] = {
  12. #include <asm-generic/audit_read.h>
  13. ~0U
  14. };
  15. static unsigned write_class[] = {
  16. #include <asm-generic/audit_write.h>
  17. ~0U
  18. };
  19. static unsigned chattr_class[] = {
  20. #include <asm-generic/audit_change_attr.h>
  21. ~0U
  22. };
  23. static unsigned signal_class[] = {
  24. #include <asm-generic/audit_signal.h>
  25. ~0U
  26. };
  27. int audit_classify_arch(int arch)
  28. {
  29. #ifdef CONFIG_COMPAT
  30. if (arch == AUDIT_ARCH_S390)
  31. return 1;
  32. #endif
  33. return 0;
  34. }
  35. int audit_classify_syscall(int abi, unsigned syscall)
  36. {
  37. #ifdef CONFIG_COMPAT
  38. if (abi == AUDIT_ARCH_S390)
  39. return s390_classify_syscall(syscall);
  40. #endif
  41. switch(syscall) {
  42. case __NR_open:
  43. return 2;
  44. case __NR_openat:
  45. return 3;
  46. case __NR_socketcall:
  47. return 4;
  48. case __NR_execve:
  49. return 5;
  50. default:
  51. return 0;
  52. }
  53. }
  54. static int __init audit_classes_init(void)
  55. {
  56. #ifdef CONFIG_COMPAT
  57. audit_register_class(AUDIT_CLASS_WRITE_32, s390_write_class);
  58. audit_register_class(AUDIT_CLASS_READ_32, s390_read_class);
  59. audit_register_class(AUDIT_CLASS_DIR_WRITE_32, s390_dir_class);
  60. audit_register_class(AUDIT_CLASS_CHATTR_32, s390_chattr_class);
  61. audit_register_class(AUDIT_CLASS_SIGNAL_32, s390_signal_class);
  62. #endif
  63. audit_register_class(AUDIT_CLASS_WRITE, write_class);
  64. audit_register_class(AUDIT_CLASS_READ, read_class);
  65. audit_register_class(AUDIT_CLASS_DIR_WRITE, dir_class);
  66. audit_register_class(AUDIT_CLASS_CHATTR, chattr_class);
  67. audit_register_class(AUDIT_CLASS_SIGNAL, signal_class);
  68. return 0;
  69. }
  70. __initcall(audit_classes_init);