audit.c 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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. #ifdef CONFIG_PPC64
  29. if (arch == AUDIT_ARCH_PPC)
  30. return 1;
  31. #endif
  32. return 0;
  33. }
  34. int audit_classify_syscall(int abi, unsigned syscall)
  35. {
  36. #ifdef CONFIG_PPC64
  37. extern int ppc32_classify_syscall(unsigned);
  38. if (abi == AUDIT_ARCH_PPC)
  39. return ppc32_classify_syscall(syscall);
  40. #endif
  41. switch(syscall) {
  42. case __NR_open:
  43. return AUDITSC_OPEN;
  44. case __NR_openat:
  45. return AUDITSC_OPENAT;
  46. case __NR_socketcall:
  47. return AUDITSC_SOCKETCALL;
  48. case __NR_execve:
  49. return AUDITSC_EXECVE;
  50. case __NR_openat2:
  51. return AUDITSC_OPENAT2;
  52. default:
  53. return AUDITSC_NATIVE;
  54. }
  55. }
  56. static int __init audit_classes_init(void)
  57. {
  58. #ifdef CONFIG_PPC64
  59. extern __u32 ppc32_dir_class[];
  60. extern __u32 ppc32_write_class[];
  61. extern __u32 ppc32_read_class[];
  62. extern __u32 ppc32_chattr_class[];
  63. extern __u32 ppc32_signal_class[];
  64. audit_register_class(AUDIT_CLASS_WRITE_32, ppc32_write_class);
  65. audit_register_class(AUDIT_CLASS_READ_32, ppc32_read_class);
  66. audit_register_class(AUDIT_CLASS_DIR_WRITE_32, ppc32_dir_class);
  67. audit_register_class(AUDIT_CLASS_CHATTR_32, ppc32_chattr_class);
  68. audit_register_class(AUDIT_CLASS_SIGNAL_32, ppc32_signal_class);
  69. #endif
  70. audit_register_class(AUDIT_CLASS_WRITE, write_class);
  71. audit_register_class(AUDIT_CLASS_READ, read_class);
  72. audit_register_class(AUDIT_CLASS_DIR_WRITE, dir_class);
  73. audit_register_class(AUDIT_CLASS_CHATTR, chattr_class);
  74. audit_register_class(AUDIT_CLASS_SIGNAL, signal_class);
  75. return 0;
  76. }
  77. __initcall(audit_classes_init);