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