netlabel_unlabeled.h 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245
  1. /*
  2. * NetLabel Unlabeled Support
  3. *
  4. * This file defines functions for dealing with unlabeled packets for the
  5. * NetLabel system. The NetLabel system manages static and dynamic label
  6. * mappings for network protocols such as CIPSO and RIPSO.
  7. *
  8. * Author: Paul Moore <paul@paul-moore.com>
  9. *
  10. */
  11. /*
  12. * (c) Copyright Hewlett-Packard Development Company, L.P., 2006
  13. *
  14. * This program is free software; you can redistribute it and/or modify
  15. * it under the terms of the GNU General Public License as published by
  16. * the Free Software Foundation; either version 2 of the License, or
  17. * (at your option) any later version.
  18. *
  19. * This program is distributed in the hope that it will be useful,
  20. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  21. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
  22. * the GNU General Public License for more details.
  23. *
  24. * You should have received a copy of the GNU General Public License
  25. * along with this program; if not, see <http://www.gnu.org/licenses/>.
  26. *
  27. */
  28. #ifndef _NETLABEL_UNLABELED_H
  29. #define _NETLABEL_UNLABELED_H
  30. #include <net/netlabel.h>
  31. /*
  32. * The following NetLabel payloads are supported by the Unlabeled subsystem.
  33. *
  34. * o STATICADD
  35. * This message is sent from an application to add a new static label for
  36. * incoming unlabeled connections.
  37. *
  38. * Required attributes:
  39. *
  40. * NLBL_UNLABEL_A_IFACE
  41. * NLBL_UNLABEL_A_SECCTX
  42. *
  43. * If IPv4 is specified the following attributes are required:
  44. *
  45. * NLBL_UNLABEL_A_IPV4ADDR
  46. * NLBL_UNLABEL_A_IPV4MASK
  47. *
  48. * If IPv6 is specified the following attributes are required:
  49. *
  50. * NLBL_UNLABEL_A_IPV6ADDR
  51. * NLBL_UNLABEL_A_IPV6MASK
  52. *
  53. * o STATICREMOVE
  54. * This message is sent from an application to remove an existing static
  55. * label for incoming unlabeled connections.
  56. *
  57. * Required attributes:
  58. *
  59. * NLBL_UNLABEL_A_IFACE
  60. *
  61. * If IPv4 is specified the following attributes are required:
  62. *
  63. * NLBL_UNLABEL_A_IPV4ADDR
  64. * NLBL_UNLABEL_A_IPV4MASK
  65. *
  66. * If IPv6 is specified the following attributes are required:
  67. *
  68. * NLBL_UNLABEL_A_IPV6ADDR
  69. * NLBL_UNLABEL_A_IPV6MASK
  70. *
  71. * o STATICLIST
  72. * This message can be sent either from an application or by the kernel in
  73. * response to an application generated STATICLIST message. When sent by an
  74. * application there is no payload and the NLM_F_DUMP flag should be set.
  75. * The kernel should response with a series of the following messages.
  76. *
  77. * Required attributes:
  78. *
  79. * NLBL_UNLABEL_A_IFACE
  80. * NLBL_UNLABEL_A_SECCTX
  81. *
  82. * If IPv4 is specified the following attributes are required:
  83. *
  84. * NLBL_UNLABEL_A_IPV4ADDR
  85. * NLBL_UNLABEL_A_IPV4MASK
  86. *
  87. * If IPv6 is specified the following attributes are required:
  88. *
  89. * NLBL_UNLABEL_A_IPV6ADDR
  90. * NLBL_UNLABEL_A_IPV6MASK
  91. *
  92. * o STATICADDDEF
  93. * This message is sent from an application to set the default static
  94. * label for incoming unlabeled connections.
  95. *
  96. * Required attribute:
  97. *
  98. * NLBL_UNLABEL_A_SECCTX
  99. *
  100. * If IPv4 is specified the following attributes are required:
  101. *
  102. * NLBL_UNLABEL_A_IPV4ADDR
  103. * NLBL_UNLABEL_A_IPV4MASK
  104. *
  105. * If IPv6 is specified the following attributes are required:
  106. *
  107. * NLBL_UNLABEL_A_IPV6ADDR
  108. * NLBL_UNLABEL_A_IPV6MASK
  109. *
  110. * o STATICREMOVEDEF
  111. * This message is sent from an application to remove the existing default
  112. * static label for incoming unlabeled connections.
  113. *
  114. * If IPv4 is specified the following attributes are required:
  115. *
  116. * NLBL_UNLABEL_A_IPV4ADDR
  117. * NLBL_UNLABEL_A_IPV4MASK
  118. *
  119. * If IPv6 is specified the following attributes are required:
  120. *
  121. * NLBL_UNLABEL_A_IPV6ADDR
  122. * NLBL_UNLABEL_A_IPV6MASK
  123. *
  124. * o STATICLISTDEF
  125. * This message can be sent either from an application or by the kernel in
  126. * response to an application generated STATICLISTDEF message. When sent by
  127. * an application there is no payload and the NLM_F_DUMP flag should be set.
  128. * The kernel should response with the following message.
  129. *
  130. * Required attribute:
  131. *
  132. * NLBL_UNLABEL_A_SECCTX
  133. *
  134. * If IPv4 is specified the following attributes are required:
  135. *
  136. * NLBL_UNLABEL_A_IPV4ADDR
  137. * NLBL_UNLABEL_A_IPV4MASK
  138. *
  139. * If IPv6 is specified the following attributes are required:
  140. *
  141. * NLBL_UNLABEL_A_IPV6ADDR
  142. * NLBL_UNLABEL_A_IPV6MASK
  143. *
  144. * o ACCEPT
  145. * This message is sent from an application to specify if the kernel should
  146. * allow unlabled packets to pass if they do not match any of the static
  147. * mappings defined in the unlabeled module.
  148. *
  149. * Required attributes:
  150. *
  151. * NLBL_UNLABEL_A_ACPTFLG
  152. *
  153. * o LIST
  154. * This message can be sent either from an application or by the kernel in
  155. * response to an application generated LIST message. When sent by an
  156. * application there is no payload. The kernel should respond to a LIST
  157. * message with a LIST message on success.
  158. *
  159. * Required attributes:
  160. *
  161. * NLBL_UNLABEL_A_ACPTFLG
  162. *
  163. */
  164. /* NetLabel Unlabeled commands */
  165. enum {
  166. NLBL_UNLABEL_C_UNSPEC,
  167. NLBL_UNLABEL_C_ACCEPT,
  168. NLBL_UNLABEL_C_LIST,
  169. NLBL_UNLABEL_C_STATICADD,
  170. NLBL_UNLABEL_C_STATICREMOVE,
  171. NLBL_UNLABEL_C_STATICLIST,
  172. NLBL_UNLABEL_C_STATICADDDEF,
  173. NLBL_UNLABEL_C_STATICREMOVEDEF,
  174. NLBL_UNLABEL_C_STATICLISTDEF,
  175. __NLBL_UNLABEL_C_MAX,
  176. };
  177. /* NetLabel Unlabeled attributes */
  178. enum {
  179. NLBL_UNLABEL_A_UNSPEC,
  180. NLBL_UNLABEL_A_ACPTFLG,
  181. /* (NLA_U8)
  182. * if true then unlabeled packets are allowed to pass, else unlabeled
  183. * packets are rejected */
  184. NLBL_UNLABEL_A_IPV6ADDR,
  185. /* (NLA_BINARY, struct in6_addr)
  186. * an IPv6 address */
  187. NLBL_UNLABEL_A_IPV6MASK,
  188. /* (NLA_BINARY, struct in6_addr)
  189. * an IPv6 address mask */
  190. NLBL_UNLABEL_A_IPV4ADDR,
  191. /* (NLA_BINARY, struct in_addr)
  192. * an IPv4 address */
  193. NLBL_UNLABEL_A_IPV4MASK,
  194. /* (NLA_BINARY, struct in_addr)
  195. * and IPv4 address mask */
  196. NLBL_UNLABEL_A_IFACE,
  197. /* (NLA_NULL_STRING)
  198. * network interface */
  199. NLBL_UNLABEL_A_SECCTX,
  200. /* (NLA_BINARY)
  201. * a LSM specific security context */
  202. __NLBL_UNLABEL_A_MAX,
  203. };
  204. #define NLBL_UNLABEL_A_MAX (__NLBL_UNLABEL_A_MAX - 1)
  205. /* NetLabel protocol functions */
  206. int netlbl_unlabel_genl_init(void);
  207. /* Unlabeled connection hash table size */
  208. /* XXX - currently this number is an uneducated guess */
  209. #define NETLBL_UNLHSH_BITSIZE 7
  210. /* General Unlabeled init function */
  211. int netlbl_unlabel_init(u32 size);
  212. /* Static/Fallback label management functions */
  213. int netlbl_unlhsh_add(struct net *net,
  214. const char *dev_name,
  215. const void *addr,
  216. const void *mask,
  217. u32 addr_len,
  218. u32 secid,
  219. struct netlbl_audit *audit_info);
  220. int netlbl_unlhsh_remove(struct net *net,
  221. const char *dev_name,
  222. const void *addr,
  223. const void *mask,
  224. u32 addr_len,
  225. struct netlbl_audit *audit_info);
  226. /* Process Unlabeled incoming network packets */
  227. int netlbl_unlabel_getattr(const struct sk_buff *skb,
  228. u16 family,
  229. struct netlbl_lsm_secattr *secattr);
  230. /* Set the default configuration to allow Unlabeled packets */
  231. int netlbl_unlabel_defconf(void);
  232. #endif