* [PATCH 1/5] netfilter: fix crash during boot if NAT has been compiled built-in
2012-09-13 11:01 [PATCH 0/5] Netfilter updates for net-next pablo
@ 2012-09-13 11:01 ` pablo
2012-09-13 11:01 ` [PATCH 2/5] netfilter: nf_nat: fix out-of-bounds access in address selection pablo
` (4 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: pablo @ 2012-09-13 11:01 UTC (permalink / raw)
To: netfilter-devel; +Cc: davem, netdev
From: Pablo Neira Ayuso <pablo@netfilter.org>
(c7232c9 netfilter: add protocol independent NAT core) introduced a
problem that leads to crashing during boot due to NULL pointer
dereference. It seems that xt_nat calls xt_register_target() before
xt_init():
net/netfilter/x_tables.c:static struct xt_af *xt; is NULL and we crash on
xt_register_target(struct xt_target *target)
{
u_int8_t af = target->family;
int ret;
ret = mutex_lock_interruptible(&xt[af].mutex);
...
Fix this by changing the linking order, to make sure that x_tables
comes before xt_nat.
Reported-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
---
net/netfilter/Makefile | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/netfilter/Makefile b/net/netfilter/Makefile
index 98244d4..0baa3f1 100644
--- a/net/netfilter/Makefile
+++ b/net/netfilter/Makefile
@@ -47,7 +47,6 @@ nf_nat-y := nf_nat_core.o nf_nat_proto_unknown.o nf_nat_proto_common.o \
nf_nat_proto_udp.o nf_nat_proto_tcp.o nf_nat_helper.o
obj-$(CONFIG_NF_NAT) += nf_nat.o
-obj-$(CONFIG_NF_NAT) += xt_nat.o
# NAT protocols (nf_nat)
obj-$(CONFIG_NF_NAT_PROTO_DCCP) += nf_nat_proto_dccp.o
@@ -71,6 +70,7 @@ obj-$(CONFIG_NETFILTER_XTABLES) += x_tables.o xt_tcpudp.o
obj-$(CONFIG_NETFILTER_XT_MARK) += xt_mark.o
obj-$(CONFIG_NETFILTER_XT_CONNMARK) += xt_connmark.o
obj-$(CONFIG_NETFILTER_XT_SET) += xt_set.o
+obj-$(CONFIG_NF_NAT) += xt_nat.o
# targets
obj-$(CONFIG_NETFILTER_XT_TARGET_AUDIT) += xt_AUDIT.o
--
1.7.10.4
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 2/5] netfilter: nf_nat: fix out-of-bounds access in address selection
2012-09-13 11:01 [PATCH 0/5] Netfilter updates for net-next pablo
2012-09-13 11:01 ` [PATCH 1/5] netfilter: fix crash during boot if NAT has been compiled built-in pablo
@ 2012-09-13 11:01 ` pablo
2012-09-13 11:01 ` [PATCH 3/5] netfilter: nfnetlink_queue: remove pointless conditional before kfree_skb() pablo
` (3 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: pablo @ 2012-09-13 11:01 UTC (permalink / raw)
To: netfilter-devel; +Cc: davem, netdev
From: Florian Westphal <fw@strlen.de>
include/linux/jhash.h:138:16: warning: array subscript is above array bounds
[jhash2() expects the number of u32 in the key]
Signed-off-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
---
net/netfilter/nf_nat_core.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/netfilter/nf_nat_core.c b/net/netfilter/nf_nat_core.c
index 29d4452..1816ad3 100644
--- a/net/netfilter/nf_nat_core.c
+++ b/net/netfilter/nf_nat_core.c
@@ -255,7 +255,7 @@ find_best_ips_proto(u16 zone, struct nf_conntrack_tuple *tuple,
* client coming from the same IP (some Internet Banking sites
* like this), even across reboots.
*/
- j = jhash2((u32 *)&tuple->src.u3, sizeof(tuple->src.u3),
+ j = jhash2((u32 *)&tuple->src.u3, sizeof(tuple->src.u3) / sizeof(u32),
range->flags & NF_NAT_RANGE_PERSISTENT ?
0 : (__force u32)tuple->dst.u3.all[max] ^ zone);
--
1.7.10.4
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 3/5] netfilter: nfnetlink_queue: remove pointless conditional before kfree_skb()
2012-09-13 11:01 [PATCH 0/5] Netfilter updates for net-next pablo
2012-09-13 11:01 ` [PATCH 1/5] netfilter: fix crash during boot if NAT has been compiled built-in pablo
2012-09-13 11:01 ` [PATCH 2/5] netfilter: nf_nat: fix out-of-bounds access in address selection pablo
@ 2012-09-13 11:01 ` pablo
2012-09-13 11:01 ` [PATCH 4/5] ipvs: use list_del_init instead of list_del/INIT_LIST_HEAD pablo
` (2 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: pablo @ 2012-09-13 11:01 UTC (permalink / raw)
To: netfilter-devel; +Cc: davem, netdev
From: Wei Yongjun <yongjun_wei@trendmicro.com.cn>
Remove pointless conditional before kfree_skb().
Signed-off-by: Wei Yongjun <yongjun_wei@trendmicro.com.cn>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
---
net/netfilter/nfnetlink_queue_core.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/net/netfilter/nfnetlink_queue_core.c b/net/netfilter/nfnetlink_queue_core.c
index c0496a5..5c2d78d 100644
--- a/net/netfilter/nfnetlink_queue_core.c
+++ b/net/netfilter/nfnetlink_queue_core.c
@@ -406,8 +406,7 @@ nfqnl_build_packet_message(struct nfqnl_instance *queue,
return skb;
nla_put_failure:
- if (skb)
- kfree_skb(skb);
+ kfree_skb(skb);
net_err_ratelimited("nf_queue: error creating packet message\n");
return NULL;
}
--
1.7.10.4
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 4/5] ipvs: use list_del_init instead of list_del/INIT_LIST_HEAD
2012-09-13 11:01 [PATCH 0/5] Netfilter updates for net-next pablo
` (2 preceding siblings ...)
2012-09-13 11:01 ` [PATCH 3/5] netfilter: nfnetlink_queue: remove pointless conditional before kfree_skb() pablo
@ 2012-09-13 11:01 ` pablo
2012-09-13 11:01 ` [PATCH 5/5] netfilter: ctnetlink: fix module auto-load in ctnetlink_parse_nat pablo
2012-09-13 18:26 ` [PATCH 0/5] Netfilter updates for net-next David Miller
5 siblings, 0 replies; 7+ messages in thread
From: pablo @ 2012-09-13 11:01 UTC (permalink / raw)
To: netfilter-devel; +Cc: davem, netdev
From: Wei Yongjun <yongjun_wei@trendmicro.com.cn>
Using list_del_init() instead of list_del() + INIT_LIST_HEAD().
spatch with a semantic match is used to found this problem.
(http://coccinelle.lip6.fr/)
Signed-off-by: Wei Yongjun <yongjun_wei@trendmicro.com.cn>
Acked-by: Simon Horman <horms@verge.net.au>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
---
net/netfilter/ipvs/ip_vs_ctl.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/net/netfilter/ipvs/ip_vs_ctl.c b/net/netfilter/ipvs/ip_vs_ctl.c
index 767cc12..37b38d0 100644
--- a/net/netfilter/ipvs/ip_vs_ctl.c
+++ b/net/netfilter/ipvs/ip_vs_ctl.c
@@ -539,8 +539,7 @@ static int ip_vs_rs_unhash(struct ip_vs_dest *dest)
* Remove it from the rs_table table.
*/
if (!list_empty(&dest->d_list)) {
- list_del(&dest->d_list);
- INIT_LIST_HEAD(&dest->d_list);
+ list_del_init(&dest->d_list);
}
return 1;
--
1.7.10.4
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 5/5] netfilter: ctnetlink: fix module auto-load in ctnetlink_parse_nat
2012-09-13 11:01 [PATCH 0/5] Netfilter updates for net-next pablo
` (3 preceding siblings ...)
2012-09-13 11:01 ` [PATCH 4/5] ipvs: use list_del_init instead of list_del/INIT_LIST_HEAD pablo
@ 2012-09-13 11:01 ` pablo
2012-09-13 18:26 ` [PATCH 0/5] Netfilter updates for net-next David Miller
5 siblings, 0 replies; 7+ messages in thread
From: pablo @ 2012-09-13 11:01 UTC (permalink / raw)
To: netfilter-devel; +Cc: davem, netdev
From: Pablo Neira Ayuso <pablo@netfilter.org>
(c7232c9 netfilter: add protocol independent NAT core) added
incorrect locking for the module auto-load case in ctnetlink_parse_nat.
That function is always called from ctnetlink_create_conntrack which
requires no locking.
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
---
net/netfilter/nf_conntrack_netlink.c | 3 ---
1 file changed, 3 deletions(-)
diff --git a/net/netfilter/nf_conntrack_netlink.c b/net/netfilter/nf_conntrack_netlink.c
index a205bd6..090d267 100644
--- a/net/netfilter/nf_conntrack_netlink.c
+++ b/net/netfilter/nf_conntrack_netlink.c
@@ -1120,16 +1120,13 @@ ctnetlink_parse_nat_setup(struct nf_conn *ct,
if (err == -EAGAIN) {
#ifdef CONFIG_MODULES
rcu_read_unlock();
- spin_unlock_bh(&nf_conntrack_lock);
nfnl_unlock();
if (request_module("nf-nat-%u", nf_ct_l3num(ct)) < 0) {
nfnl_lock();
- spin_lock_bh(&nf_conntrack_lock);
rcu_read_lock();
return -EOPNOTSUPP;
}
nfnl_lock();
- spin_lock_bh(&nf_conntrack_lock);
rcu_read_lock();
#else
err = -EOPNOTSUPP;
--
1.7.10.4
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH 0/5] Netfilter updates for net-next
2012-09-13 11:01 [PATCH 0/5] Netfilter updates for net-next pablo
` (4 preceding siblings ...)
2012-09-13 11:01 ` [PATCH 5/5] netfilter: ctnetlink: fix module auto-load in ctnetlink_parse_nat pablo
@ 2012-09-13 18:26 ` David Miller
5 siblings, 0 replies; 7+ messages in thread
From: David Miller @ 2012-09-13 18:26 UTC (permalink / raw)
To: pablo; +Cc: netfilter-devel, netdev
From: pablo@netfilter.org
Date: Thu, 13 Sep 2012 13:01:27 +0200
> The following patchset contains four Netfilter updates, mostly targeting
> to fix issues added with IPv6 NAT, and one little IPVS update for net-next:
>
> * Remove unneeded conditional free of skb in nfnetlink_queue, from
> Wei Yongjun.
>
> * One semantic path from coccinelle detected the use of list_del +
> INIT_LIST_HEAD, instead of list_del_init, again from Wei Yongjun.
>
> * Fix out-of-bound memory access in the NAT address selection, from
> Florian Westphal. This was introduced with the IPv6 NAT patches.
>
> * Two fixes for crashes that were introduced in the recently merged
> IPv6 NAT support, from myself.
>
> You can pull these changes from:
>
> git://1984.lsi.us.es/nf-next master
Also pulled, thanks a lot.
^ permalink raw reply [flat|nested] 7+ messages in thread