* [-stable-3.8.y 1/9] ipvs: ip_vs_sip_fill_param() BUG: bad check of return value
@ 2013-05-06 23:05 Pablo Neira Ayuso
2013-05-06 23:05 ` [-stable-3.8.y 2/9] netfilter: nf_nat: fix race when unloading protocol modules Pablo Neira Ayuso
` (8 more replies)
0 siblings, 9 replies; 12+ messages in thread
From: Pablo Neira Ayuso @ 2013-05-06 23:05 UTC (permalink / raw)
To: netfilter-devel; +Cc: stable, davem
From: Hans Schillstrom <hans@schillstrom.com>
The reason for this patch is crash in kmemdup
caused by returning from get_callid with uniialized
matchoff and matchlen.
Removing Zero check of matchlen since it's done by ct_sip_get_header()
BUG: unable to handle kernel paging request at ffff880457b5763f
IP: [<ffffffff810df7fc>] kmemdup+0x2e/0x35
PGD 27f6067 PUD 0
Oops: 0000 [#1] PREEMPT SMP
Modules linked in: xt_state xt_helper nf_conntrack_ipv6 nf_defrag_ipv6 ip6table_mangle xt_connmark xt_conntrack ip6_tables nf_conntrack_ftp ip_vs_ftp nf_nat xt_tcpudp iptable_mangle xt_mark ip_tables x_tables ip_vs_rr ip_vs_lblcr ip_vs_pe_sip ip_vs nf_conntrack_sip nf_conntrack bonding igb i2c_algo_bit i2c_core
CPU 5
Pid: 0, comm: swapper/5 Not tainted 3.9.0-rc5+ #5 /S1200KP
RIP: 0010:[<ffffffff810df7fc>] [<ffffffff810df7fc>] kmemdup+0x2e/0x35
RSP: 0018:ffff8803fea03648 EFLAGS: 00010282
RAX: ffff8803d61063e0 RBX: 0000000000000003 RCX: 0000000000000003
RDX: 0000000000000003 RSI: ffff880457b5763f RDI: ffff8803d61063e0
RBP: ffff8803fea03658 R08: 0000000000000008 R09: 0000000000000011
R10: 0000000000000011 R11: 00ffffffff81a8a3 R12: ffff880457b5763f
R13: ffff8803d67f786a R14: ffff8803fea03730 R15: ffffffffa0098e90
FS: 0000000000000000(0000) GS:ffff8803fea00000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: ffff880457b5763f CR3: 0000000001a0c000 CR4: 00000000001407e0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000ffff0ff0 DR7: 0000000000000400
Process swapper/5 (pid: 0, threadinfo ffff8803ee18c000, task ffff8803ee18a480)
Stack:
ffff8803d822a080 000000000000001c ffff8803fea036c8 ffffffffa000937a
ffffffff81f0d8a0 000000038135fdd5 ffff880300000014 ffff880300110000
ffffffff150118ac ffff8803d7e8a000 ffff88031e0118ac 0000000000000000
Call Trace:
<IRQ>
[<ffffffffa000937a>] ip_vs_sip_fill_param+0x13a/0x187 [ip_vs_pe_sip]
[<ffffffffa007b209>] ip_vs_sched_persist+0x2c6/0x9c3 [ip_vs]
[<ffffffff8107dc53>] ? __lock_acquire+0x677/0x1697
[<ffffffff8100972e>] ? native_sched_clock+0x3c/0x7d
[<ffffffff8100972e>] ? native_sched_clock+0x3c/0x7d
[<ffffffff810649bc>] ? sched_clock_cpu+0x43/0xcf
[<ffffffffa007bb1e>] ip_vs_schedule+0x181/0x4ba [ip_vs]
...
[ git cherry-pick f7a1dd6 ]
Signed-off-by: Hans Schillstrom <hans@schillstrom.com>
Acked-by: Julian Anastasov <ja@ssi.bg>
Signed-off-by: Simon Horman <horms@verge.net.au>
Signed-off-by: David S. Miller <davem@davemloft.net>
---
net/netfilter/ipvs/ip_vs_pe_sip.c | 6 +-----
1 file changed, 1 insertion(+), 5 deletions(-)
diff --git a/net/netfilter/ipvs/ip_vs_pe_sip.c b/net/netfilter/ipvs/ip_vs_pe_sip.c
index 12475ef..e5920fb 100644
--- a/net/netfilter/ipvs/ip_vs_pe_sip.c
+++ b/net/netfilter/ipvs/ip_vs_pe_sip.c
@@ -37,14 +37,10 @@ static int get_callid(const char *dptr, unsigned int dataoff,
if (ret > 0)
break;
if (!ret)
- return 0;
+ return -EINVAL;
dataoff += *matchoff;
}
- /* Empty callid is useless */
- if (!*matchlen)
- return -EINVAL;
-
/* Too large is useless */
if (*matchlen > IP_VS_PEDATA_MAXLEN)
return -EINVAL;
--
1.7.10.4
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [-stable-3.8.y 2/9] netfilter: nf_nat: fix race when unloading protocol modules
2013-05-06 23:05 [-stable-3.8.y 1/9] ipvs: ip_vs_sip_fill_param() BUG: bad check of return value Pablo Neira Ayuso
@ 2013-05-06 23:05 ` Pablo Neira Ayuso
2013-05-06 23:05 ` [-stable-3.8.y 3/9] netfilter: ipset: list:set: fix reference counter update Pablo Neira Ayuso
` (7 subsequent siblings)
8 siblings, 0 replies; 12+ messages in thread
From: Pablo Neira Ayuso @ 2013-05-06 23:05 UTC (permalink / raw)
To: netfilter-devel; +Cc: stable, davem
From: Florian Westphal <fw@strlen.de>
following oops was reported:
RIP: 0010:[<ffffffffa03227f2>] [<ffffffffa03227f2>] nf_nat_cleanup_conntrack+0x42/0x70 [nf_nat]
RSP: 0018:ffff880202c63d40 EFLAGS: 00010246
RAX: 0000000000000000 RBX: ffff8801ac7bec28 RCX: ffff8801d0eedbe0
RDX: dead000000200200 RSI: 0000000000000011 RDI: ffffffffa03265b8
[..]
Call Trace:
[..]
[<ffffffffa02febed>] destroy_conntrack+0xbd/0x110 [nf_conntrack]
Happens when a conntrack timeout expires right after first part
of the nat cleanup has completed (bysrc hash removal), but before
part 2 has completed (re-initialization of nat area).
[ destroy callback tries to delete bysrc again ]
Patrick suggested to just remove the affected conntracks -- the
connections won't work properly anyway without nat transformation.
So, lets do that.
Reported-by: CAI Qian <caiqian@redhat.com>
Cc: Patrick McHardy <kaber@trash.net>
Signed-off-by: Florian Westphal <fw@strlen.de>
Acked-by: Patrick McHardy <kaber@trash.net>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
[ git cherry-pick c2d421e ]
---
net/netfilter/nf_nat_core.c | 40 +++++++---------------------------------
1 file changed, 7 insertions(+), 33 deletions(-)
diff --git a/net/netfilter/nf_nat_core.c b/net/netfilter/nf_nat_core.c
index 5f2f910..4bc2aaf 100644
--- a/net/netfilter/nf_nat_core.c
+++ b/net/netfilter/nf_nat_core.c
@@ -468,33 +468,22 @@ EXPORT_SYMBOL_GPL(nf_nat_packet);
struct nf_nat_proto_clean {
u8 l3proto;
u8 l4proto;
- bool hash;
};
-/* Clear NAT section of all conntracks, in case we're loaded again. */
-static int nf_nat_proto_clean(struct nf_conn *i, void *data)
+/* kill conntracks with affected NAT section */
+static int nf_nat_proto_remove(struct nf_conn *i, void *data)
{
const struct nf_nat_proto_clean *clean = data;
struct nf_conn_nat *nat = nfct_nat(i);
if (!nat)
return 0;
- if (!(i->status & IPS_SRC_NAT_DONE))
- return 0;
+
if ((clean->l3proto && nf_ct_l3num(i) != clean->l3proto) ||
(clean->l4proto && nf_ct_protonum(i) != clean->l4proto))
return 0;
- if (clean->hash) {
- spin_lock_bh(&nf_nat_lock);
- hlist_del_rcu(&nat->bysource);
- spin_unlock_bh(&nf_nat_lock);
- } else {
- memset(nat, 0, sizeof(*nat));
- i->status &= ~(IPS_NAT_MASK | IPS_NAT_DONE_MASK |
- IPS_SEQ_ADJUST);
- }
- return 0;
+ return i->status & IPS_NAT_MASK ? 1 : 0;
}
static void nf_nat_l4proto_clean(u8 l3proto, u8 l4proto)
@@ -506,16 +495,8 @@ static void nf_nat_l4proto_clean(u8 l3proto, u8 l4proto)
struct net *net;
rtnl_lock();
- /* Step 1 - remove from bysource hash */
- clean.hash = true;
for_each_net(net)
- nf_ct_iterate_cleanup(net, nf_nat_proto_clean, &clean);
- synchronize_rcu();
-
- /* Step 2 - clean NAT section */
- clean.hash = false;
- for_each_net(net)
- nf_ct_iterate_cleanup(net, nf_nat_proto_clean, &clean);
+ nf_ct_iterate_cleanup(net, nf_nat_proto_remove, &clean);
rtnl_unlock();
}
@@ -527,16 +508,9 @@ static void nf_nat_l3proto_clean(u8 l3proto)
struct net *net;
rtnl_lock();
- /* Step 1 - remove from bysource hash */
- clean.hash = true;
- for_each_net(net)
- nf_ct_iterate_cleanup(net, nf_nat_proto_clean, &clean);
- synchronize_rcu();
- /* Step 2 - clean NAT section */
- clean.hash = false;
for_each_net(net)
- nf_ct_iterate_cleanup(net, nf_nat_proto_clean, &clean);
+ nf_ct_iterate_cleanup(net, nf_nat_proto_remove, &clean);
rtnl_unlock();
}
@@ -774,7 +748,7 @@ static void __net_exit nf_nat_net_exit(struct net *net)
{
struct nf_nat_proto_clean clean = {};
- nf_ct_iterate_cleanup(net, &nf_nat_proto_clean, &clean);
+ nf_ct_iterate_cleanup(net, &nf_nat_proto_remove, &clean);
synchronize_rcu();
nf_ct_free_hashtable(net->ct.nat_bysource, net->ct.nat_htable_size);
}
--
1.7.10.4
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [-stable-3.8.y 3/9] netfilter: ipset: list:set: fix reference counter update
2013-05-06 23:05 [-stable-3.8.y 1/9] ipvs: ip_vs_sip_fill_param() BUG: bad check of return value Pablo Neira Ayuso
2013-05-06 23:05 ` [-stable-3.8.y 2/9] netfilter: nf_nat: fix race when unloading protocol modules Pablo Neira Ayuso
@ 2013-05-06 23:05 ` Pablo Neira Ayuso
2013-05-06 23:05 ` [-stable-3.8.y 4/9] netfilter: nf_ct_sip: don't drop packets with offsets pointing outside the packet Pablo Neira Ayuso
` (6 subsequent siblings)
8 siblings, 0 replies; 12+ messages in thread
From: Pablo Neira Ayuso @ 2013-05-06 23:05 UTC (permalink / raw)
To: netfilter-devel; +Cc: stable, davem
From: Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>
The last element can be replaced or pushed off and in both
cases the reference counter must be updated.
Signed-off-by: Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
[ git cherry-pick 02f815c ]
---
net/netfilter/ipset/ip_set_list_set.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/net/netfilter/ipset/ip_set_list_set.c b/net/netfilter/ipset/ip_set_list_set.c
index 8371c2b..09c744a 100644
--- a/net/netfilter/ipset/ip_set_list_set.c
+++ b/net/netfilter/ipset/ip_set_list_set.c
@@ -174,9 +174,13 @@ list_set_add(struct list_set *map, u32 i, ip_set_id_t id,
{
const struct set_elem *e = list_set_elem(map, i);
- if (i == map->size - 1 && e->id != IPSET_INVALID_ID)
- /* Last element replaced: e.g. add new,before,last */
- ip_set_put_byindex(e->id);
+ if (e->id != IPSET_INVALID_ID) {
+ const struct set_elem *x = list_set_elem(map, map->size - 1);
+
+ /* Last element replaced or pushed off */
+ if (x->id != IPSET_INVALID_ID)
+ ip_set_put_byindex(x->id);
+ }
if (with_timeout(map->timeout))
list_elem_tadd(map, i, id, ip_set_timeout_set(timeout));
else
--
1.7.10.4
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [-stable-3.8.y 4/9] netfilter: nf_ct_sip: don't drop packets with offsets pointing outside the packet
2013-05-06 23:05 [-stable-3.8.y 1/9] ipvs: ip_vs_sip_fill_param() BUG: bad check of return value Pablo Neira Ayuso
2013-05-06 23:05 ` [-stable-3.8.y 2/9] netfilter: nf_nat: fix race when unloading protocol modules Pablo Neira Ayuso
2013-05-06 23:05 ` [-stable-3.8.y 3/9] netfilter: ipset: list:set: fix reference counter update Pablo Neira Ayuso
@ 2013-05-06 23:05 ` Pablo Neira Ayuso
2013-05-06 23:05 ` [-stable-3.8.y 5/9] netfilter: ipset: "Directory not empty" error message Pablo Neira Ayuso
` (5 subsequent siblings)
8 siblings, 0 replies; 12+ messages in thread
From: Pablo Neira Ayuso @ 2013-05-06 23:05 UTC (permalink / raw)
To: netfilter-devel; +Cc: stable, davem
From: Patrick McHardy <kaber@trash.net>
Some Cisco phones create huge messages that are spread over multiple packets.
After calculating the offset of the SIP body, it is validated to be within
the packet and the packet is dropped otherwise. This breaks operation of
these phones. Since connection tracking is supposed to be passive, just let
those packets pass unmodified and untracked.
Signed-off-by: Patrick McHardy <kaber@trash.net>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
[ This patch is a backport of 3a7b21e ]
---
net/netfilter/nf_conntrack_sip.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/netfilter/nf_conntrack_sip.c b/net/netfilter/nf_conntrack_sip.c
index df8f4f2..b4e0d1c 100644
--- a/net/netfilter/nf_conntrack_sip.c
+++ b/net/netfilter/nf_conntrack_sip.c
@@ -1547,7 +1547,7 @@ static int sip_help_tcp(struct sk_buff *skb, unsigned int protoff,
msglen = origlen = end - dptr;
if (msglen > datalen)
- return NF_DROP;
+ return NF_ACCEPT;
ret = process_sip_msg(skb, ct, protoff, dataoff,
&dptr, &msglen);
--
1.7.10.4
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [-stable-3.8.y 5/9] netfilter: ipset: "Directory not empty" error message
2013-05-06 23:05 [-stable-3.8.y 1/9] ipvs: ip_vs_sip_fill_param() BUG: bad check of return value Pablo Neira Ayuso
` (2 preceding siblings ...)
2013-05-06 23:05 ` [-stable-3.8.y 4/9] netfilter: nf_ct_sip: don't drop packets with offsets pointing outside the packet Pablo Neira Ayuso
@ 2013-05-06 23:05 ` Pablo Neira Ayuso
2013-05-06 23:05 ` [-stable-3.8.y 6/9] netfilter: nf_ct_helper: don't discard helper if it is actually the same Pablo Neira Ayuso
` (4 subsequent siblings)
8 siblings, 0 replies; 12+ messages in thread
From: Pablo Neira Ayuso @ 2013-05-06 23:05 UTC (permalink / raw)
To: netfilter-devel; +Cc: stable, davem
From: Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>
When an entry flagged with "nomatch" was tested by ipset, it
returned the error message "Kernel error received:
Directory not empty" instead of "<element> is NOT in set <setname>"
(reported by John Brendler).
The internal error code was not properly transformed before returning
to userspace, fixed.
Signed-off-by: Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
[ git cherry-pick dd82088 ]
---
net/netfilter/ipset/ip_set_core.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/net/netfilter/ipset/ip_set_core.c b/net/netfilter/ipset/ip_set_core.c
index 6d6d8f2..38ca630 100644
--- a/net/netfilter/ipset/ip_set_core.c
+++ b/net/netfilter/ipset/ip_set_core.c
@@ -1470,7 +1470,8 @@ ip_set_utest(struct sock *ctnl, struct sk_buff *skb,
if (ret == -EAGAIN)
ret = 1;
- return ret < 0 ? ret : ret > 0 ? 0 : -IPSET_ERR_EXIST;
+ return (ret < 0 && ret != -ENOTEMPTY) ? ret :
+ ret > 0 ? 0 : -IPSET_ERR_EXIST;
}
/* Get headed data of a set */
--
1.7.10.4
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [-stable-3.8.y 6/9] netfilter: nf_ct_helper: don't discard helper if it is actually the same
2013-05-06 23:05 [-stable-3.8.y 1/9] ipvs: ip_vs_sip_fill_param() BUG: bad check of return value Pablo Neira Ayuso
` (3 preceding siblings ...)
2013-05-06 23:05 ` [-stable-3.8.y 5/9] netfilter: ipset: "Directory not empty" error message Pablo Neira Ayuso
@ 2013-05-06 23:05 ` Pablo Neira Ayuso
2013-05-06 23:05 ` [-stable-3.8.y 7/9] netfilter: ctnetlink: don't permit ct creation with random tuple Pablo Neira Ayuso
` (3 subsequent siblings)
8 siblings, 0 replies; 12+ messages in thread
From: Pablo Neira Ayuso @ 2013-05-06 23:05 UTC (permalink / raw)
To: netfilter-devel; +Cc: stable, davem
From: Florian Westphal <fw@strlen.de>
commit (32f5376 netfilter: nf_ct_helper: disable automatic helper
re-assignment of different type) broke transparent proxy scenarios.
For example, initial helper lookup might yield "ftp" (dport 21),
while re-lookup after REDIRECT yields "ftp-2121".
This causes the autoassign code to toss the ftp helper, even
though these are just different instances of the same helper.
Change the test to check for the helper function address instead
of the helper address, as suggested by Pablo.
Signed-off-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Pablo Neira Ayuso <pablo@gnumonks.org>
[ git cherry-pick 6e2f0aa ]
---
net/netfilter/nf_conntrack_helper.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/net/netfilter/nf_conntrack_helper.c b/net/netfilter/nf_conntrack_helper.c
index 884f2b3..91527d5 100644
--- a/net/netfilter/nf_conntrack_helper.c
+++ b/net/netfilter/nf_conntrack_helper.c
@@ -236,7 +236,9 @@ int __nf_ct_try_assign_helper(struct nf_conn *ct, struct nf_conn *tmpl,
/* We only allow helper re-assignment of the same sort since
* we cannot reallocate the helper extension area.
*/
- if (help->helper != helper) {
+ struct nf_conntrack_helper *tmp = rcu_dereference(help->helper);
+
+ if (tmp && tmp->help != helper->help) {
RCU_INIT_POINTER(help->helper, NULL);
goto out;
}
--
1.7.10.4
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [-stable-3.8.y 7/9] netfilter: ctnetlink: don't permit ct creation with random tuple
2013-05-06 23:05 [-stable-3.8.y 1/9] ipvs: ip_vs_sip_fill_param() BUG: bad check of return value Pablo Neira Ayuso
` (4 preceding siblings ...)
2013-05-06 23:05 ` [-stable-3.8.y 6/9] netfilter: nf_ct_helper: don't discard helper if it is actually the same Pablo Neira Ayuso
@ 2013-05-06 23:05 ` Pablo Neira Ayuso
2013-05-06 23:05 ` [-stable-3.8.y 8/9] netfilter: xt_rpfilter: skip locally generated broadcast/multicast, too Pablo Neira Ayuso
` (2 subsequent siblings)
8 siblings, 0 replies; 12+ messages in thread
From: Pablo Neira Ayuso @ 2013-05-06 23:05 UTC (permalink / raw)
To: netfilter-devel; +Cc: stable, davem
From: Florian Westphal <fw@strlen.de>
Userspace can cause kernel panic by not specifying orig/reply
tuple: kernel will create a tuple with random stack values.
Problem is that tuple.dst.dir will be random, too, which
causes nf_ct_tuplehash_to_ctrack() to return garbage.
Signed-off-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Pablo Neira Ayuso <pablo@gnumonks.org>
[ git cherry-pick 442fad9 ]
---
net/netfilter/nf_conntrack_netlink.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/net/netfilter/nf_conntrack_netlink.c b/net/netfilter/nf_conntrack_netlink.c
index 627b0e5..a081915 100644
--- a/net/netfilter/nf_conntrack_netlink.c
+++ b/net/netfilter/nf_conntrack_netlink.c
@@ -1705,6 +1705,9 @@ ctnetlink_new_conntrack(struct sock *ctnl, struct sk_buff *skb,
if (nlh->nlmsg_flags & NLM_F_CREATE) {
enum ip_conntrack_events events;
+ if (!cda[CTA_TUPLE_ORIG] || !cda[CTA_TUPLE_REPLY])
+ return -EINVAL;
+
ct = ctnetlink_create_conntrack(net, zone, cda, &otuple,
&rtuple, u3);
if (IS_ERR(ct))
--
1.7.10.4
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [-stable-3.8.y 8/9] netfilter: xt_rpfilter: skip locally generated broadcast/multicast, too
2013-05-06 23:05 [-stable-3.8.y 1/9] ipvs: ip_vs_sip_fill_param() BUG: bad check of return value Pablo Neira Ayuso
` (5 preceding siblings ...)
2013-05-06 23:05 ` [-stable-3.8.y 7/9] netfilter: ctnetlink: don't permit ct creation with random tuple Pablo Neira Ayuso
@ 2013-05-06 23:05 ` Pablo Neira Ayuso
2013-05-06 23:05 ` [-stable-3.8.y 9/9] netfilter: ip6t_NPT: Fix translation for non-multiple of 32 prefix lengths Pablo Neira Ayuso
2013-05-08 22:36 ` [-stable-3.8.y 1/9] ipvs: ip_vs_sip_fill_param() BUG: bad check of return value Greg KH
8 siblings, 0 replies; 12+ messages in thread
From: Pablo Neira Ayuso @ 2013-05-06 23:05 UTC (permalink / raw)
To: netfilter-devel; +Cc: stable, davem
From: Florian Westphal <fw@strlen.de>
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.
Signed-off-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
[ git cherry-pick f83a7ea ]
---
net/ipv4/netfilter/ipt_rpfilter.c | 8 +++++++-
net/ipv6/netfilter/ip6t_rpfilter.c | 8 +++++++-
2 files changed, 14 insertions(+), 2 deletions(-)
diff --git a/net/ipv4/netfilter/ipt_rpfilter.c b/net/ipv4/netfilter/ipt_rpfilter.c
index c301300..c49dcd0 100644
--- a/net/ipv4/netfilter/ipt_rpfilter.c
+++ b/net/ipv4/netfilter/ipt_rpfilter.c
@@ -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);
diff --git a/net/ipv6/netfilter/ip6t_rpfilter.c b/net/ipv6/netfilter/ip6t_rpfilter.c
index 5060d54..e0983f3 100644
--- a/net/ipv6/netfilter/ip6t_rpfilter.c
+++ b/net/ipv6/netfilter/ip6t_rpfilter.c
@@ -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);
--
1.7.10.4
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [-stable-3.8.y 9/9] netfilter: ip6t_NPT: Fix translation for non-multiple of 32 prefix lengths
2013-05-06 23:05 [-stable-3.8.y 1/9] ipvs: ip_vs_sip_fill_param() BUG: bad check of return value Pablo Neira Ayuso
` (6 preceding siblings ...)
2013-05-06 23:05 ` [-stable-3.8.y 8/9] netfilter: xt_rpfilter: skip locally generated broadcast/multicast, too Pablo Neira Ayuso
@ 2013-05-06 23:05 ` Pablo Neira Ayuso
2013-05-08 22:36 ` [-stable-3.8.y 1/9] ipvs: ip_vs_sip_fill_param() BUG: bad check of return value Greg KH
8 siblings, 0 replies; 12+ messages in thread
From: Pablo Neira Ayuso @ 2013-05-06 23:05 UTC (permalink / raw)
To: netfilter-devel; +Cc: stable, davem
From: Matthias Schiffer <mschiffer@universe-factory.net>
The bitmask used for the prefix mangling was being calculated
incorrectly, leading to the wrong part of the address being replaced
when the prefix length wasn't a multiple of 32.
Signed-off-by: Matthias Schiffer <mschiffer@universe-factory.net>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
[ git cherry-pick 906b1c3 ]
---
net/ipv6/netfilter/ip6t_NPT.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/ipv6/netfilter/ip6t_NPT.c b/net/ipv6/netfilter/ip6t_NPT.c
index 83acc14..0ea43c7 100644
--- a/net/ipv6/netfilter/ip6t_NPT.c
+++ b/net/ipv6/netfilter/ip6t_NPT.c
@@ -57,7 +57,7 @@ static bool ip6t_npt_map_pfx(const struct ip6t_npt_tginfo *npt,
if (pfx_len - i >= 32)
mask = 0;
else
- mask = htonl(~((1 << (pfx_len - i)) - 1));
+ mask = htonl((1 << (i - pfx_len + 32)) - 1);
idx = i / 32;
addr->s6_addr32[idx] &= mask;
--
1.7.10.4
^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [-stable-3.8.y 1/9] ipvs: ip_vs_sip_fill_param() BUG: bad check of return value
2013-05-06 23:05 [-stable-3.8.y 1/9] ipvs: ip_vs_sip_fill_param() BUG: bad check of return value Pablo Neira Ayuso
` (7 preceding siblings ...)
2013-05-06 23:05 ` [-stable-3.8.y 9/9] netfilter: ip6t_NPT: Fix translation for non-multiple of 32 prefix lengths Pablo Neira Ayuso
@ 2013-05-08 22:36 ` Greg KH
2013-05-08 23:53 ` Pablo Neira Ayuso
8 siblings, 1 reply; 12+ messages in thread
From: Greg KH @ 2013-05-08 22:36 UTC (permalink / raw)
To: Pablo Neira Ayuso; +Cc: netfilter-devel, stable, davem
On Tue, May 07, 2013 at 01:05:20AM +0200, Pablo Neira Ayuso wrote:
> From: Hans Schillstrom <hans@schillstrom.com>
>
> The reason for this patch is crash in kmemdup
> caused by returning from get_callid with uniialized
> matchoff and matchlen.
>
> Removing Zero check of matchlen since it's done by ct_sip_get_header()
>
> BUG: unable to handle kernel paging request at ffff880457b5763f
> IP: [<ffffffff810df7fc>] kmemdup+0x2e/0x35
> PGD 27f6067 PUD 0
> Oops: 0000 [#1] PREEMPT SMP
> Modules linked in: xt_state xt_helper nf_conntrack_ipv6 nf_defrag_ipv6 ip6table_mangle xt_connmark xt_conntrack ip6_tables nf_conntrack_ftp ip_vs_ftp nf_nat xt_tcpudp iptable_mangle xt_mark ip_tables x_tables ip_vs_rr ip_vs_lblcr ip_vs_pe_sip ip_vs nf_conntrack_sip nf_conntrack bonding igb i2c_algo_bit i2c_core
> CPU 5
> Pid: 0, comm: swapper/5 Not tainted 3.9.0-rc5+ #5 /S1200KP
> RIP: 0010:[<ffffffff810df7fc>] [<ffffffff810df7fc>] kmemdup+0x2e/0x35
> RSP: 0018:ffff8803fea03648 EFLAGS: 00010282
> RAX: ffff8803d61063e0 RBX: 0000000000000003 RCX: 0000000000000003
> RDX: 0000000000000003 RSI: ffff880457b5763f RDI: ffff8803d61063e0
> RBP: ffff8803fea03658 R08: 0000000000000008 R09: 0000000000000011
> R10: 0000000000000011 R11: 00ffffffff81a8a3 R12: ffff880457b5763f
> R13: ffff8803d67f786a R14: ffff8803fea03730 R15: ffffffffa0098e90
> FS: 0000000000000000(0000) GS:ffff8803fea00000(0000) knlGS:0000000000000000
> CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
> CR2: ffff880457b5763f CR3: 0000000001a0c000 CR4: 00000000001407e0
> DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
> DR3: 0000000000000000 DR6: 00000000ffff0ff0 DR7: 0000000000000400
> Process swapper/5 (pid: 0, threadinfo ffff8803ee18c000, task ffff8803ee18a480)
> Stack:
> ffff8803d822a080 000000000000001c ffff8803fea036c8 ffffffffa000937a
> ffffffff81f0d8a0 000000038135fdd5 ffff880300000014 ffff880300110000
> ffffffff150118ac ffff8803d7e8a000 ffff88031e0118ac 0000000000000000
> Call Trace:
> <IRQ>
>
> [<ffffffffa000937a>] ip_vs_sip_fill_param+0x13a/0x187 [ip_vs_pe_sip]
> [<ffffffffa007b209>] ip_vs_sched_persist+0x2c6/0x9c3 [ip_vs]
> [<ffffffff8107dc53>] ? __lock_acquire+0x677/0x1697
> [<ffffffff8100972e>] ? native_sched_clock+0x3c/0x7d
> [<ffffffff8100972e>] ? native_sched_clock+0x3c/0x7d
> [<ffffffff810649bc>] ? sched_clock_cpu+0x43/0xcf
> [<ffffffffa007bb1e>] ip_vs_schedule+0x181/0x4ba [ip_vs]
> ...
>
> [ git cherry-pick f7a1dd6 ]
>
> Signed-off-by: Hans Schillstrom <hans@schillstrom.com>
> Acked-by: Julian Anastasov <ja@ssi.bg>
> Signed-off-by: Simon Horman <horms@verge.net.au>
> Signed-off-by: David S. Miller <davem@davemloft.net>
This should also go into other stable kernel releases as well, right?
thanks,
greg k-h
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [-stable-3.8.y 1/9] ipvs: ip_vs_sip_fill_param() BUG: bad check of return value
2013-05-08 22:36 ` [-stable-3.8.y 1/9] ipvs: ip_vs_sip_fill_param() BUG: bad check of return value Greg KH
@ 2013-05-08 23:53 ` Pablo Neira Ayuso
2013-05-09 20:38 ` Greg KH
0 siblings, 1 reply; 12+ messages in thread
From: Pablo Neira Ayuso @ 2013-05-08 23:53 UTC (permalink / raw)
To: Greg KH; +Cc: netfilter-devel, stable, davem
On Wed, May 08, 2013 at 03:36:42PM -0700, Greg KH wrote:
[...]
> This should also go into other stable kernel releases as well, right?
Yes, that's a good idea. I was going to send you specific batches per
branch though.
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [-stable-3.8.y 1/9] ipvs: ip_vs_sip_fill_param() BUG: bad check of return value
2013-05-08 23:53 ` Pablo Neira Ayuso
@ 2013-05-09 20:38 ` Greg KH
0 siblings, 0 replies; 12+ messages in thread
From: Greg KH @ 2013-05-09 20:38 UTC (permalink / raw)
To: Pablo Neira Ayuso; +Cc: netfilter-devel, stable, davem
On Thu, May 09, 2013 at 01:53:02AM +0200, Pablo Neira Ayuso wrote:
> On Wed, May 08, 2013 at 03:36:42PM -0700, Greg KH wrote:
> [...]
> > This should also go into other stable kernel releases as well, right?
>
> Yes, that's a good idea. I was going to send you specific batches per
> branch though.
Ok, you can still do that, no objection from me.
thanks,
greg k-h
^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2013-05-09 20:38 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-05-06 23:05 [-stable-3.8.y 1/9] ipvs: ip_vs_sip_fill_param() BUG: bad check of return value Pablo Neira Ayuso
2013-05-06 23:05 ` [-stable-3.8.y 2/9] netfilter: nf_nat: fix race when unloading protocol modules Pablo Neira Ayuso
2013-05-06 23:05 ` [-stable-3.8.y 3/9] netfilter: ipset: list:set: fix reference counter update Pablo Neira Ayuso
2013-05-06 23:05 ` [-stable-3.8.y 4/9] netfilter: nf_ct_sip: don't drop packets with offsets pointing outside the packet Pablo Neira Ayuso
2013-05-06 23:05 ` [-stable-3.8.y 5/9] netfilter: ipset: "Directory not empty" error message Pablo Neira Ayuso
2013-05-06 23:05 ` [-stable-3.8.y 6/9] netfilter: nf_ct_helper: don't discard helper if it is actually the same Pablo Neira Ayuso
2013-05-06 23:05 ` [-stable-3.8.y 7/9] netfilter: ctnetlink: don't permit ct creation with random tuple Pablo Neira Ayuso
2013-05-06 23:05 ` [-stable-3.8.y 8/9] netfilter: xt_rpfilter: skip locally generated broadcast/multicast, too Pablo Neira Ayuso
2013-05-06 23:05 ` [-stable-3.8.y 9/9] netfilter: ip6t_NPT: Fix translation for non-multiple of 32 prefix lengths Pablo Neira Ayuso
2013-05-08 22:36 ` [-stable-3.8.y 1/9] ipvs: ip_vs_sip_fill_param() BUG: bad check of return value Greg KH
2013-05-08 23:53 ` Pablo Neira Ayuso
2013-05-09 20:38 ` Greg KH
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).