lsm_audit.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. /*
  2. * Common LSM logging functions
  3. * Heavily borrowed from selinux/avc.h
  4. *
  5. * Author : Etienne BASSET <etienne.basset@ensta.org>
  6. *
  7. * All credits to : Stephen Smalley, <sds@epoch.ncsc.mil>
  8. * All BUGS to : Etienne BASSET <etienne.basset@ensta.org>
  9. */
  10. #ifndef _LSM_COMMON_LOGGING_
  11. #define _LSM_COMMON_LOGGING_
  12. #include <linux/stddef.h>
  13. #include <linux/errno.h>
  14. #include <linux/kernel.h>
  15. #include <linux/kdev_t.h>
  16. #include <linux/spinlock.h>
  17. #include <linux/init.h>
  18. #include <linux/audit.h>
  19. #include <linux/in6.h>
  20. #include <linux/path.h>
  21. #include <linux/key.h>
  22. #include <linux/skbuff.h>
  23. struct lsm_network_audit {
  24. int netif;
  25. struct sock *sk;
  26. u16 family;
  27. __be16 dport;
  28. __be16 sport;
  29. union {
  30. struct {
  31. __be32 daddr;
  32. __be32 saddr;
  33. } v4;
  34. struct {
  35. struct in6_addr daddr;
  36. struct in6_addr saddr;
  37. } v6;
  38. } fam;
  39. };
  40. struct lsm_ioctlop_audit {
  41. struct path path;
  42. u16 cmd;
  43. };
  44. /* Auxiliary data to use in generating the audit record. */
  45. struct common_audit_data {
  46. char type;
  47. #define LSM_AUDIT_DATA_PATH 1
  48. #define LSM_AUDIT_DATA_NET 2
  49. #define LSM_AUDIT_DATA_CAP 3
  50. #define LSM_AUDIT_DATA_IPC 4
  51. #define LSM_AUDIT_DATA_TASK 5
  52. #define LSM_AUDIT_DATA_KEY 6
  53. #define LSM_AUDIT_DATA_NONE 7
  54. #define LSM_AUDIT_DATA_KMOD 8
  55. #define LSM_AUDIT_DATA_INODE 9
  56. #define LSM_AUDIT_DATA_DENTRY 10
  57. #define LSM_AUDIT_DATA_IOCTL_OP 11
  58. union {
  59. struct path path;
  60. struct dentry *dentry;
  61. struct inode *inode;
  62. struct lsm_network_audit *net;
  63. int cap;
  64. int ipc_id;
  65. struct task_struct *tsk;
  66. #ifdef CONFIG_KEYS
  67. struct {
  68. key_serial_t key;
  69. char *key_desc;
  70. } key_struct;
  71. #endif
  72. char *kmod_name;
  73. struct lsm_ioctlop_audit *op;
  74. } u;
  75. /* this union contains LSM specific data */
  76. union {
  77. #ifdef CONFIG_SECURITY_SMACK
  78. struct smack_audit_data *smack_audit_data;
  79. #endif
  80. #ifdef CONFIG_SECURITY_SELINUX
  81. struct selinux_audit_data *selinux_audit_data;
  82. #endif
  83. #ifdef CONFIG_SECURITY_APPARMOR
  84. struct apparmor_audit_data *apparmor_audit_data;
  85. #endif
  86. }; /* per LSM data pointer union */
  87. };
  88. #define v4info fam.v4
  89. #define v6info fam.v6
  90. int ipv4_skb_to_auditdata(struct sk_buff *skb,
  91. struct common_audit_data *ad, u8 *proto);
  92. int ipv6_skb_to_auditdata(struct sk_buff *skb,
  93. struct common_audit_data *ad, u8 *proto);
  94. void common_lsm_audit(struct common_audit_data *a,
  95. void (*pre_audit)(struct audit_buffer *, void *),
  96. void (*post_audit)(struct audit_buffer *, void *));
  97. #endif