avc.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  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 <asm/system.h>
  18. #include "flask.h"
  19. #include "av_permissions.h"
  20. #include "security.h"
  21. #ifdef CONFIG_SECURITY_SELINUX_DEVELOP
  22. extern int selinux_enforcing;
  23. #else
  24. #define selinux_enforcing 1
  25. #endif
  26. /*
  27. * An entry in the AVC.
  28. */
  29. struct avc_entry;
  30. struct task_struct;
  31. struct inode;
  32. struct sock;
  33. struct sk_buff;
  34. /*
  35. * AVC statistics
  36. */
  37. struct avc_cache_stats {
  38. unsigned int lookups;
  39. unsigned int hits;
  40. unsigned int misses;
  41. unsigned int allocations;
  42. unsigned int reclaims;
  43. unsigned int frees;
  44. };
  45. /*
  46. * AVC operations
  47. */
  48. void __init avc_init(void);
  49. int avc_audit(u32 ssid, u32 tsid,
  50. u16 tclass, u32 requested,
  51. struct av_decision *avd,
  52. int result,
  53. struct common_audit_data *a, unsigned flags);
  54. #define AVC_STRICT 1 /* Ignore permissive mode. */
  55. int avc_has_perm_noaudit(u32 ssid, u32 tsid,
  56. u16 tclass, u32 requested,
  57. unsigned flags,
  58. struct av_decision *avd);
  59. int avc_has_perm_flags(u32 ssid, u32 tsid,
  60. u16 tclass, u32 requested,
  61. struct common_audit_data *auditdata,
  62. unsigned);
  63. static inline int avc_has_perm(u32 ssid, u32 tsid,
  64. u16 tclass, u32 requested,
  65. struct common_audit_data *auditdata)
  66. {
  67. return avc_has_perm_flags(ssid, tsid, tclass, requested, auditdata, 0);
  68. }
  69. u32 avc_policy_seqno(void);
  70. #define AVC_CALLBACK_GRANT 1
  71. #define AVC_CALLBACK_TRY_REVOKE 2
  72. #define AVC_CALLBACK_REVOKE 4
  73. #define AVC_CALLBACK_RESET 8
  74. #define AVC_CALLBACK_AUDITALLOW_ENABLE 16
  75. #define AVC_CALLBACK_AUDITALLOW_DISABLE 32
  76. #define AVC_CALLBACK_AUDITDENY_ENABLE 64
  77. #define AVC_CALLBACK_AUDITDENY_DISABLE 128
  78. int avc_add_callback(int (*callback)(u32 event, u32 ssid, u32 tsid,
  79. u16 tclass, u32 perms,
  80. u32 *out_retained),
  81. u32 events, u32 ssid, u32 tsid,
  82. u16 tclass, u32 perms);
  83. /* Exported to selinuxfs */
  84. int avc_get_hash_stats(char *page);
  85. extern unsigned int avc_cache_threshold;
  86. /* Attempt to free avc node cache */
  87. void avc_disable(void);
  88. #ifdef CONFIG_SECURITY_SELINUX_AVC_STATS
  89. DECLARE_PER_CPU(struct avc_cache_stats, avc_cache_stats);
  90. #endif
  91. #endif /* _SELINUX_AVC_H_ */