audit.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. /*
  2. * AppArmor security module
  3. *
  4. * This file contains AppArmor auditing function definitions.
  5. *
  6. * Copyright (C) 1998-2008 Novell/SUSE
  7. * Copyright 2009-2010 Canonical Ltd.
  8. *
  9. * This program is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU General Public License as
  11. * published by the Free Software Foundation, version 2 of the
  12. * License.
  13. */
  14. #ifndef __AA_AUDIT_H
  15. #define __AA_AUDIT_H
  16. #include <linux/audit.h>
  17. #include <linux/fs.h>
  18. #include <linux/lsm_audit.h>
  19. #include <linux/sched.h>
  20. #include <linux/slab.h>
  21. #include "file.h"
  22. struct aa_profile;
  23. extern const char *const audit_mode_names[];
  24. #define AUDIT_MAX_INDEX 5
  25. enum audit_mode {
  26. AUDIT_NORMAL, /* follow normal auditing of accesses */
  27. AUDIT_QUIET_DENIED, /* quiet all denied access messages */
  28. AUDIT_QUIET, /* quiet all messages */
  29. AUDIT_NOQUIET, /* do not quiet audit messages */
  30. AUDIT_ALL /* audit all accesses */
  31. };
  32. enum audit_type {
  33. AUDIT_APPARMOR_AUDIT,
  34. AUDIT_APPARMOR_ALLOWED,
  35. AUDIT_APPARMOR_DENIED,
  36. AUDIT_APPARMOR_HINT,
  37. AUDIT_APPARMOR_STATUS,
  38. AUDIT_APPARMOR_ERROR,
  39. AUDIT_APPARMOR_KILL,
  40. AUDIT_APPARMOR_AUTO
  41. };
  42. extern const char *const op_table[];
  43. enum aa_ops {
  44. OP_NULL,
  45. OP_SYSCTL,
  46. OP_CAPABLE,
  47. OP_UNLINK,
  48. OP_MKDIR,
  49. OP_RMDIR,
  50. OP_MKNOD,
  51. OP_TRUNC,
  52. OP_LINK,
  53. OP_SYMLINK,
  54. OP_RENAME_SRC,
  55. OP_RENAME_DEST,
  56. OP_CHMOD,
  57. OP_CHOWN,
  58. OP_GETATTR,
  59. OP_OPEN,
  60. OP_FPERM,
  61. OP_FLOCK,
  62. OP_FMMAP,
  63. OP_FMPROT,
  64. OP_CREATE,
  65. OP_POST_CREATE,
  66. OP_BIND,
  67. OP_CONNECT,
  68. OP_LISTEN,
  69. OP_ACCEPT,
  70. OP_SENDMSG,
  71. OP_RECVMSG,
  72. OP_GETSOCKNAME,
  73. OP_GETPEERNAME,
  74. OP_GETSOCKOPT,
  75. OP_SETSOCKOPT,
  76. OP_SOCK_SHUTDOWN,
  77. OP_PTRACE,
  78. OP_EXEC,
  79. OP_CHANGE_HAT,
  80. OP_CHANGE_PROFILE,
  81. OP_CHANGE_ONEXEC,
  82. OP_SETPROCATTR,
  83. OP_SETRLIMIT,
  84. OP_PROF_REPL,
  85. OP_PROF_LOAD,
  86. OP_PROF_RM,
  87. };
  88. struct apparmor_audit_data {
  89. int error;
  90. int op;
  91. int type;
  92. void *profile;
  93. const char *name;
  94. const char *info;
  95. union {
  96. void *target;
  97. struct {
  98. long pos;
  99. void *target;
  100. } iface;
  101. struct {
  102. int rlim;
  103. unsigned long max;
  104. } rlim;
  105. struct {
  106. const char *target;
  107. u32 request;
  108. u32 denied;
  109. kuid_t ouid;
  110. } fs;
  111. };
  112. };
  113. /* define a short hand for apparmor_audit_data structure */
  114. #define aad apparmor_audit_data
  115. void aa_audit_msg(int type, struct common_audit_data *sa,
  116. void (*cb) (struct audit_buffer *, void *));
  117. int aa_audit(int type, struct aa_profile *profile, gfp_t gfp,
  118. struct common_audit_data *sa,
  119. void (*cb) (struct audit_buffer *, void *));
  120. static inline int complain_error(int error)
  121. {
  122. if (error == -EPERM || error == -EACCES)
  123. return 0;
  124. return error;
  125. }
  126. #endif /* __AA_AUDIT_H */