audit.c 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. #include <linux/init.h>
  2. #include <linux/types.h>
  3. #include <linux/audit.h>
  4. #include <asm/unistd.h>
  5. #include "audit.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_COMPAT
  29. if (arch == AUDIT_ARCH_S390)
  30. return 1;
  31. #endif
  32. return 0;
  33. }
  34. int audit_classify_syscall(int abi, unsigned syscall)
  35. {
  36. #ifdef CONFIG_COMPAT
  37. if (abi == AUDIT_ARCH_S390)
  38. return s390_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, s390_write_class);
  57. audit_register_class(AUDIT_CLASS_READ_32, s390_read_class);
  58. audit_register_class(AUDIT_CLASS_DIR_WRITE_32, s390_dir_class);
  59. audit_register_class(AUDIT_CLASS_CHATTR_32, s390_chattr_class);
  60. audit_register_class(AUDIT_CLASS_SIGNAL_32, s390_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);