32 #include <linux/types.h>
33 #include <linux/slab.h>
34 #include <linux/audit.h>
36 #include <linux/in6.h>
77 }
else if (addr !=
NULL && mask !=
NULL) {
118 if (domain !=
NULL) {
121 goto cfg_unlbl_map_add_failure;
126 else if (addr !=
NULL && mask !=
NULL) {
127 addrmap = kzalloc(
sizeof(*addrmap),
GFP_ATOMIC);
129 goto cfg_unlbl_map_add_failure;
130 INIT_LIST_HEAD(&addrmap->
list4);
131 INIT_LIST_HEAD(&addrmap->
list6);
139 goto cfg_unlbl_map_add_failure;
143 map4->
list.valid = 1;
147 goto cfg_unlbl_map_add_failure;
150 #if IS_ENABLED(CONFIG_IPV6)
156 goto cfg_unlbl_map_add_failure;
158 map6->
list.addr = *addr6;
159 map6->
list.addr.s6_addr32[0] &= mask6->s6_addr32[0];
160 map6->
list.addr.s6_addr32[1] &= mask6->s6_addr32[1];
161 map6->
list.addr.s6_addr32[2] &= mask6->s6_addr32[2];
162 map6->
list.addr.s6_addr32[3] &= mask6->s6_addr32[3];
163 map6->
list.mask = *mask6;
164 map6->
list.valid = 1;
165 ret_val = netlbl_af6list_add(&map6->
list,
168 goto cfg_unlbl_map_add_failure;
173 goto cfg_unlbl_map_add_failure;
181 goto cfg_unlbl_map_add_failure;
186 goto cfg_unlbl_map_add_failure;
190 cfg_unlbl_map_add_failure:
217 const char *dev_name,
228 addr_len =
sizeof(
struct in_addr);
230 #if IS_ENABLED(CONFIG_IPV6)
240 dev_name, addr, mask, addr_len,
261 const char *dev_name,
271 addr_len =
sizeof(
struct in_addr);
273 #if IS_ENABLED(CONFIG_IPV6)
283 dev_name, addr, mask, addr_len,
351 if (domain !=
NULL) {
360 }
else if (addr !=
NULL && mask !=
NULL) {
361 addrmap = kzalloc(
sizeof(*addrmap),
GFP_ATOMIC);
364 INIT_LIST_HEAD(&addrmap->
list4);
365 INIT_LIST_HEAD(&addrmap->
list6);
367 addrinfo = kzalloc(
sizeof(*addrinfo),
GFP_ATOMIC);
368 if (addrinfo ==
NULL)
374 addrinfo->
list.valid = 1;
377 goto cfg_cipsov4_map_add_failure;
388 goto cfg_cipsov4_map_add_failure;
392 cfg_cipsov4_map_add_failure:
434 node_bit = offset - iter->
startbit -
440 bitmap = iter->
bitmap[node_idx] >> node_bit;
458 bitmap = iter->
bitmap[node_idx];
492 node_bit = offset - iter->
startbit -
501 bitmap = iter->
bitmap[node_idx];
502 while (bitmask != 0 && (bitmap & bitmask) != 0) {
547 iter->
next = netlbl_secattr_catmap_alloc(flags);
595 for (spot = start; spot <= end && ret_val == 0; spot++) {
596 if (spot >= iter_max_spot && iter->
next !=
NULL) {
654 if (dom_entry ==
NULL) {
656 goto socket_setattr_return;
660 switch (dom_entry->
type) {
676 #if IS_ENABLED(CONFIG_IPV6)
687 socket_setattr_return:
723 switch (sk->sk_family) {
727 #if IS_ENABLED(CONFIG_IPV6)
765 if (af4_entry ==
NULL) {
767 goto conn_setattr_return;
769 switch (af4_entry->
type) {
785 #if IS_ENABLED(CONFIG_IPV6)
822 if (dom_entry ==
NULL) {
824 goto req_setattr_return;
826 switch (req->
rsk_ops->family) {
832 if (af4_entry ==
NULL) {
834 goto req_setattr_return;
836 proto_type = af4_entry->
type;
839 proto_type = dom_entry->
type;
842 switch (proto_type) {
856 #if IS_ENABLED(CONFIG_IPV6)
910 if (af4_entry ==
NULL) {
912 goto skbuff_setattr_return;
914 switch (af4_entry->
type) {
929 #if IS_ENABLED(CONFIG_IPV6)
940 skbuff_setattr_return:
968 #if IS_ENABLED(CONFIG_IPV6)
1065 static int __init netlbl_init(
void)
1097 panic(
"NetLabel: failed to initialize properly (%d)\n", ret_val);