netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/5] netfilter fixes for 3.5-rc4
@ 2012-06-29 15:37 pablo
  2012-06-29 15:37 ` [PATCH 1/5] netfilter: ipset: fix interface comparision in hash-netiface sets pablo
                   ` (5 more replies)
  0 siblings, 6 replies; 9+ messages in thread
From: pablo @ 2012-06-29 15:37 UTC (permalink / raw)
  To: netfilter-devel; +Cc: davem, netdev

From: Pablo Neira Ayuso <pablo@netfilter.org>

Hi David,

The following are 4 fixes and the update of the MAINTAINERS file
to point to my Netfilter trees.

They are:

* One refcount leak fix in IPVS IPv6 support from Eric Dumazet.

* One fix for interface comparison in ipset hash-netiface sets
  from Florian Westphal.

* One fix for a missing rcu_read_unlock in nfnetlink from
  Tomasz Bursztyka.

* One fix for a kernel crash if IPSET_CMD_NONE is set to ipset via
  nfnetlink, again from Tomasz Bursztyka.

You can pull these changes from:

git://1984.lsi.us.es/nf master

Thanks!

Eric Dumazet (1):
  netfilter: ipvs: fix dst leak in __ip_vs_addr_is_local_v6

Florian Westphal (1):
  netfilter: ipset: fix interface comparision in hash-netiface sets

Pablo Neira Ayuso (1):
  netfilter: update location of my trees

Tomasz Bursztyka (2):
  netfilter: ipset: fix crash if IPSET_CMD_NONE command is sent
  netfilter: nfnetlink: fix missing rcu_read_unlock in nfnetlink_rcv_msg

 MAINTAINERS                                |    4 ++--
 net/netfilter/ipset/ip_set_core.c          |   12 +++++++++++
 net/netfilter/ipset/ip_set_hash_netiface.c |   32 ++++------------------------
 net/netfilter/ipvs/ip_vs_ctl.c             |   14 ++++++------
 net/netfilter/nfnetlink.c                  |    4 +++-
 5 files changed, 28 insertions(+), 38 deletions(-)

-- 
1.7.10


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH 1/5] netfilter: ipset: fix interface comparision in hash-netiface sets
  2012-06-29 15:37 [PATCH 0/5] netfilter fixes for 3.5-rc4 pablo
@ 2012-06-29 15:37 ` pablo
  2012-06-29 15:41   ` David Laight
  2012-06-29 15:37 ` [PATCH 2/5] netfilter: ipvs: fix dst leak in __ip_vs_addr_is_local_v6 pablo
                   ` (4 subsequent siblings)
  5 siblings, 1 reply; 9+ messages in thread
From: pablo @ 2012-06-29 15:37 UTC (permalink / raw)
  To: netfilter-devel; +Cc: davem, netdev

From: Florian Westphal <fw@strlen.de>

ifname_compare() assumes that skb->dev is zero-padded,
e.g 'eth1\0\0\0\0\0...'. This isn't always the case. e1000 driver does

strncpy(netdev->name, pci_name(pdev), sizeof(netdev->name) - 1);

in e1000_probe(), so once device is registered dev->name memory contains
'eth1\0:0:3\0\0\0' (or something like that), which makes eth1 compare
fail.

Use plain strcmp() instead.

Signed-off-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
---
 net/netfilter/ipset/ip_set_hash_netiface.c |   32 ++++------------------------
 1 file changed, 4 insertions(+), 28 deletions(-)

