netlabel_unlabeled.h 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247
  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, write to the Free Software
  26. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  27. *
  28. */
  29. #ifndef _NETLABEL_UNLABELED_H
  30. #define _NETLABEL_UNLABELED_H
  31. #include <net/netlabel.h>
  32. /*
  33. * The following NetLabel payloads are supported by the Unlabeled subsystem.
  34. *
  35. * o STATICADD
  36. * This message is sent from an application to add a new static label for
  37. * incoming unlabeled connections.
  38. *
  39. * Required attributes:
  40. *
  41. * NLBL_UNLABEL_A_IFACE
  42. * NLBL_UNLABEL_A_SECCTX
  43. *
  44. * If IPv4 is specified the following attributes are required:
  45. *
  46. * NLBL_UNLABEL_A_IPV4ADDR
  47. * NLBL_UNLABEL_A_IPV4MASK
  48. *
  49. * If IPv6 is specified the following attributes are required:
  50. *
  51. * NLBL_UNLABEL_A_IPV6ADDR
  52. * NLBL_UNLABEL_A_IPV6MASK
  53. *
  54. * o STATICREMOVE
  55. * This message is sent from an application to remove an existing static
  56. * label for incoming unlabeled connections.
  57. *
  58. * Required attributes:
  59. *
  60. * NLBL_UNLABEL_A_IFACE
  61. *
  62. * If IPv4 is specified the following attributes are required:
  63. *
  64. * NLBL_UNLABEL_A_IPV4ADDR
  65. * NLBL_UNLABEL_A_IPV4MASK
  66. *
  67. * If IPv6 is specified the following attributes are required:
  68. *
  69. * NLBL_UNLABEL_A_IPV6ADDR
  70. * NLBL_UNLABEL_A_IPV6MASK
  71. *
  72. * o STATICLIST
  73. * This message can be sent either from an application or by the kernel in
  74. * response to an application generated STATICLIST message. When sent by an
  75. * application there is no payload and the NLM_F_DUMP flag should be set.
  76. * The kernel should response with a series of the following messages.
  77. *
  78. * Required attributes:
  79. *
  80. * NLBL_UNLABEL_A_IFACE
  81. * NLBL_UNLABEL_A_SECCTX
  82. *
  83. * If IPv4 is specified the following attributes are required:
  84. *
  85. * NLBL_UNLABEL_A_IPV4ADDR
  86. * NLBL_UNLABEL_A_IPV4MASK
  87. *
  88. * If IPv6 is specified the following attributes are required:
  89. *
  90. * NLBL_UNLABEL_A_IPV6ADDR
  91. * NLBL_UNLABEL_A_IPV6MASK
  92. *
  93. * o STATICADDDEF
  94. * This message is sent from an application to set the default static
  95. * label for incoming unlabeled connections.
  96. *
  97. * Required attribute:
  98. *
  99. * NLBL_UNLABEL_A_SECCTX
  100. *
  101. * If IPv4 is specified the following attributes are required:
  102. *
  103. * NLBL_UNLABEL_A_IPV4ADDR
  104. * NLBL_UNLABEL_A_IPV4MASK
  105. *
  106. * If IPv6 is specified the following attributes are required:
  107. *
  108. * NLBL_UNLABEL_A_IPV6ADDR
  109. * NLBL_UNLABEL_A_IPV6MASK
  110. *
  111. * o STATICREMOVEDEF
  112. * This message is sent from an application to remove the existing default
  113. * static label for incoming unlabeled connections.
  114. *
  115. * If IPv4 is specified the following attributes are required:
  116. *
  117. * NLBL_UNLABEL_A_IPV4ADDR
  118. * NLBL_UNLABEL_A_IPV4MASK
  119. *
  120. * If IPv6 is specified the following attributes are required:
  121. *
  122. * NLBL_UNLABEL_A_IPV6ADDR
  123. * NLBL_UNLABEL_A_IPV6MASK
  124. *
  125. * o STATICLISTDEF
  126. * This message can be sent either from an application or by the kernel in
  127. * response to an application generated STATICLISTDEF message. When sent by
  128. * an application there is no payload and the NLM_F_DUMP flag should be set.
  129. * The kernel should response with the following message.
  130. *
  131. * Required attribute:
  132. *
  133. * NLBL_UNLABEL_A_SECCTX
  134. *
  135. * If IPv4 is specified the following attributes are required:
  136. *
  137. * NLBL_UNLABEL_A_IPV4ADDR
  138. * NLBL_UNLABEL_A_IPV4MASK
  139. *
  140. * If IPv6 is specified the following attributes are required:
  141. *
  142. * NLBL_UNLABEL_A_IPV6ADDR
  143. * NLBL_UNLABEL_A_IPV6MASK
  144. *
  145. * o ACCEPT
  146. * This message is sent from an application to specify if the kernel should
  147. * allow unlabled packets to pass if they do not match any of the static
  148. * mappings defined in the unlabeled module.
  149. *
  150. * Required attributes:
  151. *
  152. * NLBL_UNLABEL_A_ACPTFLG
  153. *
  154. * o LIST
  155. * This message can be sent either from an application or by the kernel in
  156. * response to an application generated LIST message. When sent by an
  157. * application there is no payload. The kernel should respond to a LIST
  158. * message with a LIST message on success.
  159. *
  160. * Required attributes:
  161. *
  162. * NLBL_UNLABEL_A_ACPTFLG
  163. *
  164. */
  165. /* NetLabel Unlabeled commands */
  166. enum {
  167. NLBL_UNLABEL_C_UNSPEC,
  168. NLBL_UNLABEL_C_ACCEPT,
  169. NLBL_UNLABEL_C_LIST,
  170. NLBL_UNLABEL_C_STATICADD,
  171. NLBL_UNLABEL_C_STATICREMOVE,
  172. NLBL_UNLABEL_C_STATICLIST,
  173. NLBL_UNLABEL_C_STATICADDDEF,
  174. NLBL_UNLABEL_C_STATICREMOVEDEF,
  175. NLBL_UNLABEL_C_STATICLISTDEF,
  176. __NLBL_UNLABEL_C_MAX,
  177. };
  178. /* NetLabel Unlabeled attributes */
  179. enum {
  180. NLBL_UNLABEL_A_UNSPEC,
  181. NLBL_UNLABEL_A_ACPTFLG,
  182. /* (NLA_U8)
  183. * if true then unlabeled packets are allowed to pass, else unlabeled
  184. * packets are rejected */
  185. NLBL_UNLABEL_A_IPV6ADDR,
  186. /* (NLA_BINARY, struct in6_addr)
  187. * an IPv6 address */
  188. NLBL_UNLABEL_A_IPV6MASK,
  189. /* (NLA_BINARY, struct in6_addr)
  190. * an IPv6 address mask */
  191. NLBL_UNLABEL_A_IPV4ADDR,
  192. /* (NLA_BINARY, struct in_addr)
  193. * an IPv4 address */
  194. NLBL_UNLABEL_A_IPV4MASK,
  195. /* (NLA_BINARY, struct in_addr)
  196. * and IPv4 address mask */
  197. NLBL_UNLABEL_A_IFACE,
  198. /* (NLA_NULL_STRING)
  199. * network interface */
  200. NLBL_UNLABEL_A_SECCTX,
  201. /* (NLA_BINARY)
  202. * a LSM specific security context */
  203. __NLBL_UNLABEL_A_MAX,
  204. };
  205. #define NLBL_UNLABEL_A_MAX (__NLBL_UNLABEL_A_MAX - 1)
  206. /* NetLabel protocol functions */
  207. int netlbl_unlabel_genl_init(void);
  208. /* Unlabeled connection hash table size */
  209. /* XXX - currently this number is an uneducated guess */
  210. #define NETLBL_UNLHSH_BITSIZE 7
  211. /* General Unlabeled init function */
  212. int netlbl_unlabel_init(u32 size);
  213. /* Static/Fallback label management functions */
  214. int netlbl_unlhsh_add(struct net *net,
  215. const char *dev_name,
  216. const void *addr,
  217. const void *mask,
  218. u32 addr_len,
  219. u32 secid,
  220. struct netlbl_audit *audit_info);
  221. int netlbl_unlhsh_remove(struct net *net,
  222. const char *dev_name,
  223. const void *addr,
  224. const void *mask,
  225. u32 addr_len,
  226. struct netlbl_audit *audit_info);
  227. /* Process Unlabeled incoming network packets */
  228. int netlbl_unlabel_getattr(const struct sk_buff *skb,
  229. u16 family,
  230. struct netlbl_lsm_secattr *secattr);
  231. /* Set the default configuration to allow Unlabeled packets */
  232. int netlbl_unlabel_defconf(void);
  233. #endif