avc.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. /*
  2. * Access vector cache interface for object managers.
  3. *
  4. * Author : Stephen Smalley, <sds@epoch.ncsc.mil>
  5. */
  6. #ifndef _SELINUX_AVC_H_
  7. #define _SELINUX_AVC_H_
  8. #include <linux/stddef.h>
  9. #include <linux/errno.h>
  10. #include <linux/kernel.h>
  11. #include <linux/kdev_t.h>
  12. #include <linux/spinlock.h>
  13. #include <linux/init.h>
  14. #include <linux/audit.h>
  15. #include <linux/lsm_audit.h>
  16. #include <linux/in6.h>
  17. #include "flask.h"
  18. #include "av_permissions.h"
  19. #include "security.h"
  20. #ifdef CONFIG_SECURITY_SELINUX_DEVELOP
  21. extern int selinux_enforcing;
  22. #else
  23. #define selinux_enforcing 1
  24. #endif
  25. /*
  26. * An entry in the AVC.
  27. */
  28. struct avc_entry;
  29. struct task_struct;
  30. struct inode;
  31. struct sock;
  32. struct sk_buff;
  33. /*
  34. * AVC statistics
  35. */
  36. struct avc_cache_stats {
  37. unsigned int lookups;
  38. unsigned int misses;
  39. unsigned int allocations;
  40. unsigned int reclaims;
  41. unsigned int frees;
  42. };
  43. struct selinux_audit_data {
  44. u32 ssid;
  45. u32 tsid;
  46. u16 tclass;
  47. u32 requested;
  48. u32 audited;
  49. u32 denied;
  50. /*
  51. * auditdeny is a bit tricky and unintuitive. See the
  52. * comments in avc.c for it's meaning and usage.
  53. */
  54. u32 auditdeny;
  55. int result;
  56. };
  57. /*
  58. * AVC operations
  59. */
  60. void __init avc_init(void);
  61. int avc_audit(u32 ssid, u32 tsid,
  62. u16 tclass, u32 requested,
  63. struct av_decision *avd,
  64. int result,
  65. struct common_audit_data *a, unsigned flags);
  66. #define AVC_STRICT 1 /* Ignore permissive mode. */
  67. int avc_has_perm_noaudit(u32 ssid, u32 tsid,
  68. u16 tclass, u32 requested,
  69. unsigned flags,
  70. struct av_decision *avd);
  71. int avc_has_perm_flags(u32 ssid, u32 tsid,
  72. u16 tclass, u32 requested,
  73. struct common_audit_data *auditdata,
  74. unsigned);
  75. static inline int avc_has_perm(u32 ssid, u32 tsid,
  76. u16 tclass, u32 requested,
  77. struct common_audit_data *auditdata)
  78. {
  79. return avc_has_perm_flags(ssid, tsid, tclass, requested, auditdata, 0);
  80. }
  81. u32 avc_policy_seqno(void);
  82. #define AVC_CALLBACK_GRANT 1
  83. #define AVC_CALLBACK_TRY_REVOKE 2
  84. #define AVC_CALLBACK_REVOKE 4
  85. #define AVC_CALLBACK_RESET 8
  86. #define AVC_CALLBACK_AUDITALLOW_ENABLE 16
  87. #define AVC_CALLBACK_AUDITALLOW_DISABLE 32
  88. #define AVC_CALLBACK_AUDITDENY_ENABLE 64
  89. #define AVC_CALLBACK_AUDITDENY_DISABLE 128
  90. int avc_add_callback(int (*callback)(u32 event, u32 ssid, u32 tsid,
  91. u16 tclass, u32 perms,
  92. u32 *out_retained),
  93. u32 events, u32 ssid, u32 tsid,
  94. u16 tclass, u32 perms);
  95. /* Exported to selinuxfs */
  96. int avc_get_hash_stats(char *page);
  97. extern unsigned int avc_cache_threshold;
  98. /* Attempt to free avc node cache */
  99. void avc_disable(void);
  100. #ifdef CONFIG_SECURITY_SELINUX_AVC_STATS
  101. DECLARE_PER_CPU(struct avc_cache_stats, avc_cache_stats);
  102. #endif
  103. #endif /* _SELINUX_AVC_H_ */