avc.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  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. void 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);
  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(u32 ssid, u32 tsid,
  60. u16 tclass, u32 requested,
  61. struct common_audit_data *auditdata);
  62. u32 avc_policy_seqno(void);
  63. #define AVC_CALLBACK_GRANT 1
  64. #define AVC_CALLBACK_TRY_REVOKE 2
  65. #define AVC_CALLBACK_REVOKE 4
  66. #define AVC_CALLBACK_RESET 8
  67. #define AVC_CALLBACK_AUDITALLOW_ENABLE 16
  68. #define AVC_CALLBACK_AUDITALLOW_DISABLE 32
  69. #define AVC_CALLBACK_AUDITDENY_ENABLE 64
  70. #define AVC_CALLBACK_AUDITDENY_DISABLE 128
  71. int avc_add_callback(int (*callback)(u32 event, u32 ssid, u32 tsid,
  72. u16 tclass, u32 perms,
  73. u32 *out_retained),
  74. u32 events, u32 ssid, u32 tsid,
  75. u16 tclass, u32 perms);
  76. /* Exported to selinuxfs */
  77. int avc_get_hash_stats(char *page);
  78. extern unsigned int avc_cache_threshold;
  79. /* Attempt to free avc node cache */
  80. void avc_disable(void);
  81. #ifdef CONFIG_SECURITY_SELINUX_AVC_STATS
  82. DECLARE_PER_CPU(struct avc_cache_stats, avc_cache_stats);
  83. #endif
  84. #endif /* _SELINUX_AVC_H_ */