diff options
author | David S. Miller <davem@davemloft.net> | 2012-04-01 19:54:46 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2012-04-02 04:33:41 -0400 |
commit | 7cf7899d9ee31c88c86ea8459fc4db4bd11cc240 (patch) | |
tree | 335504607f6347baa1d7b660376c18523e509a1e /net | |
parent | 6c1dd3b6a35178366eefcd0565aa2c8dd9020987 (diff) |
ipset: Stop using NLA_PUT*().
These macros contain a hidden goto, and are thus extremely error
prone and make code hard to audit.
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net')
-rw-r--r-- | net/netfilter/ipset/ip_set_bitmap_ip.c | 33 | ||||
-rw-r--r-- | net/netfilter/ipset/ip_set_bitmap_ipmac.c | 43 | ||||
-rw-r--r-- | net/netfilter/ipset/ip_set_bitmap_port.c | 29 | ||||
-rw-r--r-- | net/netfilter/ipset/ip_set_core.c | 43 | ||||
-rw-r--r-- | net/netfilter/ipset/ip_set_hash_ip.c | 20 | ||||
-rw-r--r-- | net/netfilter/ipset/ip_set_hash_ipport.c | 37 | ||||
-rw-r--r-- | net/netfilter/ipset/ip_set_hash_ipportip.c | 45 | ||||
-rw-r--r-- | net/netfilter/ipset/ip_set_hash_ipportnet.c | 69 | ||||
-rw-r--r-- | net/netfilter/ipset/ip_set_hash_net.c | 45 | ||||
-rw-r--r-- | net/netfilter/ipset/ip_set_hash_netiface.c | 52 | ||||
-rw-r--r-- | net/netfilter/ipset/ip_set_hash_netport.c | 61 | ||||
-rw-r--r-- | net/netfilter/ipset/ip_set_list_set.c | 23 |
12 files changed, 271 insertions, 229 deletions
diff --git a/net/netfilter/ipset/ip_set_bitmap_ip.c b/net/netfilter/ipset/ip_set_bitmap_ip.c index a72a4dff0031..7e1b061aeeba 100644 --- a/net/netfilter/ipset/ip_set_bitmap_ip.c +++ b/net/netfilter/ipset/ip_set_bitmap_ip.c | |||
@@ -109,8 +109,9 @@ bitmap_ip_list(const struct ip_set *set, | |||
109 | } else | 109 | } else |
110 | goto nla_put_failure; | 110 | goto nla_put_failure; |
111 | } | 111 | } |
112 | NLA_PUT_IPADDR4(skb, IPSET_ATTR_IP, | 112 | if (nla_put_ipaddr4(skb, IPSET_ATTR_IP, |
113 | htonl(map->first_ip + id * map->hosts)); | 113 | htonl(map->first_ip + id * map->hosts))) |
114 | goto nla_put_failure; | ||
114 | ipset_nest_end(skb, nested); | 115 | ipset_nest_end(skb, nested); |
115 | } | 116 | } |
116 | ipset_nest_end(skb, atd); | 117 | ipset_nest_end(skb, atd); |
@@ -194,10 +195,11 @@ bitmap_ip_tlist(const struct ip_set *set, | |||
194 | } else | 195 | } else |
195 | goto nla_put_failure; | 196 | goto nla_put_failure; |
196 | } | 197 | } |
197 | NLA_PUT_IPADDR4(skb, IPSET_ATTR_IP, | 198 | if (nla_put_ipaddr4(skb, IPSET_ATTR_IP, |
198 | htonl(map->first_ip + id * map->hosts)); | 199 | htonl(map->first_ip + id * map->hosts)) || |
199 | NLA_PUT_NET32(skb, IPSET_ATTR_TIMEOUT, | 200 | nla_put_net32(skb, IPSET_ATTR_TIMEOUT, |
200 | htonl(ip_set_timeout_get(members[id]))); | 201 | htonl(ip_set_timeout_get(members[id])))) |
202 | goto nla_put_failure; | ||
201 | ipset_nest_end(skb, nested); | 203 | ipset_nest_end(skb, nested); |
202 | } | 204 | } |
203 | ipset_nest_end(skb, adt); | 205 | ipset_nest_end(skb, adt); |
@@ -334,15 +336,16 @@ bitmap_ip_head(struct ip_set *set, struct sk_buff *skb) | |||
334 | nested = ipset_nest_start(skb, IPSET_ATTR_DATA); | 336 | nested = ipset_nest_start(skb, IPSET_ATTR_DATA); |
335 | if (!nested) | 337 | if (!nested) |
336 | goto nla_put_failure; | 338 | goto nla_put_failure; |
337 | NLA_PUT_IPADDR4(skb, IPSET_ATTR_IP, htonl(map->first_ip)); | 339 | if (nla_put_ipaddr4(skb, IPSET_ATTR_IP, htonl(map->first_ip)) || |
338 | NLA_PUT_IPADDR4(skb, IPSET_ATTR_IP_TO, htonl(map->last_ip)); | 340 | nla_put_ipaddr4(skb, IPSET_ATTR_IP_TO, htonl(map->last_ip)) || |
339 | if (map->netmask != 32) | 341 | (map->netmask != 32 && |
340 | NLA_PUT_U8(skb, IPSET_ATTR_NETMASK, map->netmask); | 342 | nla_put_u8(skb, IPSET_ATTR_NETMASK, map->netmask)) || |
341 | NLA_PUT_NET32(skb, IPSET_ATTR_REFERENCES, htonl(set->ref - 1)); | 343 | nla_put_net32(skb, IPSET_ATTR_REFERENCES, htonl(set->ref - 1)) || |
342 | NLA_PUT_NET32(skb, IPSET_ATTR_MEMSIZE, | 344 | nla_put_net32(skb, IPSET_ATTR_MEMSIZE, |
343 | htonl(sizeof(*map) + map->memsize)); | 345 | htonl(sizeof(*map) + map->memsize)) || |
344 | if (with_timeout(map->timeout)) | 346 | (with_timeout(map->timeout) && |
345 | NLA_PUT_NET32(skb, IPSET_ATTR_TIMEOUT, htonl(map->timeout)); | 347 | nla_put_net32(skb, IPSET_ATTR_TIMEOUT, htonl(map->timeout)))) |
348 | goto nla_put_failure; | ||
346 | ipset_nest_end(skb, nested); | 349 | ipset_nest_end(skb, nested); |
347 | 350 | ||
348 | return 0; | 351 | return 0; |
diff --git a/net/netfilter/ipset/ip_set_bitmap_ipmac.c b/net/netfilter/ipset/ip_set_bitmap_ipmac.c index 81324c12c5be..0bb16c469a89 100644 --- a/net/netfilter/ipset/ip_set_bitmap_ipmac.c +++ b/net/netfilter/ipset/ip_set_bitmap_ipmac.c | |||
@@ -186,11 +186,12 @@ bitmap_ipmac_list(const struct ip_set *set, | |||
186 | } else | 186 | } else |
187 | goto nla_put_failure; | 187 | goto nla_put_failure; |
188 | } | 188 | } |
189 | NLA_PUT_IPADDR4(skb, IPSET_ATTR_IP, | 189 | if (nla_put_ipaddr4(skb, IPSET_ATTR_IP, |
190 | htonl(map->first_ip + id)); | 190 | htonl(map->first_ip + id)) || |
191 | if (elem->match == MAC_FILLED) | 191 | (elem->match == MAC_FILLED && |
192 | NLA_PUT(skb, IPSET_ATTR_ETHER, ETH_ALEN, | 192 | nla_put(skb, IPSET_ATTR_ETHER, ETH_ALEN, |
193 | elem->ether); | 193 | elem->ether))) |
194 | goto nla_put_failure; | ||
194 | ipset_nest_end(skb, nested); | 195 | ipset_nest_end(skb, nested); |
195 | } | 196 | } |
196 | ipset_nest_end(skb, atd); | 197 | ipset_nest_end(skb, atd); |
@@ -314,14 +315,16 @@ bitmap_ipmac_tlist(const struct ip_set *set, | |||
314 | } else | 315 | } else |
315 | goto nla_put_failure; | 316 | goto nla_put_failure; |
316 | } | 317 | } |
317 | NLA_PUT_IPADDR4(skb, IPSET_ATTR_IP, | 318 | if (nla_put_ipaddr4(skb, IPSET_ATTR_IP, |
318 | htonl(map->first_ip + id)); | 319 | htonl(map->first_ip + id)) || |
319 | if (elem->match == MAC_FILLED) | 320 | (elem->match == MAC_FILLED && |
320 | NLA_PUT(skb, IPSET_ATTR_ETHER, ETH_ALEN, | 321 | nla_put(skb, IPSET_ATTR_ETHER, ETH_ALEN, |
321 | elem->ether); | 322 | elem->ether))) |
323 | goto nla_put_failure; | ||
322 | timeout = elem->match == MAC_UNSET ? elem->timeout | 324 | timeout = elem->match == MAC_UNSET ? elem->timeout |
323 | : ip_set_timeout_get(elem->timeout); | 325 | : ip_set_timeout_get(elem->timeout); |
324 | NLA_PUT_NET32(skb, IPSET_ATTR_TIMEOUT, htonl(timeout)); | 326 | if (nla_put_net32(skb, IPSET_ATTR_TIMEOUT, htonl(timeout))) |
327 | goto nla_put_failure; | ||
325 | ipset_nest_end(skb, nested); | 328 | ipset_nest_end(skb, nested); |
326 | } | 329 | } |
327 | ipset_nest_end(skb, atd); | 330 | ipset_nest_end(skb, atd); |
@@ -438,14 +441,16 @@ bitmap_ipmac_head(struct ip_set *set, struct sk_buff *skb) | |||
438 | nested = ipset_nest_start(skb, IPSET_ATTR_DATA); | 441 | nested = ipset_nest_start(skb, IPSET_ATTR_DATA); |
439 | if (!nested) | 442 | if (!nested) |
440 | goto nla_put_failure; | 443 | goto nla_put_failure; |
441 | NLA_PUT_IPADDR4(skb, IPSET_ATTR_IP, htonl(map->first_ip)); | 444 | if (nla_put_ipaddr4(skb, IPSET_ATTR_IP, htonl(map->first_ip)) || |
442 | NLA_PUT_IPADDR4(skb, IPSET_ATTR_IP_TO, htonl(map->last_ip)); | 445 | nla_put_ipaddr4(skb, IPSET_ATTR_IP_TO, htonl(map->last_ip)) || |
443 | NLA_PUT_NET32(skb, IPSET_ATTR_REFERENCES, htonl(set->ref - 1)); | 446 | nla_put_net32(skb, IPSET_ATTR_REFERENCES, htonl(set->ref - 1)) || |
444 | NLA_PUT_NET32(skb, IPSET_ATTR_MEMSIZE, | 447 | nla_put_net32(skb, IPSET_ATTR_MEMSIZE, |
445 | htonl(sizeof(*map) | 448 | htonl(sizeof(*map) + |
446 | + (map->last_ip - map->first_ip + 1) * map->dsize)); | 449 | ((map->last_ip - map->first_ip + 1) * |
447 | if (with_timeout(map->timeout)) | 450 | map->dsize))) || |
448 | NLA_PUT_NET32(skb, IPSET_ATTR_TIMEOUT, htonl(map->timeout)); | 451 | (with_timeout(map->timeout) && |
452 | nla_put_net32(skb, IPSET_ATTR_TIMEOUT, htonl(map->timeout)))) | ||
453 | goto nla_put_failure; | ||
449 | ipset_nest_end(skb, nested); | 454 | ipset_nest_end(skb, nested); |
450 | 455 | ||
451 | return 0; | 456 | return 0; |
diff --git a/net/netfilter/ipset/ip_set_bitmap_port.c b/net/netfilter/ipset/ip_set_bitmap_port.c index 382ec28ba72e..b9f1fce7053b 100644 --- a/net/netfilter/ipset/ip_set_bitmap_port.c +++ b/net/netfilter/ipset/ip_set_bitmap_port.c | |||
@@ -96,8 +96,9 @@ bitmap_port_list(const struct ip_set *set, | |||
96 | } else | 96 | } else |
97 | goto nla_put_failure; | 97 | goto nla_put_failure; |
98 | } | 98 | } |
99 | NLA_PUT_NET16(skb, IPSET_ATTR_PORT, | 99 | if (nla_put_net16(skb, IPSET_ATTR_PORT, |
100 | htons(map->first_port + id)); | 100 | htons(map->first_port + id))) |
101 | goto nla_put_failure; | ||
101 | ipset_nest_end(skb, nested); | 102 | ipset_nest_end(skb, nested); |
102 | } | 103 | } |
103 | ipset_nest_end(skb, atd); | 104 | ipset_nest_end(skb, atd); |
@@ -183,10 +184,11 @@ bitmap_port_tlist(const struct ip_set *set, | |||
183 | } else | 184 | } else |
184 | goto nla_put_failure; | 185 | goto nla_put_failure; |
185 | } | 186 | } |
186 | NLA_PUT_NET16(skb, IPSET_ATTR_PORT, | 187 | if (nla_put_net16(skb, IPSET_ATTR_PORT, |
187 | htons(map->first_port + id)); | 188 | htons(map->first_port + id)) || |
188 | NLA_PUT_NET32(skb, IPSET_ATTR_TIMEOUT, | 189 | nla_put_net32(skb, IPSET_ATTR_TIMEOUT, |
189 | htonl(ip_set_timeout_get(members[id]))); | 190 | htonl(ip_set_timeout_get(members[id])))) |
191 | goto nla_put_failure; | ||
190 | ipset_nest_end(skb, nested); | 192 | ipset_nest_end(skb, nested); |
191 | } | 193 | } |
192 | ipset_nest_end(skb, adt); | 194 | ipset_nest_end(skb, adt); |
@@ -320,13 +322,14 @@ bitmap_port_head(struct ip_set *set, struct sk_buff *skb) | |||
320 | nested = ipset_nest_start(skb, IPSET_ATTR_DATA); | 322 | nested = ipset_nest_start(skb, IPSET_ATTR_DATA); |
321 | if (!nested) | 323 | if (!nested) |
322 | goto nla_put_failure; | 324 | goto nla_put_failure; |
323 | NLA_PUT_NET16(skb, IPSET_ATTR_PORT, htons(map->first_port)); | 325 | if (nla_put_net16(skb, IPSET_ATTR_PORT, htons(map->first_port)) || |
324 | NLA_PUT_NET16(skb, IPSET_ATTR_PORT_TO, htons(map->last_port)); | 326 | nla_put_net16(skb, IPSET_ATTR_PORT_TO, htons(map->last_port)) || |
325 | NLA_PUT_NET32(skb, IPSET_ATTR_REFERENCES, htonl(set->ref - 1)); | 327 | nla_put_net32(skb, IPSET_ATTR_REFERENCES, htonl(set->ref - 1)) || |
326 | NLA_PUT_NET32(skb, IPSET_ATTR_MEMSIZE, | 328 | nla_put_net32(skb, IPSET_ATTR_MEMSIZE, |
327 | htonl(sizeof(*map) + map->memsize)); | 329 | htonl(sizeof(*map) + map->memsize)) || |
328 | if (with_timeout(map->timeout)) | 330 | (with_timeout(map->timeout) && |
329 | NLA_PUT_NET32(skb, IPSET_ATTR_TIMEOUT, htonl(map->timeout)); | 331 | nla_put_net32(skb, IPSET_ATTR_TIMEOUT, htonl(map->timeout)))) |
332 | goto nla_put_failure; | ||
330 | ipset_nest_end(skb, nested); | 333 | ipset_nest_end(skb, nested); |
331 | 334 | ||
332 | return 0; | 335 | return 0; |
diff --git a/net/netfilter/ipset/ip_set_core.c b/net/netfilter/ipset/ip_set_core.c index e6c1c9605a58..eb66b9790a6f 100644 --- a/net/netfilter/ipset/ip_set_core.c +++ b/net/netfilter/ipset/ip_set_core.c | |||
@@ -1092,19 +1092,21 @@ dump_last: | |||
1092 | ret = -EMSGSIZE; | 1092 | ret = -EMSGSIZE; |
1093 | goto release_refcount; | 1093 | goto release_refcount; |
1094 | } | 1094 | } |
1095 | NLA_PUT_U8(skb, IPSET_ATTR_PROTOCOL, IPSET_PROTOCOL); | 1095 | if (nla_put_u8(skb, IPSET_ATTR_PROTOCOL, IPSET_PROTOCOL) || |
1096 | NLA_PUT_STRING(skb, IPSET_ATTR_SETNAME, set->name); | 1096 | nla_put_string(skb, IPSET_ATTR_SETNAME, set->name)) |
1097 | goto nla_put_failure; | ||
1097 | if (dump_flags & IPSET_FLAG_LIST_SETNAME) | 1098 | if (dump_flags & IPSET_FLAG_LIST_SETNAME) |
1098 | goto next_set; | 1099 | goto next_set; |
1099 | switch (cb->args[2]) { | 1100 | switch (cb->args[2]) { |
1100 | case 0: | 1101 | case 0: |
1101 | /* Core header data */ | 1102 | /* Core header data */ |
1102 | NLA_PUT_STRING(skb, IPSET_ATTR_TYPENAME, | 1103 | if (nla_put_string(skb, IPSET_ATTR_TYPENAME, |
1103 | set->type->name); | 1104 | set->type->name) || |
1104 | NLA_PUT_U8(skb, IPSET_ATTR_FAMILY, | 1105 | nla_put_u8(skb, IPSET_ATTR_FAMILY, |
1105 | set->family); | 1106 | set->family) || |
1106 | NLA_PUT_U8(skb, IPSET_ATTR_REVISION, | 1107 | nla_put_u8(skb, IPSET_ATTR_REVISION, |
1107 | set->revision); | 1108 | set->revision)) |
1109 | goto nla_put_failure; | ||
1108 | ret = set->variant->head(set, skb); | 1110 | ret = set->variant->head(set, skb); |
1109 | if (ret < 0) | 1111 | if (ret < 0) |
1110 | goto release_refcount; | 1112 | goto release_refcount; |
@@ -1410,11 +1412,12 @@ ip_set_header(struct sock *ctnl, struct sk_buff *skb, | |||
1410 | IPSET_CMD_HEADER); | 1412 | IPSET_CMD_HEADER); |
1411 | if (!nlh2) | 1413 | if (!nlh2) |
1412 | goto nlmsg_failure; | 1414 | goto nlmsg_failure; |
1413 | NLA_PUT_U8(skb2, IPSET_ATTR_PROTOCOL, IPSET_PROTOCOL); | 1415 | if (nla_put_u8(skb2, IPSET_ATTR_PROTOCOL, IPSET_PROTOCOL) || |
1414 | NLA_PUT_STRING(skb2, IPSET_ATTR_SETNAME, set->name); | 1416 | nla_put_string(skb2, IPSET_ATTR_SETNAME, set->name) || |
1415 | NLA_PUT_STRING(skb2, IPSET_ATTR_TYPENAME, set->type->name); | 1417 | nla_put_string(skb2, IPSET_ATTR_TYPENAME, set->type->name) || |
1416 | NLA_PUT_U8(skb2, IPSET_ATTR_FAMILY, set->family); | 1418 | nla_put_u8(skb2, IPSET_ATTR_FAMILY, set->family) || |
1417 | NLA_PUT_U8(skb2, IPSET_ATTR_REVISION, set->revision); | 1419 | nla_put_u8(skb2, IPSET_ATTR_REVISION, set->revision)) |
1420 | goto nla_put_failure; | ||
1418 | nlmsg_end(skb2, nlh2); | 1421 | nlmsg_end(skb2, nlh2); |
1419 | 1422 | ||
1420 | ret = netlink_unicast(ctnl, skb2, NETLINK_CB(skb).pid, MSG_DONTWAIT); | 1423 | ret = netlink_unicast(ctnl, skb2, NETLINK_CB(skb).pid, MSG_DONTWAIT); |
@@ -1469,11 +1472,12 @@ ip_set_type(struct sock *ctnl, struct sk_buff *skb, | |||
1469 | IPSET_CMD_TYPE); | 1472 | IPSET_CMD_TYPE); |
1470 | if (!nlh2) | 1473 | if (!nlh2) |
1471 | goto nlmsg_failure; | 1474 | goto nlmsg_failure; |
1472 | NLA_PUT_U8(skb2, IPSET_ATTR_PROTOCOL, IPSET_PROTOCOL); | 1475 | if (nla_put_u8(skb2, IPSET_ATTR_PROTOCOL, IPSET_PROTOCOL) || |
1473 | NLA_PUT_STRING(skb2, IPSET_ATTR_TYPENAME, typename); | 1476 | nla_put_string(skb2, IPSET_ATTR_TYPENAME, typename) || |
1474 | NLA_PUT_U8(skb2, IPSET_ATTR_FAMILY, family); | 1477 | nla_put_u8(skb2, IPSET_ATTR_FAMILY, family) || |
1475 | NLA_PUT_U8(skb2, IPSET_ATTR_REVISION, max); | 1478 | nla_put_u8(skb2, IPSET_ATTR_REVISION, max) || |
1476 | NLA_PUT_U8(skb2, IPSET_ATTR_REVISION_MIN, min); | 1479 | nla_put_u8(skb2, IPSET_ATTR_REVISION_MIN, min)) |
1480 | goto nla_put_failure; | ||
1477 | nlmsg_end(skb2, nlh2); | 1481 | nlmsg_end(skb2, nlh2); |
1478 | 1482 | ||
1479 | pr_debug("Send TYPE, nlmsg_len: %u\n", nlh2->nlmsg_len); | 1483 | pr_debug("Send TYPE, nlmsg_len: %u\n", nlh2->nlmsg_len); |
@@ -1517,7 +1521,8 @@ ip_set_protocol(struct sock *ctnl, struct sk_buff *skb, | |||
1517 | IPSET_CMD_PROTOCOL); | 1521 | IPSET_CMD_PROTOCOL); |
1518 | if (!nlh2) | 1522 | if (!nlh2) |
1519 | goto nlmsg_failure; | 1523 | goto nlmsg_failure; |
1520 | NLA_PUT_U8(skb2, IPSET_ATTR_PROTOCOL, IPSET_PROTOCOL); | 1524 | if (nla_put_u8(skb2, IPSET_ATTR_PROTOCOL, IPSET_PROTOCOL)) |
1525 | goto nla_put_failure; | ||
1521 | nlmsg_end(skb2, nlh2); | 1526 | nlmsg_end(skb2, nlh2); |
1522 | 1527 | ||
1523 | ret = netlink_unicast(ctnl, skb2, NETLINK_CB(skb).pid, MSG_DONTWAIT); | 1528 | ret = netlink_unicast(ctnl, skb2, NETLINK_CB(skb).pid, MSG_DONTWAIT); |
diff --git a/net/netfilter/ipset/ip_set_hash_ip.c b/net/netfilter/ipset/ip_set_hash_ip.c index 5139dea6019e..507fe93794aa 100644 --- a/net/netfilter/ipset/ip_set_hash_ip.c +++ b/net/netfilter/ipset/ip_set_hash_ip.c | |||
@@ -81,7 +81,8 @@ hash_ip4_data_zero_out(struct hash_ip4_elem *elem) | |||
81 | static inline bool | 81 | static inline bool |
82 | hash_ip4_data_list(struct sk_buff *skb, const struct hash_ip4_elem *data) | 82 | hash_ip4_data_list(struct sk_buff *skb, const struct hash_ip4_elem *data) |
83 | { | 83 | { |
84 | NLA_PUT_IPADDR4(skb, IPSET_ATTR_IP, data->ip); | 84 | if (nla_put_ipaddr4(skb, IPSET_ATTR_IP, data->ip)) |
85 | goto nla_put_failure; | ||
85 | return 0; | 86 | return 0; |
86 | 87 | ||
87 | nla_put_failure: | 88 | nla_put_failure: |
@@ -94,9 +95,10 @@ hash_ip4_data_tlist(struct sk_buff *skb, const struct hash_ip4_elem *data) | |||
94 | const struct hash_ip4_telem *tdata = | 95 | const struct hash_ip4_telem *tdata = |
95 | (const struct hash_ip4_telem *)data; | 96 | (const struct hash_ip4_telem *)data; |
96 | 97 | ||
97 | NLA_PUT_IPADDR4(skb, IPSET_ATTR_IP, tdata->ip); | 98 | if (nla_put_ipaddr4(skb, IPSET_ATTR_IP, tdata->ip) || |
98 | NLA_PUT_NET32(skb, IPSET_ATTR_TIMEOUT, | 99 | nla_put_net32(skb, IPSET_ATTR_TIMEOUT, |
99 | htonl(ip_set_timeout_get(tdata->timeout))); | 100 | htonl(ip_set_timeout_get(tdata->timeout)))) |
101 | goto nla_put_failure; | ||
100 | 102 | ||
101 | return 0; | 103 | return 0; |
102 | 104 | ||
@@ -262,7 +264,8 @@ ip6_netmask(union nf_inet_addr *ip, u8 prefix) | |||
262 | static bool | 264 | static bool |
263 | hash_ip6_data_list(struct sk_buff *skb, const struct hash_ip6_elem *data) | 265 | hash_ip6_data_list(struct sk_buff *skb, const struct hash_ip6_elem *data) |
264 | { | 266 | { |
265 | NLA_PUT_IPADDR6(skb, IPSET_ATTR_IP, &data->ip); | 267 | if (nla_put_ipaddr6(skb, IPSET_ATTR_IP, &data->ip.in6)) |
268 | goto nla_put_failure; | ||
266 | return 0; | 269 | return 0; |
267 | 270 | ||
268 | nla_put_failure: | 271 | nla_put_failure: |
@@ -275,9 +278,10 @@ hash_ip6_data_tlist(struct sk_buff *skb, const struct hash_ip6_elem *data) | |||
275 | const struct hash_ip6_telem *e = | 278 | const struct hash_ip6_telem *e = |
276 | (const struct hash_ip6_telem *)data; | 279 | (const struct hash_ip6_telem *)data; |
277 | 280 | ||
278 | NLA_PUT_IPADDR6(skb, IPSET_ATTR_IP, &e->ip); | 281 | if (nla_put_ipaddr6(skb, IPSET_ATTR_IP, &e->ip.in6) || |
279 | NLA_PUT_NET32(skb, IPSET_ATTR_TIMEOUT, | 282 | nla_put_net32(skb, IPSET_ATTR_TIMEOUT, |
280 | htonl(ip_set_timeout_get(e->timeout))); | 283 | htonl(ip_set_timeout_get(e->timeout)))) |
284 | goto nla_put_failure; | ||
281 | return 0; | 285 | return 0; |
282 | 286 | ||
283 | nla_put_failure: | 287 | nla_put_failure: |
diff --git a/net/netfilter/ipset/ip_set_hash_ipport.c b/net/netfilter/ipset/ip_set_hash_ipport.c index 9c27e249c171..68f284c97490 100644 --- a/net/netfilter/ipset/ip_set_hash_ipport.c +++ b/net/netfilter/ipset/ip_set_hash_ipport.c | |||
@@ -93,9 +93,10 @@ static bool | |||
93 | hash_ipport4_data_list(struct sk_buff *skb, | 93 | hash_ipport4_data_list(struct sk_buff *skb, |
94 | const struct hash_ipport4_elem *data) | 94 | const struct hash_ipport4_elem *data) |
95 | { | 95 | { |
96 | NLA_PUT_IPADDR4(skb, IPSET_ATTR_IP, data->ip); | 96 | if (nla_put_ipaddr4(skb, IPSET_ATTR_IP, data->ip) || |
97 | NLA_PUT_NET16(skb, IPSET_ATTR_PORT, data->port); | 97 | nla_put_net16(skb, IPSET_ATTR_PORT, data->port) || |
98 | NLA_PUT_U8(skb, IPSET_ATTR_PROTO, data->proto); | 98 | nla_put_u8(skb, IPSET_ATTR_PROTO, data->proto)) |
99 | goto nla_put_failure; | ||
99 | return 0; | 100 | return 0; |
100 | 101 | ||
101 | nla_put_failure: | 102 | nla_put_failure: |
@@ -109,12 +110,12 @@ hash_ipport4_data_tlist(struct sk_buff *skb, | |||
109 | const struct hash_ipport4_telem *tdata = | 110 | const struct hash_ipport4_telem *tdata = |
110 | (const struct hash_ipport4_telem *)data; | 111 | (const struct hash_ipport4_telem *)data; |
111 | 112 | ||
112 | NLA_PUT_IPADDR4(skb, IPSET_ATTR_IP, tdata->ip); | 113 | if (nla_put_ipaddr4(skb, IPSET_ATTR_IP, tdata->ip) || |
113 | NLA_PUT_NET16(skb, IPSET_ATTR_PORT, tdata->port); | 114 | nla_put_net16(skb, IPSET_ATTR_PORT, tdata->port) || |
114 | NLA_PUT_U8(skb, IPSET_ATTR_PROTO, data->proto); | 115 | nla_put_u8(skb, IPSET_ATTR_PROTO, data->proto) || |
115 | NLA_PUT_NET32(skb, IPSET_ATTR_TIMEOUT, | 116 | nla_put_net32(skb, IPSET_ATTR_TIMEOUT, |
116 | htonl(ip_set_timeout_get(tdata->timeout))); | 117 | htonl(ip_set_timeout_get(tdata->timeout)))) |
117 | 118 | goto nla_put_failure; | |
118 | return 0; | 119 | return 0; |
119 | 120 | ||
120 | nla_put_failure: | 121 | nla_put_failure: |
@@ -308,9 +309,10 @@ static bool | |||
308 | hash_ipport6_data_list(struct sk_buff *skb, | 309 | hash_ipport6_data_list(struct sk_buff *skb, |
309 | const struct hash_ipport6_elem *data) | 310 | const struct hash_ipport6_elem *data) |
310 | { | 311 | { |
311 | NLA_PUT_IPADDR6(skb, IPSET_ATTR_IP, &data->ip); | 312 | if (nla_put_ipaddr6(skb, IPSET_ATTR_IP, &data->ip.in6) || |
312 | NLA_PUT_NET16(skb, IPSET_ATTR_PORT, data->port); | 313 | nla_put_net16(skb, IPSET_ATTR_PORT, data->port) || |
313 | NLA_PUT_U8(skb, IPSET_ATTR_PROTO, data->proto); | 314 | nla_put_u8(skb, IPSET_ATTR_PROTO, data->proto)) |
315 | goto nla_put_failure; | ||
314 | return 0; | 316 | return 0; |
315 | 317 | ||
316 | nla_put_failure: | 318 | nla_put_failure: |
@@ -324,11 +326,12 @@ hash_ipport6_data_tlist(struct sk_buff *skb, | |||
324 | const struct hash_ipport6_telem *e = | 326 | const struct hash_ipport6_telem *e = |
325 | (const struct hash_ipport6_telem *)data; | 327 | (const struct hash_ipport6_telem *)data; |
326 | 328 | ||
327 | NLA_PUT_IPADDR6(skb, IPSET_ATTR_IP, &e->ip); | 329 | if (nla_put_ipaddr6(skb, IPSET_ATTR_IP, &e->ip.in6) || |
328 | NLA_PUT_NET16(skb, IPSET_ATTR_PORT, data->port); | 330 | nla_put_net16(skb, IPSET_ATTR_PORT, data->port) || |
329 | NLA_PUT_U8(skb, IPSET_ATTR_PROTO, data->proto); | 331 | nla_put_u8(skb, IPSET_ATTR_PROTO, data->proto) || |
330 | NLA_PUT_NET32(skb, IPSET_ATTR_TIMEOUT, | 332 | nla_put_net32(skb, IPSET_ATTR_TIMEOUT, |
331 | htonl(ip_set_timeout_get(e->timeout))); | 333 | htonl(ip_set_timeout_get(e->timeout)))) |
334 | goto nla_put_failure; | ||
332 | return 0; | 335 | return 0; |
333 | 336 | ||
334 | nla_put_failure: | 337 | nla_put_failure: |
diff --git a/net/netfilter/ipset/ip_set_hash_ipportip.c b/net/netfilter/ipset/ip_set_hash_ipportip.c index 9134057c0728..1eec4b9e0dca 100644 --- a/net/netfilter/ipset/ip_set_hash_ipportip.c +++ b/net/netfilter/ipset/ip_set_hash_ipportip.c | |||
@@ -94,10 +94,11 @@ static bool | |||
94 | hash_ipportip4_data_list(struct sk_buff *skb, | 94 | hash_ipportip4_data_list(struct sk_buff *skb, |
95 | const struct hash_ipportip4_elem *data) | 95 | const struct hash_ipportip4_elem *data) |
96 | { | 96 | { |
97 | NLA_PUT_IPADDR4(skb, IPSET_ATTR_IP, data->ip); | 97 | if (nla_put_ipaddr4(skb, IPSET_ATTR_IP, data->ip) || |
98 | NLA_PUT_IPADDR4(skb, IPSET_ATTR_IP2, data->ip2); | 98 | nla_put_ipaddr4(skb, IPSET_ATTR_IP2, data->ip2) || |
99 | NLA_PUT_NET16(skb, IPSET_ATTR_PORT, data->port); | 99 | nla_put_net16(skb, IPSET_ATTR_PORT, data->port) || |
100 | NLA_PUT_U8(skb, IPSET_ATTR_PROTO, data->proto); | 100 | nla_put_u8(skb, IPSET_ATTR_PROTO, data->proto)) |
101 | goto nla_put_failure; | ||
101 | return 0; | 102 | return 0; |
102 | 103 | ||
103 | nla_put_failure: | 104 | nla_put_failure: |
@@ -111,13 +112,13 @@ hash_ipportip4_data_tlist(struct sk_buff *skb, | |||
111 | const struct hash_ipportip4_telem *tdata = | 112 | const struct hash_ipportip4_telem *tdata = |
112 | (const struct hash_ipportip4_telem *)data; | 113 | (const struct hash_ipportip4_telem *)data; |
113 | 114 | ||
114 | NLA_PUT_IPADDR4(skb, IPSET_ATTR_IP, tdata->ip); | 115 | if (nla_put_ipaddr4(skb, IPSET_ATTR_IP, tdata->ip) || |
115 | NLA_PUT_IPADDR4(skb, IPSET_ATTR_IP2, tdata->ip2); | 116 | nla_put_ipaddr4(skb, IPSET_ATTR_IP2, tdata->ip2) || |
116 | NLA_PUT_NET16(skb, IPSET_ATTR_PORT, tdata->port); | 117 | nla_put_net16(skb, IPSET_ATTR_PORT, tdata->port) || |
117 | NLA_PUT_U8(skb, IPSET_ATTR_PROTO, data->proto); | 118 | nla_put_u8(skb, IPSET_ATTR_PROTO, data->proto) || |
118 | NLA_PUT_NET32(skb, IPSET_ATTR_TIMEOUT, | 119 | nla_put_net32(skb, IPSET_ATTR_TIMEOUT, |
119 | htonl(ip_set_timeout_get(tdata->timeout))); | 120 | htonl(ip_set_timeout_get(tdata->timeout)))) |
120 | 121 | goto nla_put_failure; | |
121 | return 0; | 122 | return 0; |
122 | 123 | ||
123 | nla_put_failure: | 124 | nla_put_failure: |
@@ -319,10 +320,11 @@ static bool | |||
319 | hash_ipportip6_data_list(struct sk_buff *skb, | 320 | hash_ipportip6_data_list(struct sk_buff *skb, |
320 | const struct hash_ipportip6_elem *data) | 321 | const struct hash_ipportip6_elem *data) |
321 | { | 322 | { |
322 | NLA_PUT_IPADDR6(skb, IPSET_ATTR_IP, &data->ip); | 323 | if (nla_put_ipaddr6(skb, IPSET_ATTR_IP, &data->ip.in6) || |
323 | NLA_PUT_IPADDR6(skb, IPSET_ATTR_IP2, &data->ip2); | 324 | nla_put_ipaddr6(skb, IPSET_ATTR_IP2, &data->ip2.in6) || |
324 | NLA_PUT_NET16(skb, IPSET_ATTR_PORT, data->port); | 325 | nla_put_net16(skb, IPSET_ATTR_PORT, data->port) || |
325 | NLA_PUT_U8(skb, IPSET_ATTR_PROTO, data->proto); | 326 | nla_put_u8(skb, IPSET_ATTR_PROTO, data->proto)) |
327 | goto nla_put_failure; | ||
326 | return 0; | 328 | return 0; |
327 | 329 | ||
328 | nla_put_failure: | 330 | nla_put_failure: |
@@ -336,12 +338,13 @@ hash_ipportip6_data_tlist(struct sk_buff *skb, | |||
336 | const struct hash_ipportip6_telem *e = | 338 | const struct hash_ipportip6_telem *e = |
337 | (const struct hash_ipportip6_telem *)data; | 339 | (const struct hash_ipportip6_telem *)data; |
338 | 340 | ||
339 | NLA_PUT_IPADDR6(skb, IPSET_ATTR_IP, &e->ip); | 341 | if (nla_put_ipaddr6(skb, IPSET_ATTR_IP, &e->ip.in6) || |
340 | NLA_PUT_IPADDR6(skb, IPSET_ATTR_IP2, &data->ip2); | 342 | nla_put_ipaddr6(skb, IPSET_ATTR_IP2, &data->ip2.in6) || |
341 | NLA_PUT_NET16(skb, IPSET_ATTR_PORT, data->port); | 343 | nla_put_net16(skb, IPSET_ATTR_PORT, data->port) || |
342 | NLA_PUT_U8(skb, IPSET_ATTR_PROTO, data->proto); | 344 | nla_put_u8(skb, IPSET_ATTR_PROTO, data->proto) || |
343 | NLA_PUT_NET32(skb, IPSET_ATTR_TIMEOUT, | 345 | nla_put_net32(skb, IPSET_ATTR_TIMEOUT, |
344 | htonl(ip_set_timeout_get(e->timeout))); | 346 | htonl(ip_set_timeout_get(e->timeout)))) |
347 | goto nla_put_failure; | ||
345 | return 0; | 348 | return 0; |
346 | 349 | ||
347 | nla_put_failure: | 350 | nla_put_failure: |
diff --git a/net/netfilter/ipset/ip_set_hash_ipportnet.c b/net/netfilter/ipset/ip_set_hash_ipportnet.c index 5d05e6969862..62d66ecef369 100644 --- a/net/netfilter/ipset/ip_set_hash_ipportnet.c +++ b/net/netfilter/ipset/ip_set_hash_ipportnet.c | |||
@@ -124,13 +124,14 @@ hash_ipportnet4_data_list(struct sk_buff *skb, | |||
124 | { | 124 | { |
125 | u32 flags = data->nomatch ? IPSET_FLAG_NOMATCH : 0; | 125 | u32 flags = data->nomatch ? IPSET_FLAG_NOMATCH : 0; |
126 | 126 | ||
127 | NLA_PUT_IPADDR4(skb, IPSET_ATTR_IP, data->ip); | 127 | if (nla_put_ipaddr4(skb, IPSET_ATTR_IP, data->ip) || |
128 | NLA_PUT_IPADDR4(skb, IPSET_ATTR_IP2, data->ip2); | 128 | nla_put_ipaddr4(skb, IPSET_ATTR_IP2, data->ip2) || |
129 | NLA_PUT_NET16(skb, IPSET_ATTR_PORT, data->port); | 129 | nla_put_net16(skb, IPSET_ATTR_PORT, data->port) || |
130 | NLA_PUT_U8(skb, IPSET_ATTR_CIDR2, data->cidr + 1); | 130 | nla_put_u8(skb, IPSET_ATTR_CIDR2, data->cidr + 1) || |
131 | NLA_PUT_U8(skb, IPSET_ATTR_PROTO, data->proto); | 131 | nla_put_u8(skb, IPSET_ATTR_PROTO, data->proto) || |
132 | if (flags) | 132 | (flags && |
133 | NLA_PUT_NET32(skb, IPSET_ATTR_CADT_FLAGS, htonl(flags)); | 133 | nla_put_net32(skb, IPSET_ATTR_CADT_FLAGS, htonl(flags)))) |
134 | goto nla_put_failure; | ||
134 | return 0; | 135 | return 0; |
135 | 136 | ||
136 | nla_put_failure: | 137 | nla_put_failure: |
@@ -145,16 +146,16 @@ hash_ipportnet4_data_tlist(struct sk_buff *skb, | |||
145 | (const struct hash_ipportnet4_telem *)data; | 146 | (const struct hash_ipportnet4_telem *)data; |
146 | u32 flags = data->nomatch ? IPSET_FLAG_NOMATCH : 0; | 147 | u32 flags = data->nomatch ? IPSET_FLAG_NOMATCH : 0; |
147 | 148 | ||
148 | NLA_PUT_IPADDR4(skb, IPSET_ATTR_IP, tdata->ip); | 149 | if (nla_put_ipaddr4(skb, IPSET_ATTR_IP, tdata->ip) || |
149 | NLA_PUT_IPADDR4(skb, IPSET_ATTR_IP2, tdata->ip2); | 150 | nla_put_ipaddr4(skb, IPSET_ATTR_IP2, tdata->ip2) || |
150 | NLA_PUT_NET16(skb, IPSET_ATTR_PORT, tdata->port); | 151 | nla_put_net16(skb, IPSET_ATTR_PORT, tdata->port) || |
151 | NLA_PUT_U8(skb, IPSET_ATTR_CIDR2, data->cidr + 1); | 152 | nla_put_u8(skb, IPSET_ATTR_CIDR2, data->cidr + 1) || |
152 | NLA_PUT_U8(skb, IPSET_ATTR_PROTO, data->proto); | 153 | nla_put_u8(skb, IPSET_ATTR_PROTO, data->proto) || |
153 | NLA_PUT_NET32(skb, IPSET_ATTR_TIMEOUT, | 154 | nla_put_net32(skb, IPSET_ATTR_TIMEOUT, |
154 | htonl(ip_set_timeout_get(tdata->timeout))); | 155 | htonl(ip_set_timeout_get(tdata->timeout))) || |
155 | if (flags) | 156 | (flags && |
156 | NLA_PUT_NET32(skb, IPSET_ATTR_CADT_FLAGS, htonl(flags)); | 157 | nla_put_net32(skb, IPSET_ATTR_CADT_FLAGS, htonl(flags)))) |
157 | 158 | goto nla_put_failure; | |
158 | return 0; | 159 | return 0; |
159 | 160 | ||
160 | nla_put_failure: | 161 | nla_put_failure: |
@@ -436,13 +437,14 @@ hash_ipportnet6_data_list(struct sk_buff *skb, | |||
436 | { | 437 | { |
437 | u32 flags = data->nomatch ? IPSET_FLAG_NOMATCH : 0; | 438 | u32 flags = data->nomatch ? IPSET_FLAG_NOMATCH : 0; |
438 | 439 | ||
439 | NLA_PUT_IPADDR6(skb, IPSET_ATTR_IP, &data->ip); | 440 | if (nla_put_ipaddr6(skb, IPSET_ATTR_IP, &data->ip.in6) || |
440 | NLA_PUT_IPADDR6(skb, IPSET_ATTR_IP2, &data->ip2); | 441 | nla_put_ipaddr6(skb, IPSET_ATTR_IP2, &data->ip2.in6) || |
441 | NLA_PUT_NET16(skb, IPSET_ATTR_PORT, data->port); | 442 | nla_put_net16(skb, IPSET_ATTR_PORT, data->port) || |
442 | NLA_PUT_U8(skb, IPSET_ATTR_CIDR2, data->cidr + 1); | 443 | nla_put_u8(skb, IPSET_ATTR_CIDR2, data->cidr + 1) || |
443 | NLA_PUT_U8(skb, IPSET_ATTR_PROTO, data->proto); | 444 | nla_put_u8(skb, IPSET_ATTR_PROTO, data->proto) || |
444 | if (flags) | 445 | (flags && |
445 | NLA_PUT_NET32(skb, IPSET_ATTR_CADT_FLAGS, htonl(flags)); | 446 | nla_put_net32(skb, IPSET_ATTR_CADT_FLAGS, htonl(flags)))) |
447 | goto nla_put_failure; | ||
446 | return 0; | 448 | return 0; |
447 | 449 | ||
448 | nla_put_failure: | 450 | nla_put_failure: |
@@ -457,15 +459,16 @@ hash_ipportnet6_data_tlist(struct sk_buff *skb, | |||
457 | (const struct hash_ipportnet6_telem *)data; | 459 | (const struct hash_ipportnet6_telem *)data; |
458 | u32 flags = data->nomatch ? IPSET_FLAG_NOMATCH : 0; | 460 | u32 flags = data->nomatch ? IPSET_FLAG_NOMATCH : 0; |
459 | 461 | ||
460 | NLA_PUT_IPADDR6(skb, IPSET_ATTR_IP, &e->ip); | 462 | if (nla_put_ipaddr6(skb, IPSET_ATTR_IP, &e->ip.in6) || |
461 | NLA_PUT_IPADDR6(skb, IPSET_ATTR_IP2, &data->ip2); | 463 | nla_put_ipaddr6(skb, IPSET_ATTR_IP2, &data->ip2.in6) || |
462 | NLA_PUT_NET16(skb, IPSET_ATTR_PORT, data->port); | 464 | nla_put_net16(skb, IPSET_ATTR_PORT, data->port) || |
463 | NLA_PUT_U8(skb, IPSET_ATTR_CIDR2, data->cidr + 1); | 465 | nla_put_u8(skb, IPSET_ATTR_CIDR2, data->cidr + 1) || |
464 | NLA_PUT_U8(skb, IPSET_ATTR_PROTO, data->proto); | 466 | nla_put_u8(skb, IPSET_ATTR_PROTO, data->proto) || |
465 | NLA_PUT_NET32(skb, IPSET_ATTR_TIMEOUT, | 467 | nla_put_net32(skb, IPSET_ATTR_TIMEOUT, |
466 | htonl(ip_set_timeout_get(e->timeout))); | 468 | htonl(ip_set_timeout_get(e->timeout))) || |
467 | if (flags) | 469 | (flags && |
468 | NLA_PUT_NET32(skb, IPSET_ATTR_CADT_FLAGS, htonl(flags)); | 470 | nla_put_net32(skb, IPSET_ATTR_CADT_FLAGS, htonl(flags)))) |
471 | goto nla_put_failure; | ||
469 | return 0; | 472 | return 0; |
470 | 473 | ||
471 | nla_put_failure: | 474 | nla_put_failure: |
diff --git a/net/netfilter/ipset/ip_set_hash_net.c b/net/netfilter/ipset/ip_set_hash_net.c index 7c3d945517cf..6607a814be57 100644 --- a/net/netfilter/ipset/ip_set_hash_net.c +++ b/net/netfilter/ipset/ip_set_hash_net.c | |||
@@ -111,10 +111,11 @@ hash_net4_data_list(struct sk_buff *skb, const struct hash_net4_elem *data) | |||
111 | { | 111 | { |
112 | u32 flags = data->nomatch ? IPSET_FLAG_NOMATCH : 0; | 112 | u32 flags = data->nomatch ? IPSET_FLAG_NOMATCH : 0; |
113 | 113 | ||
114 | NLA_PUT_IPADDR4(skb, IPSET_ATTR_IP, data->ip); | 114 | if (nla_put_ipaddr4(skb, IPSET_ATTR_IP, data->ip) || |
115 | NLA_PUT_U8(skb, IPSET_ATTR_CIDR, data->cidr); | 115 | nla_put_u8(skb, IPSET_ATTR_CIDR, data->cidr) || |
116 | if (flags) | 116 | (flags && |
117 | NLA_PUT_NET32(skb, IPSET_ATTR_CADT_FLAGS, htonl(flags)); | 117 | nla_put_net32(skb, IPSET_ATTR_CADT_FLAGS, htonl(flags)))) |
118 | goto nla_put_failure; | ||
118 | return 0; | 119 | return 0; |
119 | 120 | ||
120 | nla_put_failure: | 121 | nla_put_failure: |
@@ -128,13 +129,13 @@ hash_net4_data_tlist(struct sk_buff *skb, const struct hash_net4_elem *data) | |||
128 | (const struct hash_net4_telem *)data; | 129 | (const struct hash_net4_telem *)data; |
129 | u32 flags = data->nomatch ? IPSET_FLAG_NOMATCH : 0; | 130 | u32 flags = data->nomatch ? IPSET_FLAG_NOMATCH : 0; |
130 | 131 | ||
131 | NLA_PUT_IPADDR4(skb, IPSET_ATTR_IP, tdata->ip); | 132 | if (nla_put_ipaddr4(skb, IPSET_ATTR_IP, tdata->ip) || |
132 | NLA_PUT_U8(skb, IPSET_ATTR_CIDR, tdata->cidr); | 133 | nla_put_u8(skb, IPSET_ATTR_CIDR, tdata->cidr) || |
133 | NLA_PUT_NET32(skb, IPSET_ATTR_TIMEOUT, | 134 | nla_put_net32(skb, IPSET_ATTR_TIMEOUT, |
134 | htonl(ip_set_timeout_get(tdata->timeout))); | 135 | htonl(ip_set_timeout_get(tdata->timeout))) || |
135 | if (flags) | 136 | (flags && |
136 | NLA_PUT_NET32(skb, IPSET_ATTR_CADT_FLAGS, htonl(flags)); | 137 | nla_put_net32(skb, IPSET_ATTR_CADT_FLAGS, htonl(flags)))) |
137 | 138 | goto nla_put_failure; | |
138 | return 0; | 139 | return 0; |
139 | 140 | ||
140 | nla_put_failure: | 141 | nla_put_failure: |
@@ -339,10 +340,11 @@ hash_net6_data_list(struct sk_buff *skb, const struct hash_net6_elem *data) | |||
339 | { | 340 | { |
340 | u32 flags = data->nomatch ? IPSET_FLAG_NOMATCH : 0; | 341 | u32 flags = data->nomatch ? IPSET_FLAG_NOMATCH : 0; |
341 | 342 | ||
342 | NLA_PUT_IPADDR6(skb, IPSET_ATTR_IP, &data->ip); | 343 | if (nla_put_ipaddr6(skb, IPSET_ATTR_IP, &data->ip.in6) || |
343 | NLA_PUT_U8(skb, IPSET_ATTR_CIDR, data->cidr); | 344 | nla_put_u8(skb, IPSET_ATTR_CIDR, data->cidr) || |
344 | if (flags) | 345 | (flags && |
345 | NLA_PUT_NET32(skb, IPSET_ATTR_CADT_FLAGS, htonl(flags)); | 346 | nla_put_net32(skb, IPSET_ATTR_CADT_FLAGS, htonl(flags)))) |
347 | goto nla_put_failure; | ||
346 | return 0; | 348 | return 0; |
347 | 349 | ||
348 | nla_put_failure: | 350 | nla_put_failure: |
@@ -356,12 +358,13 @@ hash_net6_data_tlist(struct sk_buff *skb, const struct hash_net6_elem *data) | |||
356 | (const struct hash_net6_telem *)data; | 358 | (const struct hash_net6_telem *)data; |
357 | u32 flags = data->nomatch ? IPSET_FLAG_NOMATCH : 0; | 359 | u32 flags = data->nomatch ? IPSET_FLAG_NOMATCH : 0; |
358 | 360 | ||
359 | NLA_PUT_IPADDR6(skb, IPSET_ATTR_IP, &e->ip); | 361 | if (nla_put_ipaddr6(skb, IPSET_ATTR_IP, &e->ip.in6) || |
360 | NLA_PUT_U8(skb, IPSET_ATTR_CIDR, e->cidr); | 362 | nla_put_u8(skb, IPSET_ATTR_CIDR, e->cidr) || |
361 | NLA_PUT_NET32(skb, IPSET_ATTR_TIMEOUT, | 363 | nla_put_net32(skb, IPSET_ATTR_TIMEOUT, |
362 | htonl(ip_set_timeout_get(e->timeout))); | 364 | htonl(ip_set_timeout_get(e->timeout))) || |
363 | if (flags) | 365 | (flags && |
364 | NLA_PUT_NET32(skb, IPSET_ATTR_CADT_FLAGS, htonl(flags)); | 366 | nla_put_net32(skb, IPSET_ATTR_CADT_FLAGS, htonl(flags)))) |
367 | goto nla_put_failure; | ||
365 | return 0; | 368 | return 0; |
366 | 369 | ||
367 | nla_put_failure: | 370 | nla_put_failure: |
diff --git a/net/netfilter/ipset/ip_set_hash_netiface.c b/net/netfilter/ipset/ip_set_hash_netiface.c index f24037ff4322..6093f3daa911 100644 --- a/net/netfilter/ipset/ip_set_hash_netiface.c +++ b/net/netfilter/ipset/ip_set_hash_netiface.c | |||
@@ -252,11 +252,12 @@ hash_netiface4_data_list(struct sk_buff *skb, | |||
252 | 252 | ||
253 | if (data->nomatch) | 253 | if (data->nomatch) |
254 | flags |= IPSET_FLAG_NOMATCH; | 254 | flags |= IPSET_FLAG_NOMATCH; |
255 | NLA_PUT_IPADDR4(skb, IPSET_ATTR_IP, data->ip); | 255 | if (nla_put_ipaddr4(skb, IPSET_ATTR_IP, data->ip) || |
256 | NLA_PUT_U8(skb, IPSET_ATTR_CIDR, data->cidr); | 256 | nla_put_u8(skb, IPSET_ATTR_CIDR, data->cidr) || |
257 | NLA_PUT_STRING(skb, IPSET_ATTR_IFACE, data->iface); | 257 | nla_put_string(skb, IPSET_ATTR_IFACE, data->iface) || |
258 | if (flags) | 258 | (flags && |
259 | NLA_PUT_NET32(skb, IPSET_ATTR_CADT_FLAGS, htonl(flags)); | 259 | nla_put_net32(skb, IPSET_ATTR_CADT_FLAGS, htonl(flags)))) |
260 | goto nla_put_failure; | ||
260 | return 0; | 261 | return 0; |
261 | 262 | ||
262 | nla_put_failure: | 263 | nla_put_failure: |
@@ -273,13 +274,14 @@ hash_netiface4_data_tlist(struct sk_buff *skb, | |||
273 | 274 | ||
274 | if (data->nomatch) | 275 | if (data->nomatch) |
275 | flags |= IPSET_FLAG_NOMATCH; | 276 | flags |= IPSET_FLAG_NOMATCH; |
276 | NLA_PUT_IPADDR4(skb, IPSET_ATTR_IP, data->ip); | 277 | if (nla_put_ipaddr4(skb, IPSET_ATTR_IP, data->ip) || |
277 | NLA_PUT_U8(skb, IPSET_ATTR_CIDR, data->cidr); | 278 | nla_put_u8(skb, IPSET_ATTR_CIDR, data->cidr) || |
278 | NLA_PUT_STRING(skb, IPSET_ATTR_IFACE, data->iface); | 279 | nla_put_string(skb, IPSET_ATTR_IFACE, data->iface) || |
279 | if (flags) | 280 | (flags && |
280 | NLA_PUT_NET32(skb, IPSET_ATTR_CADT_FLAGS, htonl(flags)); | 281 | nla_put_net32(skb, IPSET_ATTR_CADT_FLAGS, htonl(flags))) || |
281 | NLA_PUT_NET32(skb, IPSET_ATTR_TIMEOUT, | 282 | nla_put_net32(skb, IPSET_ATTR_TIMEOUT, |
282 | htonl(ip_set_timeout_get(tdata->timeout))); | 283 | htonl(ip_set_timeout_get(tdata->timeout)))) |
284 | goto nla_put_failure; | ||
283 | 285 | ||
284 | return 0; | 286 | return 0; |
285 | 287 | ||
@@ -555,11 +557,12 @@ hash_netiface6_data_list(struct sk_buff *skb, | |||
555 | 557 | ||
556 | if (data->nomatch) | 558 | if (data->nomatch) |
557 | flags |= IPSET_FLAG_NOMATCH; | 559 | flags |= IPSET_FLAG_NOMATCH; |
558 | NLA_PUT_IPADDR6(skb, IPSET_ATTR_IP, &data->ip); | 560 | if (nla_put_ipaddr6(skb, IPSET_ATTR_IP, &data->ip.in6) || |
559 | NLA_PUT_U8(skb, IPSET_ATTR_CIDR, data->cidr); | 561 | nla_put_u8(skb, IPSET_ATTR_CIDR, data->cidr) || |
560 | NLA_PUT_STRING(skb, IPSET_ATTR_IFACE, data->iface); | 562 | nla_put_string(skb, IPSET_ATTR_IFACE, data->iface) || |
561 | if (flags) | 563 | (flags && |
562 | NLA_PUT_NET32(skb, IPSET_ATTR_CADT_FLAGS, htonl(flags)); | 564 | nla_put_net32(skb, IPSET_ATTR_CADT_FLAGS, htonl(flags)))) |
565 | goto nla_put_failure; | ||
563 | return 0; | 566 | return 0; |
564 | 567 | ||
565 | nla_put_failure: | 568 | nla_put_failure: |
@@ -576,13 +579,14 @@ hash_netiface6_data_tlist(struct sk_buff *skb, | |||
576 | 579 | ||
577 | if (data->nomatch) | 580 | if (data->nomatch) |
578 | flags |= IPSET_FLAG_NOMATCH; | 581 | flags |= IPSET_FLAG_NOMATCH; |
579 | NLA_PUT_IPADDR6(skb, IPSET_ATTR_IP, &e->ip); | 582 | if (nla_put_ipaddr6(skb, IPSET_ATTR_IP, &e->ip.in6) || |
580 | NLA_PUT_U8(skb, IPSET_ATTR_CIDR, data->cidr); | 583 | nla_put_u8(skb, IPSET_ATTR_CIDR, data->cidr) || |
581 | NLA_PUT_STRING(skb, IPSET_ATTR_IFACE, data->iface); | 584 | nla_put_string(skb, IPSET_ATTR_IFACE, data->iface) || |
582 | if (flags) | 585 | (flags && |
583 | NLA_PUT_NET32(skb, IPSET_ATTR_CADT_FLAGS, htonl(flags)); | 586 | nla_put_net32(skb, IPSET_ATTR_CADT_FLAGS, htonl(flags))) || |
584 | NLA_PUT_NET32(skb, IPSET_ATTR_TIMEOUT, | 587 | nla_put_net32(skb, IPSET_ATTR_TIMEOUT, |
585 | htonl(ip_set_timeout_get(e->timeout))); | 588 | htonl(ip_set_timeout_get(e->timeout)))) |
589 | goto nla_put_failure; | ||
586 | return 0; | 590 | return 0; |
587 | 591 | ||
588 | nla_put_failure: | 592 | nla_put_failure: |
diff --git a/net/netfilter/ipset/ip_set_hash_netport.c b/net/netfilter/ipset/ip_set_hash_netport.c index ce2e77100b64..ae3c644adc14 100644 --- a/net/netfilter/ipset/ip_set_hash_netport.c +++ b/net/netfilter/ipset/ip_set_hash_netport.c | |||
@@ -124,12 +124,13 @@ hash_netport4_data_list(struct sk_buff *skb, | |||
124 | { | 124 | { |
125 | u32 flags = data->nomatch ? IPSET_FLAG_NOMATCH : 0; | 125 | u32 flags = data->nomatch ? IPSET_FLAG_NOMATCH : 0; |
126 | 126 | ||
127 | NLA_PUT_IPADDR4(skb, IPSET_ATTR_IP, data->ip); | 127 | if (nla_put_ipaddr4(skb, IPSET_ATTR_IP, data->ip) || |
128 | NLA_PUT_NET16(skb, IPSET_ATTR_PORT, data->port); | 128 | nla_put_net16(skb, IPSET_ATTR_PORT, data->port) || |
129 | NLA_PUT_U8(skb, IPSET_ATTR_CIDR, data->cidr + 1); | 129 | nla_put_u8(skb, IPSET_ATTR_CIDR, data->cidr + 1) || |
130 | NLA_PUT_U8(skb, IPSET_ATTR_PROTO, data->proto); | 130 | nla_put_u8(skb, IPSET_ATTR_PROTO, data->proto) || |
131 | if (flags) | 131 | (flags && |
132 | NLA_PUT_NET32(skb, IPSET_ATTR_CADT_FLAGS, htonl(flags)); | 132 | nla_put_net32(skb, IPSET_ATTR_CADT_FLAGS, htonl(flags)))) |
133 | goto nla_put_failure; | ||
133 | return 0; | 134 | return 0; |
134 | 135 | ||
135 | nla_put_failure: | 136 | nla_put_failure: |
@@ -144,15 +145,15 @@ hash_netport4_data_tlist(struct sk_buff *skb, | |||
144 | (const struct hash_netport4_telem *)data; | 145 | (const struct hash_netport4_telem *)data; |
145 | u32 flags = data->nomatch ? IPSET_FLAG_NOMATCH : 0; | 146 | u32 flags = data->nomatch ? IPSET_FLAG_NOMATCH : 0; |
146 | 147 | ||
147 | NLA_PUT_IPADDR4(skb, IPSET_ATTR_IP, tdata->ip); | 148 | if (nla_put_ipaddr4(skb, IPSET_ATTR_IP, tdata->ip) || |
148 | NLA_PUT_NET16(skb, IPSET_ATTR_PORT, tdata->port); | 149 | nla_put_net16(skb, IPSET_ATTR_PORT, tdata->port) || |
149 | NLA_PUT_U8(skb, IPSET_ATTR_CIDR, data->cidr + 1); | 150 | nla_put_u8(skb, IPSET_ATTR_CIDR, data->cidr + 1) || |
150 | NLA_PUT_U8(skb, IPSET_ATTR_PROTO, data->proto); | 151 | nla_put_u8(skb, IPSET_ATTR_PROTO, data->proto) || |
151 | NLA_PUT_NET32(skb, IPSET_ATTR_TIMEOUT, | 152 | nla_put_net32(skb, IPSET_ATTR_TIMEOUT, |
152 | htonl(ip_set_timeout_get(tdata->timeout))); | 153 | htonl(ip_set_timeout_get(tdata->timeout))) || |
153 | if (flags) | 154 | (flags && |
154 | NLA_PUT_NET32(skb, IPSET_ATTR_CADT_FLAGS, htonl(flags)); | 155 | nla_put_net32(skb, IPSET_ATTR_CADT_FLAGS, htonl(flags)))) |
155 | 156 | goto nla_put_failure; | |
156 | return 0; | 157 | return 0; |
157 | 158 | ||
158 | nla_put_failure: | 159 | nla_put_failure: |
@@ -402,12 +403,13 @@ hash_netport6_data_list(struct sk_buff *skb, | |||
402 | { | 403 | { |
403 | u32 flags = data->nomatch ? IPSET_FLAG_NOMATCH : 0; | 404 | u32 flags = data->nomatch ? IPSET_FLAG_NOMATCH : 0; |
404 | 405 | ||
405 | NLA_PUT_IPADDR6(skb, IPSET_ATTR_IP, &data->ip); | 406 | if (nla_put_ipaddr6(skb, IPSET_ATTR_IP, &data->ip.in6) || |
406 | NLA_PUT_NET16(skb, IPSET_ATTR_PORT, data->port); | 407 | nla_put_net16(skb, IPSET_ATTR_PORT, data->port) || |
407 | NLA_PUT_U8(skb, IPSET_ATTR_CIDR, data->cidr + 1); | 408 | nla_put_u8(skb, IPSET_ATTR_CIDR, data->cidr + 1) || |
408 | NLA_PUT_U8(skb, IPSET_ATTR_PROTO, data->proto); | 409 | nla_put_u8(skb, IPSET_ATTR_PROTO, data->proto) || |
409 | if (flags) | 410 | (flags && |
410 | NLA_PUT_NET32(skb, IPSET_ATTR_CADT_FLAGS, htonl(flags)); | 411 | nla_put_net32(skb, IPSET_ATTR_CADT_FLAGS, htonl(flags)))) |
412 | goto nla_put_failure; | ||
411 | return 0; | 413 | return 0; |
412 | 414 | ||
413 | nla_put_failure: | 415 | nla_put_failure: |
@@ -422,14 +424,15 @@ hash_netport6_data_tlist(struct sk_buff *skb, | |||
422 | (const struct hash_netport6_telem *)data; | 424 | (const struct hash_netport6_telem *)data; |
423 | u32 flags = data->nomatch ? IPSET_FLAG_NOMATCH : 0; | 425 | u32 flags = data->nomatch ? IPSET_FLAG_NOMATCH : 0; |
424 | 426 | ||
425 | NLA_PUT_IPADDR6(skb, IPSET_ATTR_IP, &e->ip); | 427 | if (nla_put_ipaddr6(skb, IPSET_ATTR_IP, &e->ip.in6) || |
426 | NLA_PUT_NET16(skb, IPSET_ATTR_PORT, data->port); | 428 | nla_put_net16(skb, IPSET_ATTR_PORT, data->port) || |
427 | NLA_PUT_U8(skb, IPSET_ATTR_CIDR, data->cidr + 1); | 429 | nla_put_u8(skb, IPSET_ATTR_CIDR, data->cidr + 1) || |
428 | NLA_PUT_U8(skb, IPSET_ATTR_PROTO, data->proto); | 430 | nla_put_u8(skb, IPSET_ATTR_PROTO, data->proto) || |
429 | NLA_PUT_NET32(skb, IPSET_ATTR_TIMEOUT, | 431 | nla_put_net32(skb, IPSET_ATTR_TIMEOUT, |
430 | htonl(ip_set_timeout_get(e->timeout))); | 432 | htonl(ip_set_timeout_get(e->timeout))) || |
431 | if (flags) | 433 | (flags && |
432 | NLA_PUT_NET32(skb, IPSET_ATTR_CADT_FLAGS, htonl(flags)); | 434 | nla_put_net32(skb, IPSET_ATTR_CADT_FLAGS, htonl(flags)))) |
435 | goto nla_put_failure; | ||
433 | return 0; | 436 | return 0; |
434 | 437 | ||
435 | nla_put_failure: | 438 | nla_put_failure: |
diff --git a/net/netfilter/ipset/ip_set_list_set.c b/net/netfilter/ipset/ip_set_list_set.c index 7e095f9005f0..6cb1225765f9 100644 --- a/net/netfilter/ipset/ip_set_list_set.c +++ b/net/netfilter/ipset/ip_set_list_set.c | |||
@@ -402,12 +402,13 @@ list_set_head(struct ip_set *set, struct sk_buff *skb) | |||
402 | nested = ipset_nest_start(skb, IPSET_ATTR_DATA); | 402 | nested = ipset_nest_start(skb, IPSET_ATTR_DATA); |
403 | if (!nested) | 403 | if (!nested) |
404 | goto nla_put_failure; | 404 | goto nla_put_failure; |
405 | NLA_PUT_NET32(skb, IPSET_ATTR_SIZE, htonl(map->size)); | 405 | if (nla_put_net32(skb, IPSET_ATTR_SIZE, htonl(map->size)) || |
406 | if (with_timeout(map->timeout)) | 406 | (with_timeout(map->timeout) && |
407 | NLA_PUT_NET32(skb, IPSET_ATTR_TIMEOUT, htonl(map->timeout)); | 407 | nla_put_net32(skb, IPSET_ATTR_TIMEOUT, htonl(map->timeout))) || |
408 | NLA_PUT_NET32(skb, IPSET_ATTR_REFERENCES, htonl(set->ref - 1)); | 408 | nla_put_net32(skb, IPSET_ATTR_REFERENCES, htonl(set->ref - 1)) || |
409 | NLA_PUT_NET32(skb, IPSET_ATTR_MEMSIZE, | 409 | nla_put_net32(skb, IPSET_ATTR_MEMSIZE, |
410 | htonl(sizeof(*map) + map->size * map->dsize)); | 410 | htonl(sizeof(*map) + map->size * map->dsize))) |
411 | goto nla_put_failure; | ||
411 | ipset_nest_end(skb, nested); | 412 | ipset_nest_end(skb, nested); |
412 | 413 | ||
413 | return 0; | 414 | return 0; |
@@ -442,13 +443,15 @@ list_set_list(const struct ip_set *set, | |||
442 | } else | 443 | } else |
443 | goto nla_put_failure; | 444 | goto nla_put_failure; |
444 | } | 445 | } |
445 | NLA_PUT_STRING(skb, IPSET_ATTR_NAME, | 446 | if (nla_put_string(skb, IPSET_ATTR_NAME, |
446 | ip_set_name_byindex(e->id)); | 447 | ip_set_name_byindex(e->id))) |
448 | goto nla_put_failure; | ||
447 | if (with_timeout(map->timeout)) { | 449 | if (with_timeout(map->timeout)) { |
448 | const struct set_telem *te = | 450 | const struct set_telem *te = |
449 | (const struct set_telem *) e; | 451 | (const struct set_telem *) e; |
450 | NLA_PUT_NET32(skb, IPSET_ATTR_TIMEOUT, | 452 | __be32 to = htonl(ip_set_timeout_get(te->timeout)); |
451 | htonl(ip_set_timeout_get(te->timeout))); | 453 | if (nla_put_net32(skb, IPSET_ATTR_TIMEOUT, to)) |
454 | goto nla_put_failure; | ||
452 | } | 455 | } |
453 | ipset_nest_end(skb, nested); | 456 | ipset_nest_end(skb, nested); |
454 | } | 457 | } |