audit.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. /* audit -- definition of audit_context structure and supporting types
  2. *
  3. * Copyright 2003-2004 Red Hat, Inc.
  4. * Copyright 2005 Hewlett-Packard Development Company, L.P.
  5. * Copyright 2005 IBM Corporation
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation; either version 2 of the License, or
  10. * (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, write to the Free Software
  19. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  20. */
  21. #include <linux/mutex.h>
  22. #include <linux/fs.h>
  23. #include <linux/audit.h>
  24. #include <linux/skbuff.h>
  25. /* 0 = no checking
  26. 1 = put_count checking
  27. 2 = verbose put_count checking
  28. */
  29. #define AUDIT_DEBUG 0
  30. /* At task start time, the audit_state is set in the audit_context using
  31. a per-task filter. At syscall entry, the audit_state is augmented by
  32. the syscall filter. */
  33. enum audit_state {
  34. AUDIT_DISABLED, /* Do not create per-task audit_context.
  35. * No syscall-specific audit records can
  36. * be generated. */
  37. AUDIT_SETUP_CONTEXT, /* Create the per-task audit_context,
  38. * but don't necessarily fill it in at
  39. * syscall entry time (i.e., filter
  40. * instead). */
  41. AUDIT_BUILD_CONTEXT, /* Create the per-task audit_context,
  42. * and always fill it in at syscall
  43. * entry time. This makes a full
  44. * syscall record available if some
  45. * other part of the kernel decides it
  46. * should be recorded. */
  47. AUDIT_RECORD_CONTEXT /* Create the per-task audit_context,
  48. * always fill it in at syscall entry
  49. * time, and always write out the audit
  50. * record at syscall exit time. */
  51. };
  52. /* Rule lists */
  53. struct audit_field {
  54. u32 type;
  55. u32 val;
  56. u32 op;
  57. char *se_str;
  58. struct selinux_audit_rule *se_rule;
  59. };
  60. struct audit_krule {
  61. int vers_ops;
  62. u32 flags;
  63. u32 listnr;
  64. u32 action;
  65. u32 mask[AUDIT_BITMASK_SIZE];
  66. u32 buflen; /* for data alloc on list rules */
  67. u32 field_count;
  68. struct audit_field *fields;
  69. };
  70. struct audit_entry {
  71. struct list_head list;
  72. struct rcu_head rcu;
  73. struct audit_krule rule;
  74. };
  75. extern int audit_pid;
  76. extern int audit_comparator(const u32 left, const u32 op, const u32 right);
  77. extern struct sk_buff * audit_make_reply(int pid, int seq, int type,
  78. int done, int multi,
  79. void *payload, int size);
  80. extern void audit_send_reply(int pid, int seq, int type,
  81. int done, int multi,
  82. void *payload, int size);
  83. extern void audit_log_lost(const char *message);
  84. extern void audit_panic(const char *message);
  85. extern struct mutex audit_netlink_mutex;
  86. struct audit_netlink_list {
  87. int pid;
  88. struct sk_buff_head q;
  89. };
  90. int audit_send_list(void *);
  91. extern int selinux_audit_rule_update(void);
  92. #ifdef CONFIG_AUDITSYSCALL
  93. extern void __audit_signal_info(int sig, struct task_struct *t);
  94. static inline void audit_signal_info(int sig, struct task_struct *t)
  95. {
  96. if (unlikely(audit_pid && t->tgid == audit_pid))
  97. __audit_signal_info(sig, t);
  98. }
  99. #else
  100. #define audit_signal_info(s,t)
  101. #endif