audit.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  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 *audit_mode_names[];
  24. #define AUDIT_MAX_INDEX 5
  25. #define AUDIT_APPARMOR_AUTO 0 /* auto choose audit message type */
  26. enum audit_mode {
  27. AUDIT_NORMAL, /* follow normal auditing of accesses */
  28. AUDIT_QUIET_DENIED, /* quiet all denied access messages */
  29. AUDIT_QUIET, /* quiet all messages */
  30. AUDIT_NOQUIET, /* do not quiet audit messages */
  31. AUDIT_ALL /* audit all accesses */
  32. };
  33. enum audit_type {
  34. AUDIT_APPARMOR_AUDIT,
  35. AUDIT_APPARMOR_ALLOWED,
  36. AUDIT_APPARMOR_DENIED,
  37. AUDIT_APPARMOR_HINT,
  38. AUDIT_APPARMOR_STATUS,
  39. AUDIT_APPARMOR_ERROR,
  40. AUDIT_APPARMOR_KILL
  41. };
  42. extern const char *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. /* define a short hand for apparmor_audit_data portion of common_audit_data */
  89. #define aad apparmor_audit_data
  90. void aa_audit_msg(int type, struct common_audit_data *sa,
  91. void (*cb) (struct audit_buffer *, void *));
  92. int aa_audit(int type, struct aa_profile *profile, gfp_t gfp,
  93. struct common_audit_data *sa,
  94. void (*cb) (struct audit_buffer *, void *));
  95. static inline int complain_error(int error)
  96. {
  97. if (error == -EPERM || error == -EACCES)
  98. return 0;
  99. return error;
  100. }
  101. #endif /* __AA_AUDIT_H */