diff options
author | Patrick McHardy <kaber@trash.net> | 2007-09-28 17:39:55 -0400 |
---|---|---|
committer | David S. Miller <davem@sunset.davemloft.net> | 2007-10-10 19:53:35 -0400 |
commit | f73e924cdd166360e8cc9a1b193008fdc9b3e3e2 (patch) | |
tree | 48fbf4b0f9101359e05fb53eabe194495f8214d1 /net/ipv4 | |
parent | 5bf758539388fa9383afd539d052ae93229544b9 (diff) |
[NETFILTER]: ctnetlink: use netlink policy
Signed-off-by: Patrick McHardy <kaber@trash.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv4')
-rw-r--r-- | net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c | 10 | ||||
-rw-r--r-- | net/ipv4/netfilter/nf_conntrack_proto_icmp.c | 12 |
2 files changed, 9 insertions, 13 deletions
diff --git a/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c b/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c index 77ca556aad91..2fcb9249a8da 100644 --- a/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c +++ b/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c | |||
@@ -373,9 +373,9 @@ nla_put_failure: | |||
373 | return -1; | 373 | return -1; |
374 | } | 374 | } |
375 | 375 | ||
376 | static const size_t cta_min_ip[CTA_IP_MAX+1] = { | 376 | static const struct nla_policy ipv4_nla_policy[CTA_IP_MAX+1] = { |
377 | [CTA_IP_V4_SRC] = sizeof(u_int32_t), | 377 | [CTA_IP_V4_SRC] = { .type = NLA_U32 }, |
378 | [CTA_IP_V4_DST] = sizeof(u_int32_t), | 378 | [CTA_IP_V4_DST] = { .type = NLA_U32 }, |
379 | }; | 379 | }; |
380 | 380 | ||
381 | static int ipv4_nlattr_to_tuple(struct nlattr *tb[], | 381 | static int ipv4_nlattr_to_tuple(struct nlattr *tb[], |
@@ -384,9 +384,6 @@ static int ipv4_nlattr_to_tuple(struct nlattr *tb[], | |||
384 | if (!tb[CTA_IP_V4_SRC] || !tb[CTA_IP_V4_DST]) | 384 | if (!tb[CTA_IP_V4_SRC] || !tb[CTA_IP_V4_DST]) |
385 | return -EINVAL; | 385 | return -EINVAL; |
386 | 386 | ||
387 | if (nlattr_bad_size(tb, CTA_IP_MAX, cta_min_ip)) | ||
388 | return -EINVAL; | ||
389 | |||
390 | t->src.u3.ip = *(__be32 *)nla_data(tb[CTA_IP_V4_SRC]); | 387 | t->src.u3.ip = *(__be32 *)nla_data(tb[CTA_IP_V4_SRC]); |
391 | t->dst.u3.ip = *(__be32 *)nla_data(tb[CTA_IP_V4_DST]); | 388 | t->dst.u3.ip = *(__be32 *)nla_data(tb[CTA_IP_V4_DST]); |
392 | 389 | ||
@@ -413,6 +410,7 @@ struct nf_conntrack_l3proto nf_conntrack_l3proto_ipv4 __read_mostly = { | |||
413 | #if defined(CONFIG_NF_CT_NETLINK) || defined(CONFIG_NF_CT_NETLINK_MODULE) | 410 | #if defined(CONFIG_NF_CT_NETLINK) || defined(CONFIG_NF_CT_NETLINK_MODULE) |
414 | .tuple_to_nlattr = ipv4_tuple_to_nlattr, | 411 | .tuple_to_nlattr = ipv4_tuple_to_nlattr, |
415 | .nlattr_to_tuple = ipv4_nlattr_to_tuple, | 412 | .nlattr_to_tuple = ipv4_nlattr_to_tuple, |
413 | .nla_policy = ipv4_nla_policy, | ||
416 | #endif | 414 | #endif |
417 | #if defined(CONFIG_SYSCTL) && defined(CONFIG_NF_CONNTRACK_PROC_COMPAT) | 415 | #if defined(CONFIG_SYSCTL) && defined(CONFIG_NF_CONNTRACK_PROC_COMPAT) |
418 | .ctl_table_path = nf_net_ipv4_netfilter_sysctl_path, | 416 | .ctl_table_path = nf_net_ipv4_netfilter_sysctl_path, |
diff --git a/net/ipv4/netfilter/nf_conntrack_proto_icmp.c b/net/ipv4/netfilter/nf_conntrack_proto_icmp.c index ca7252c10758..11fedc73049c 100644 --- a/net/ipv4/netfilter/nf_conntrack_proto_icmp.c +++ b/net/ipv4/netfilter/nf_conntrack_proto_icmp.c | |||
@@ -248,10 +248,10 @@ nla_put_failure: | |||
248 | return -1; | 248 | return -1; |
249 | } | 249 | } |
250 | 250 | ||
251 | static const size_t cta_min_proto[CTA_PROTO_MAX+1] = { | 251 | static const struct nla_policy icmp_nla_policy[CTA_PROTO_MAX+1] = { |
252 | [CTA_PROTO_ICMP_TYPE] = sizeof(u_int8_t), | 252 | [CTA_PROTO_ICMP_TYPE] = { .type = NLA_U8 }, |
253 | [CTA_PROTO_ICMP_CODE] = sizeof(u_int8_t), | 253 | [CTA_PROTO_ICMP_CODE] = { .type = NLA_U8 }, |
254 | [CTA_PROTO_ICMP_ID] = sizeof(u_int16_t) | 254 | [CTA_PROTO_ICMP_ID] = { .type = NLA_U16 }, |
255 | }; | 255 | }; |
256 | 256 | ||
257 | static int icmp_nlattr_to_tuple(struct nlattr *tb[], | 257 | static int icmp_nlattr_to_tuple(struct nlattr *tb[], |
@@ -262,9 +262,6 @@ static int icmp_nlattr_to_tuple(struct nlattr *tb[], | |||
262 | || !tb[CTA_PROTO_ICMP_ID]) | 262 | || !tb[CTA_PROTO_ICMP_ID]) |
263 | return -EINVAL; | 263 | return -EINVAL; |
264 | 264 | ||
265 | if (nlattr_bad_size(tb, CTA_PROTO_MAX, cta_min_proto)) | ||
266 | return -EINVAL; | ||
267 | |||
268 | tuple->dst.u.icmp.type = | 265 | tuple->dst.u.icmp.type = |
269 | *(u_int8_t *)nla_data(tb[CTA_PROTO_ICMP_TYPE]); | 266 | *(u_int8_t *)nla_data(tb[CTA_PROTO_ICMP_TYPE]); |
270 | tuple->dst.u.icmp.code = | 267 | tuple->dst.u.icmp.code = |
@@ -329,6 +326,7 @@ struct nf_conntrack_l4proto nf_conntrack_l4proto_icmp __read_mostly = | |||
329 | #if defined(CONFIG_NF_CT_NETLINK) || defined(CONFIG_NF_CT_NETLINK_MODULE) | 326 | #if defined(CONFIG_NF_CT_NETLINK) || defined(CONFIG_NF_CT_NETLINK_MODULE) |
330 | .tuple_to_nlattr = icmp_tuple_to_nlattr, | 327 | .tuple_to_nlattr = icmp_tuple_to_nlattr, |
331 | .nlattr_to_tuple = icmp_nlattr_to_tuple, | 328 | .nlattr_to_tuple = icmp_nlattr_to_tuple, |
329 | .nla_policy = icmp_nla_policy, | ||
332 | #endif | 330 | #endif |
333 | #ifdef CONFIG_SYSCTL | 331 | #ifdef CONFIG_SYSCTL |
334 | .ctl_table_header = &icmp_sysctl_header, | 332 | .ctl_table_header = &icmp_sysctl_header, |