avc.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  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. /*
  44. * AVC operations
  45. */
  46. void __init avc_init(void);
  47. int avc_audit(u32 ssid, u32 tsid,
  48. u16 tclass, u32 requested,
  49. struct av_decision *avd,
  50. int result,
  51. struct common_audit_data *a, unsigned flags);
  52. #define AVC_STRICT 1 /* Ignore permissive mode. */
  53. int avc_has_perm_noaudit(u32 ssid, u32 tsid,
  54. u16 tclass, u32 requested,
  55. unsigned flags,
  56. struct av_decision *avd);
  57. int avc_has_perm_flags(u32 ssid, u32 tsid,
  58. u16 tclass, u32 requested,
  59. struct common_audit_data *auditdata,
  60. unsigned);
  61. static inline int avc_has_perm(u32 ssid, u32 tsid,
  62. u16 tclass, u32 requested,
  63. struct common_audit_data *auditdata)
  64. {
  65. return avc_has_perm_flags(ssid, tsid, tclass, requested, auditdata, 0);
  66. }
  67. u32 avc_policy_seqno(void);
  68. #define AVC_CALLBACK_GRANT 1
  69. #define AVC_CALLBACK_TRY_REVOKE 2
  70. #define AVC_CALLBACK_REVOKE 4
  71. #define AVC_CALLBACK_RESET 8
  72. #define AVC_CALLBACK_AUDITALLOW_ENABLE 16
  73. #define AVC_CALLBACK_AUDITALLOW_DISABLE 32
  74. #define AVC_CALLBACK_AUDITDENY_ENABLE 64
  75. #define AVC_CALLBACK_AUDITDENY_DISABLE 128
  76. int avc_add_callback(int (*callback)(u32 event, u32 ssid, u32 tsid,
  77. u16 tclass, u32 perms,
  78. u32 *out_retained),
  79. u32 events, u32 ssid, u32 tsid,
  80. u16 tclass, u32 perms);
  81. /* Exported to selinuxfs */
  82. int avc_get_hash_stats(char *page);
  83. extern unsigned int avc_cache_threshold;
  84. /* Attempt to free avc node cache */
  85. void avc_disable(void);
  86. #ifdef CONFIG_SECURITY_SELINUX_AVC_STATS
  87. DECLARE_PER_CPU(struct avc_cache_stats, avc_cache_stats);
  88. #endif
  89. #endif /* _SELINUX_AVC_H_ */