netlabel.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. /*
  2. * SELinux interface to the NetLabel subsystem
  3. *
  4. * Author: Paul Moore <paul@paul-moore.com>
  5. *
  6. */
  7. /*
  8. * (c) Copyright Hewlett-Packard Development Company, L.P., 2006
  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 as published by
  12. * the Free Software Foundation; either version 2 of the License, or
  13. * (at your option) any later version.
  14. *
  15. * This program is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
  18. * the GNU General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU General Public License
  21. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  22. *
  23. */
  24. #ifndef _SELINUX_NETLABEL_H_
  25. #define _SELINUX_NETLABEL_H_
  26. #include <linux/types.h>
  27. #include <linux/fs.h>
  28. #include <linux/net.h>
  29. #include <linux/skbuff.h>
  30. #include <net/sock.h>
  31. #include <net/request_sock.h>
  32. #include <net/sctp/structs.h>
  33. #include "avc.h"
  34. #include "objsec.h"
  35. #ifdef CONFIG_NETLABEL
  36. void selinux_netlbl_cache_invalidate(void);
  37. void selinux_netlbl_err(struct sk_buff *skb, u16 family, int error,
  38. int gateway);
  39. void selinux_netlbl_sk_security_free(struct sk_security_struct *sksec);
  40. void selinux_netlbl_sk_security_reset(struct sk_security_struct *sksec);
  41. int selinux_netlbl_skbuff_getsid(struct sk_buff *skb,
  42. u16 family,
  43. u32 *type,
  44. u32 *sid);
  45. int selinux_netlbl_skbuff_setsid(struct sk_buff *skb,
  46. u16 family,
  47. u32 sid);
  48. int selinux_netlbl_sctp_assoc_request(struct sctp_endpoint *ep,
  49. struct sk_buff *skb);
  50. int selinux_netlbl_inet_conn_request(struct request_sock *req, u16 family);
  51. void selinux_netlbl_inet_csk_clone(struct sock *sk, u16 family);
  52. void selinux_netlbl_sctp_sk_clone(struct sock *sk, struct sock *newsk);
  53. int selinux_netlbl_socket_post_create(struct sock *sk, u16 family);
  54. int selinux_netlbl_sock_rcv_skb(struct sk_security_struct *sksec,
  55. struct sk_buff *skb,
  56. u16 family,
  57. struct common_audit_data *ad);
  58. int selinux_netlbl_socket_setsockopt(struct socket *sock,
  59. int level,
  60. int optname);
  61. int selinux_netlbl_socket_connect(struct sock *sk, struct sockaddr *addr);
  62. int selinux_netlbl_socket_connect_locked(struct sock *sk,
  63. struct sockaddr *addr);
  64. #else
  65. static inline void selinux_netlbl_cache_invalidate(void)
  66. {
  67. return;
  68. }
  69. static inline void selinux_netlbl_err(struct sk_buff *skb,
  70. u16 family,
  71. int error,
  72. int gateway)
  73. {
  74. return;
  75. }
  76. static inline void selinux_netlbl_sk_security_free(
  77. struct sk_security_struct *sksec)
  78. {
  79. return;
  80. }
  81. static inline void selinux_netlbl_sk_security_reset(
  82. struct sk_security_struct *sksec)
  83. {
  84. return;
  85. }
  86. static inline int selinux_netlbl_skbuff_getsid(struct sk_buff *skb,
  87. u16 family,
  88. u32 *type,
  89. u32 *sid)
  90. {
  91. *type = NETLBL_NLTYPE_NONE;
  92. *sid = SECSID_NULL;
  93. return 0;
  94. }
  95. static inline int selinux_netlbl_skbuff_setsid(struct sk_buff *skb,
  96. u16 family,
  97. u32 sid)
  98. {
  99. return 0;
  100. }
  101. static inline int selinux_netlbl_conn_setsid(struct sock *sk,
  102. struct sockaddr *addr)
  103. {
  104. return 0;
  105. }
  106. static inline int selinux_netlbl_sctp_assoc_request(struct sctp_endpoint *ep,
  107. struct sk_buff *skb)
  108. {
  109. return 0;
  110. }
  111. static inline int selinux_netlbl_inet_conn_request(struct request_sock *req,
  112. u16 family)
  113. {
  114. return 0;
  115. }
  116. static inline void selinux_netlbl_inet_csk_clone(struct sock *sk, u16 family)
  117. {
  118. return;
  119. }
  120. static inline void selinux_netlbl_sctp_sk_clone(struct sock *sk,
  121. struct sock *newsk)
  122. {
  123. return;
  124. }
  125. static inline int selinux_netlbl_socket_post_create(struct sock *sk,
  126. u16 family)
  127. {
  128. return 0;
  129. }
  130. static inline int selinux_netlbl_sock_rcv_skb(struct sk_security_struct *sksec,
  131. struct sk_buff *skb,
  132. u16 family,
  133. struct common_audit_data *ad)
  134. {
  135. return 0;
  136. }
  137. static inline int selinux_netlbl_socket_setsockopt(struct socket *sock,
  138. int level,
  139. int optname)
  140. {
  141. return 0;
  142. }
  143. static inline int selinux_netlbl_socket_connect(struct sock *sk,
  144. struct sockaddr *addr)
  145. {
  146. return 0;
  147. }
  148. static inline int selinux_netlbl_socket_connect_locked(struct sock *sk,
  149. struct sockaddr *addr)
  150. {
  151. return 0;
  152. }
  153. #endif /* CONFIG_NETLABEL */
  154. #endif