selinux.h 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. /*
  2. * SELinux services exported to the rest of the kernel.
  3. *
  4. * Author: James Morris <jmorris@redhat.com>
  5. *
  6. * Copyright (C) 2005 Red Hat, Inc., James Morris <jmorris@redhat.com>
  7. * Copyright (C) 2006 Trusted Computer Solutions, Inc. <dgoeddel@trustedcs.com>
  8. * Copyright (C) 2006 IBM Corporation, Timothy R. Chavez <tinytim@us.ibm.com>
  9. *
  10. * This program is free software; you can redistribute it and/or modify
  11. * it under the terms of the GNU General Public License version 2,
  12. * as published by the Free Software Foundation.
  13. */
  14. #ifndef _LINUX_SELINUX_H
  15. #define _LINUX_SELINUX_H
  16. struct selinux_audit_rule;
  17. struct audit_context;
  18. struct kern_ipc_perm;
  19. #ifdef CONFIG_SECURITY_SELINUX
  20. /**
  21. * selinux_string_to_sid - map a security context string to a security ID
  22. * @str: the security context string to be mapped
  23. * @sid: ID value returned via this.
  24. *
  25. * Returns 0 if successful, with the SID stored in sid. A value
  26. * of zero for sid indicates no SID could be determined (but no error
  27. * occurred).
  28. */
  29. int selinux_string_to_sid(char *str, u32 *sid);
  30. /**
  31. * selinux_secmark_relabel_packet_permission - secmark permission check
  32. * @sid: SECMARK ID value to be applied to network packet
  33. *
  34. * Returns 0 if the current task is allowed to set the SECMARK label of
  35. * packets with the supplied security ID. Note that it is implicit that
  36. * the packet is always being relabeled from the default unlabeled value,
  37. * and that the access control decision is made in the AVC.
  38. */
  39. int selinux_secmark_relabel_packet_permission(u32 sid);
  40. /**
  41. * selinux_secmark_refcount_inc - increments the secmark use counter
  42. *
  43. * SELinux keeps track of the current SECMARK targets in use so it knows
  44. * when to apply SECMARK label access checks to network packets. This
  45. * function incements this reference count to indicate that a new SECMARK
  46. * target has been configured.
  47. */
  48. void selinux_secmark_refcount_inc(void);
  49. /**
  50. * selinux_secmark_refcount_dec - decrements the secmark use counter
  51. *
  52. * SELinux keeps track of the current SECMARK targets in use so it knows
  53. * when to apply SECMARK label access checks to network packets. This
  54. * function decements this reference count to indicate that one of the
  55. * existing SECMARK targets has been removed/flushed.
  56. */
  57. void selinux_secmark_refcount_dec(void);
  58. #else
  59. static inline int selinux_string_to_sid(const char *str, u32 *sid)
  60. {
  61. *sid = 0;
  62. return 0;
  63. }
  64. static inline int selinux_secmark_relabel_packet_permission(u32 sid)
  65. {
  66. return 0;
  67. }
  68. static inline void selinux_secmark_refcount_inc(void)
  69. {
  70. return;
  71. }
  72. static inline void selinux_secmark_refcount_dec(void)
  73. {
  74. return;
  75. }
  76. #endif /* CONFIG_SECURITY_SELINUX */
  77. #endif /* _LINUX_SELINUX_H */