diff --git a/net/netfilter/ipset/ip_set_hash_netiface.c b/net/netfilter/ipset/ip_set_hash_netiface.c
index ee86394..d5d3607 100644
--- a/net/netfilter/ipset/ip_set_hash_netiface.c
+++ b/net/netfilter/ipset/ip_set_hash_netiface.c
@@ -38,30 +38,6 @@ struct iface_node {
 
 #define iface_data(n)	(rb_entry(n, struct iface_node, node)->iface)
 
-static inline long
-ifname_compare(const char *_a, const char *_b)
-{
-	const long *a = (const long *)_a;
-	const long *b = (const long *)_b;
-
-	BUILD_BUG_ON(IFNAMSIZ > 4 * sizeof(unsigned long));
-	if (a[0] != b[0])
-		return a[0] - b[0];
-	if (IFNAMSIZ > sizeof(long)) {
-		if (a[1] != b[1])
-			return a[1] - b[1];
-	}
-	if (IFNAMSIZ > 2 * sizeof(long)) {
-		if (a[2] != b[2])
-			return a[2] - b[2];
-	}
-	if (IFNAMSIZ > 3 * sizeof(long)) {
-		if (a[3] != b[3])
-			return a[3] - b[3];
-	}
-	return 0;
-}
-
 static void
 rbtree_destroy(struct rb_root *root)
 {
@@ -99,7 +75,7 @@ iface_test(struct rb_root *root, const char **iface)
 
 	while (n) {
 		const char *d = iface_data(n);
-		long res = ifname_compare(*iface, d);
+		int res = strcmp(*iface, d);
 
 		if (res < 0)
 			n = n->rb_left;
@@ -121,7 +97,7 @@ iface_add(struct rb_root *root, const char **iface)
 
 	while (*n) {
 		char *ifname = iface_data(*n);
-		long res = ifname_compare(*iface, ifname);
+		int res = strcmp(*iface, ifname);
 
 		p = *n;
 		if (res < 0)
@@ -366,7 +342,7 @@ hash_netiface4_uadt(struct ip_set *set, struct nlattr *tb[],
 	struct hash_netiface4_elem data = { .cidr = HOST_MASK };
 	u32 ip = 0, ip_to, last;
 	u32 timeout = h->timeout;
-	char iface[IFNAMSIZ] = {};
+	char iface[IFNAMSIZ];
 	int ret;
 
 	if (unlikely(!tb[IPSET_ATTR_IP] ||
@@ -663,7 +639,7 @@ hash_netiface6_uadt(struct ip_set *set, struct nlattr *tb[],
 	ipset_adtfn adtfn = set->variant->adt[adt];
 	struct hash_netiface6_elem data = { .cidr = HOST_MASK };
 	u32 timeout = h->timeout;
-	char iface[IFNAMSIZ] = {};
+	char iface[IFNAMSIZ];
 	int ret;
 
 	if (unlikely(!tb[IPSET_ATTR_IP] ||
-- 
1.7.10

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH 2/5] netfilter: ipvs: fix dst leak in __ip_vs_addr_is_local_v6
  2012-06-29 15:37 [PATCH 0/5] netfilter fixes for 3.5-rc4 pablo
  2012-06-29 15:37 ` [PATCH 1/5] netfilter: ipset: fix interface comparision in hash-netiface sets pablo
@ 2012-06-29 15:37 ` pablo
  2012-06-29 15:37 ` [PATCH 3/5] netfilter: update location of my trees pablo
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 9+ messages in thread
From: pablo @ 2012-06-29 15:37 UTC (permalink / raw)
  To: netfilter-devel; +Cc: davem, netdev

From: Eric Dumazet <edumazet@google.com>

After call to ip6_route_output() we must release dst or we leak it.

Also should test dst->error, as ip6_route_output() never returns NULL.

Use boolean while we are at it.

Signed-off-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
---
 net/netfilter/ipvs/ip_vs_ctl.c |   14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/net/netfilter/ipvs/ip_vs_ctl.c b/net/netfilter/ipvs/ip_vs_ctl.c
index dd811b8..d43e3c1 100644
--- a/net/netfilter/ipvs/ip_vs_ctl.c
+++ b/net/netfilter/ipvs/ip_vs_ctl.c
@@ -76,19 +76,19 @@ static void __ip_vs_del_service(struct ip_vs_service *svc);
 
 #ifdef CONFIG_IP_VS_IPV6
 /* Taken from rt6_fill_node() in net/ipv6/route.c, is there a better way? */
-static int __ip_vs_addr_is_local_v6(struct net *net,
-				    const struct in6_addr *addr)
+static bool __ip_vs_addr_is_local_v6(struct net *net,
+				     const struct in6_addr *addr)
 {
-	struct rt6_info *rt;
 	struct flowi6 fl6 = {
 		.daddr = *addr,
 	};
+	struct dst_entry *dst = ip6_route_output(net, NULL, &fl6);
+	bool is_local;
 
-	rt = (struct rt6_info *)ip6_route_output(net, NULL, &fl6);
-	if (rt && rt->dst.dev && (rt->dst.dev->flags & IFF_LOOPBACK))
-		return 1;
+	is_local = !dst->error && dst->dev && (dst->dev->flags & IFF_LOOPBACK);
 
-	return 0;
+	dst_release(dst);
+	return is_local;
 }
 #endif
 
-- 
1.7.10


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH 3/5] netfilter: update location of my trees
  2012-06-29 15:37 [PATCH 0/5] netfilter fixes for 3.5-rc4 pablo
  2012-06-29 15:37 ` [PATCH 1/5] netfilter: ipset: fix interface comparision in hash-netiface sets pablo
  2012-06-29 15:37 ` [PATCH 2/5] netfilter: ipvs: fix dst leak in __ip_vs_addr_is_local_v6 pablo
@ 2012-06-29 15:37 ` pablo
  2012-06-29 15:37 ` [PATCH 4/5] netfilter: ipset: fix crash if IPSET_CMD_NONE command is sent pablo
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 9+ messages in thread
From: pablo @ 2012-06-29 15:37 UTC (permalink / raw)
  To: netfilter-devel; +Cc: davem, netdev

From: Pablo Neira Ayuso <pablo@netfilter.org>

Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
---
 MAINTAINERS |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/MAINTAINERS b/MAINTAINERS
index f6e62de..302aa00 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -4654,8 +4654,8 @@ L:	netfilter@vger.kernel.org
 L:	coreteam@netfilter.org
 W:	http://www.netfilter.org/
 W:	http://www.iptables.org/
-T:	git git://git.kernel.org/pub/scm/linux/kernel/git/netfilter/nf-2.6.git
-T:	git git://git.kernel.org/pub/scm/linux/kernel/git/netfilter/nf-next-2.6.git
+T:	git git://1984.lsi.us.es/nf
+T:	git git://1984.lsi.us.es/nf-next
 S:	Supported
 F:	include/linux/netfilter*
 F:	include/linux/netfilter/
-- 
1.7.10

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH 4/5] netfilter: ipset: fix crash if IPSET_CMD_NONE command is sent
  2012-06-29 15:37 [PATCH 0/5] netfilter fixes for 3.5-rc4 pablo
                   ` (2 preceding siblings ...)
  2012-06-29 15:37 ` [PATCH 3/5] netfilter: update location of my trees pablo
@ 2012-06-29 15:37 ` pablo
  2012-06-29 15:37 ` [PATCH 5/5] netfilter: nfnetlink: fix missing rcu_read_unlock in nfnetlink_rcv_msg pablo
  2012-06-29 23:37 ` [PATCH 0/5] netfilter fixes for 3.5-rc4 David Miller
  5 siblings, 0 replies; 9+ messages in thread
From: pablo @ 2012-06-29 15:37 UTC (permalink / raw)
  To: netfilter-devel; +Cc: davem, netdev

From: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>

This patch fixes a crash if that ipset command is sent over nfnetlink.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
Acked-by: Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
---
 net/netfilter/ipset/ip_set_core.c |   12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/net/netfilter/ipset/ip_set_core.c b/net/netfilter/ipset/ip_set_core.c
index 819c342..9730882 100644
--- a/net/netfilter/ipset/ip_set_core.c
+++ b/net/netfilter/ipset/ip_set_core.c
@@ -640,6 +640,14 @@ find_free_id(const char *name, ip_set_id_t *index, struct ip_set **set)
 }
 
 static int
+ip_set_none(struct sock *ctnl, struct sk_buff *skb,
+	    const struct nlmsghdr *nlh,
+	    const struct nlattr * const attr[])
+{
+	return -EOPNOTSUPP;
+}
+
+static int
 ip_set_create(struct sock *ctnl, struct sk_buff *skb,
 	      const struct nlmsghdr *nlh,
 	      const struct nlattr * const attr[])
@@ -1539,6 +1547,10 @@ nlmsg_failure:
 }
 
 static const struct nfnl_callback ip_set_netlink_subsys_cb[IPSET_MSG_MAX] = {
+	[IPSET_CMD_NONE]	= {
+		.call		= ip_set_none,
+		.attr_count	= IPSET_ATTR_CMD_MAX,
+	},
 	[IPSET_CMD_CREATE]	= {
 		.call		= ip_set_create,
 		.attr_count	= IPSET_ATTR_CMD_MAX,
-- 
1.7.10


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH 5/5] netfilter: nfnetlink: fix missing rcu_read_unlock in nfnetlink_rcv_msg
  2012-06-29 15:37 [PATCH 0/5] netfilter fixes for 3.5-rc4 pablo
                   ` (3 preceding siblings ...)
  2012-06-29 15:37 ` [PATCH 4/5] netfilter: ipset: fix crash if IPSET_CMD_NONE command is sent pablo
@ 2012-06-29 15:37 ` pablo
  2012-06-29 23:37 ` [PATCH 0/5] netfilter fixes for 3.5-rc4 David Miller
  5 siblings, 0 replies; 9+ messages in thread
From: pablo @ 2012-06-29 15:37 UTC (permalink / raw)
  To: netfilter-devel; +Cc: davem, netdev

From: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>

Bug added in commit 6b75e3e8d664a9a (netfilter: nfnetlink: add RCU in
nfnetlink_rcv_msg())

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
Acked-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
---
 net/netfilter/nfnetlink.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/net/netfilter/nfnetlink.c b/net/netfilter/nfnetlink.c
index 3e797d1..791d56b 100644
--- a/net/netfilter/nfnetlink.c
+++ b/net/netfilter/nfnetlink.c
@@ -169,8 +169,10 @@ replay:
 
 		err = nla_parse(cda, ss->cb[cb_id].attr_count,
 				attr, attrlen, ss->cb[cb_id].policy);
-		if (err < 0)
+		if (err < 0) {
+			rcu_read_unlock();
 			return err;
+		}
 
 		if (nc->call_rcu) {
 			err = nc->call_rcu(net->nfnl, skb, nlh,
-- 
1.7.10

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* RE: [PATCH 1/5] netfilter: ipset: fix interface comparision in hash-netiface sets
  2012-06-29 15:37 ` [PATCH 1/5] netfilter: ipset: fix interface comparision in hash-netiface sets pablo
@ 2012-06-29 15:41   ` David Laight
  2012-06-29 18:24     ` Florian Westphal
  0 siblings, 1 reply; 9+ messages in thread
From: David Laight @ 2012-06-29 15:41 UTC (permalink / raw)
  To: pablo, netfilter-devel; +Cc: davem, netdev

> From: Florian Westphal <fw@strlen.de>
> 
> ifname_compare() assumes that skb->dev is zero-padded,
> e.g 'eth1\0\0\0\0\0...'. This isn't always the case. e1000 driver does
> 
> strncpy(netdev->name, pci_name(pdev), sizeof(netdev->name) - 1);
> 
> in e1000_probe(), so once device is registered dev->name memory
contains
> 'eth1\0:0:3\0\0\0' (or something like that), which makes eth1 compare
fail.

strncpy() would normally zero-fill the destination buffer
(at least the libc version does).

So something else must be wrong.

	David



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 1/5] netfilter: ipset: fix interface comparision in hash-netiface sets
  2012-06-29 15:41   ` David Laight
@ 2012-06-29 18:24     ` Florian Westphal
  0 siblings, 0 replies; 9+ messages in thread
From: Florian Westphal @ 2012-06-29 18:24 UTC (permalink / raw)
  To: David Laight; +Cc: pablo, netfilter-devel, davem, netdev

David Laight <David.Laight@ACULAB.COM> wrote:
> > From: Florian Westphal <fw@strlen.de>
> > 
> > ifname_compare() assumes that skb->dev is zero-padded,
> > e.g 'eth1\0\0\0\0\0...'. This isn't always the case. e1000 driver does
> > 
> > strncpy(netdev->name, pci_name(pdev), sizeof(netdev->name) - 1);
> > 
> > in e1000_probe(), so once device is registered dev->name memory
> contains
> > 'eth1\0:0:3\0\0\0' (or something like that), which makes eth1 compare
> fail.
> 
> strncpy() would normally zero-fill the destination buffer
> (at least the libc version does).
> 
> So something else must be wrong.

No. driver .probe() runs before the device name is filled in, and no
explict zeroing happens there.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 0/5] netfilter fixes for 3.5-rc4
  2012-06-29 15:37 [PATCH 0/5] netfilter fixes for 3.5-rc4 pablo
                   ` (4 preceding siblings ...)
  2012-06-29 15:37 ` [PATCH 5/5] netfilter: nfnetlink: fix missing rcu_read_unlock in nfnetlink_rcv_msg pablo
@ 2012-06-29 23:37 ` David Miller
  5 siblings, 0 replies; 9+ messages in thread
From: David Miller @ 2012-06-29 23:37 UTC (permalink / raw)
  To: pablo; +Cc: netfilter-devel, netdev

From: pablo@netfilter.org
Date: Fri, 29 Jun 2012 17:37:30 +0200

> * One refcount leak fix in IPVS IPv6 support from Eric Dumazet.
> 
> * One fix for interface comparison in ipset hash-netiface sets
>   from Florian Westphal.
> 
> * One fix for a missing rcu_read_unlock in nfnetlink from
>   Tomasz Bursztyka.
> 
> * One fix for a kernel crash if IPSET_CMD_NONE is set to ipset via
>   nfnetlink, again from Tomasz Bursztyka.
> 
> You can pull these changes from:
> 
> git://1984.lsi.us.es/nf master

Pulled, thanks Pablo.

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2012-06-29 23:37 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-06-29 15:37 [PATCH 0/5] netfilter fixes for 3.5-rc4 pablo
2012-06-29 15:37 ` [PATCH 1/5] netfilter: ipset: fix interface comparision in hash-netiface sets pablo
2012-06-29 15:41   ` David Laight
2012-06-29 18:24     ` Florian Westphal
2012-06-29 15:37 ` [PATCH 2/5] netfilter: ipvs: fix dst leak in __ip_vs_addr_is_local_v6 pablo
2012-06-29 15:37 ` [PATCH 3/5] netfilter: update location of my trees pablo
2012-06-29 15:37 ` [PATCH 4/5] netfilter: ipset: fix crash if IPSET_CMD_NONE command is sent pablo
2012-06-29 15:37 ` [PATCH 5/5] netfilter: nfnetlink: fix missing rcu_read_unlock in nfnetlink_rcv_msg pablo
2012-06-29 23:37 ` [PATCH 0/5] netfilter fixes for 3.5-rc4 David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).