Skip to contentSkip to conversation

netfilter fixes for net

PATCH In review Pablo Neira Ayuso 2 participants 4 messages Apr 19, 2013

Subsystems (3)
lore
Share & tools
lore

Pablo Neira Ayuso

author maintainer
#0 lore raw

cover netfilter fixes for net

Hi David,

If time allows, please consider pulling the following patchset contains two late Netfilter fixes, they are:

* Skip broadcast/multicast locally generated traffic in the rpfilter, (closes netfilter bugzilla #814), from Florian Westphal.

* Fix missing elements in the listing of ipset bitmap ip,mac set type with timeout support enabled, from Jozsef Kadlecsik.

The following changes since commit c2d421e171868586939c328dfb91bab840fe4c49:

netfilter: nf_nat: fix race when unloading protocol modules (2013-04-12 11:46:31 +0200)

are available in the git repository at:

git://git.kernel.org/pub/scm/linux/kernel/git/pablo/nf.git master

for you to fetch changes up to f83a7ea2075ca896f2dbf07672bac9cf3682ff74:

netfilter: xt_rpfilter: skip locally generated broadcast/multicast, too (2013-04-19 00:11:59 +0200)

----------------------------------------------------------------
Florian Westphal (1):
netfilter: xt_rpfilter: skip locally generated broadcast/multicast, too

Jozsef Kadlecsik (1):
netfilter: ipset: bitmap:ip,mac: fix listing with timeout

 net/ipv4/netfilter/ipt_rpfilter.c         |    8 +++++++-
 net/ipv6/netfilter/ip6t_rpfilter.c        |    8 +++++++-
 net/netfilter/ipset/ip_set_bitmap_ipmac.c |    6 +++++-
 3 files changed, 19 insertions(+), 3 deletions(-)
author maintainer
#1 lore raw

PATCH 1/2 netfilter: ipset: bitmap:ip,mac: fix listing with timeout

From: Jozsef Kadlecsik <[email protected]>

The type when timeout support was enabled, could not list all elements, just the first ones which could fit into one netlink message: it just did not continue listing after the first message.

---
 net/netfilter/ipset/ip_set_bitmap_ipmac.c |    6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
net/netfilter/ipset/ip_set_bitmap_ipmac.c +5 -1
index 0f92dc2..d7df6ac 100644
@@ -339,7 +339,11 @@ bitmap_ipmac_tlist(const struct ip_set *set,
 nla_put_failure:
 	nla_nest_cancel(skb, nested);
 	ipset_nest_end(skb, atd);
-	return -EMSGSIZE;
+	if (unlikely(id == first)) {
+		cb->args[2] = 0;
+		return -EMSGSIZE;
+	}
+	return 0;
 }
 
 static int
Signature · 1 line
1.7.10.4
author maintainer
#2 lore raw

PATCH 2/2 netfilter: xt_rpfilter: skip locally generated broadcast/multicast, too

In reply to Pablo Neira Ayuso

From: Florian Westphal <[email protected]>

Alex Efros reported rpfilter module doesn't match following packets:
IN=br.qemu SRC=192.168.2.1 DST=192.168.2.255 [ .. ] (netfilter bugzilla #814).

Problem is that network stack arranges for the locally generated broadcasts to appear on the interface they were sent out, so the IFF_LOOPBACK check doesn't trigger.

As -m rpfilter is restricted to PREROUTING, we can check for existing rtable instead, it catches locally-generated broad/multicast case, too.

---
 net/ipv4/netfilter/ipt_rpfilter.c  |    8 +++++++-
 net/ipv6/netfilter/ip6t_rpfilter.c |    8 +++++++-
 2 files changed, 14 insertions(+), 2 deletions(-)
net/ipv4/netfilter/ipt_rpfilter.c +7 -1
index c301300..c49dcd0 100644
@@ -66,6 +66,12 @@ static bool rpfilter_lookup_reverse(struct flowi4 *fl4,
 	return dev_match;
 }
 
+static bool rpfilter_is_local(const struct sk_buff *skb)
+{
+	const struct rtable *rt = skb_rtable(skb);
+	return rt && (rt->rt_flags & RTCF_LOCAL);
+}
+
 static bool rpfilter_mt(const struct sk_buff *skb, struct xt_action_param *par)
 {
 	const struct xt_rpfilter_info *info;
@@ -76,7 +82,7 @@ static bool rpfilter_mt(const struct sk_buff *skb, struct xt_action_param *par)
 	info = par->matchinfo;
 	invert = info->flags & XT_RPFILTER_INVERT;
 
-	if (par->in->flags & IFF_LOOPBACK)
+	if (rpfilter_is_local(skb))
 		return true ^ invert;
 
 	iph = ip_hdr(skb);
net/ipv6/netfilter/ip6t_rpfilter.c +7 -1
index 5060d54..e0983f3 100644
@@ -71,6 +71,12 @@ static bool rpfilter_lookup_reverse6(const struct sk_buff *skb,
 	return ret;
 }
 
+static bool rpfilter_is_local(const struct sk_buff *skb)
+{
+	const struct rt6_info *rt = (const void *) skb_dst(skb);
+	return rt && (rt->rt6i_flags & RTF_LOCAL);
+}
+
 static bool rpfilter_mt(const struct sk_buff *skb, struct xt_action_param *par)
 {
 	const struct xt_rpfilter_info *info = par->matchinfo;
@@ -78,7 +84,7 @@ static bool rpfilter_mt(const struct sk_buff *skb, struct xt_action_param *par)
 	struct ipv6hdr *iph;
 	bool invert = info->flags & XT_RPFILTER_INVERT;
 
-	if (par->in->flags & IFF_LOOPBACK)
+	if (rpfilter_is_local(skb))
 		return true ^ invert;
 
 	iph = ipv6_hdr(skb);
Signature · 1 line
1.7.10.4
maintainer
#3 lore raw
In reply to Pablo Neira Ayuso

From: Pablo Neira Ayuso <[email protected]>
Date: Fri, 19 Apr 2013 03:16:00 +0200

Quoted 9 lines

If time allows, please consider pulling the following patchset contains two late Netfilter fixes, they are:

* Skip broadcast/multicast locally generated traffic in the rpfilter, (closes netfilter bugzilla #814), from Florian Westphal.

* Fix missing elements in the listing of ipset bitmap ip,mac set type with timeout support enabled, from Jozsef Kadlecsik.

Quoted 7 lines

The following changes since commit c2d421e171868586939c328dfb91bab840fe4c49:

netfilter: nf_nat: fix race when unloading protocol modules (2013-04-12 11:46:31 +0200)

are available in the git repository at:

git://git.kernel.org/pub/scm/linux/kernel/git/pablo/nf.git master

Pulled, thanks Pablo.