audit.c 1.7 KB

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