avc.h 2.2 KB

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