netfilter updates for 3.6-rc
Subsystems (4)
[email protected]
maintainercover netfilter updates for 3.6-rc
From: Pablo Neira Ayuso <[email protected]>
Hi David,
The following patchset contain fixes for your net tree, they are:
* Fix wrong type for NFULA_HWTYPE attribute, this was introduced while removing the NLA_PUT macro, from Patrick McHardy.
* Three fixes that spot incorrect return values in the initialization path of several Netfilter modules, from Julia Lawall.
* Fix crash in the SIP helper if we hit EBUSY while adding the RTCP expectation, from myself.
* Fix racy timer handling in case conntrackd is running in reliable event mode, also from myself.
You can pull these changes from:
git://1984.lsi.us.es/nf master
BTW, please merge net to net-next after this so I can resolve the conflict between the SIP helper and NAT IPv6 changes from Patrick, which is scheduled for net-next.
Thanks!
Julia Lawall (3):
ipvs: fix error return code
netfilter: ctnetlink: fix error return code in init path
netfilter: nfnetlink_log: fix error return code in init path
Pablo Neira Ayuso (2):
netfilter: nf_nat_sip: fix incorrect handling of EBUSY for RTCP expectation
netfilter: nf_conntrack: fix racy timer handling with reliable events
Patrick McHardy (1):
netfilter: nfnetlink_log: fix NLA_PUT macro removal bug
include/net/netfilter/nf_conntrack_ecache.h | 1 + net/ipv4/netfilter/nf_nat_sip.c | 5 ++++- net/netfilter/ipvs/ip_vs_ctl.c | 4 +++- net/netfilter/nf_conntrack_core.c | 16 +++++++++++----- net/netfilter/nf_conntrack_netlink.c | 3 ++- net/netfilter/nfnetlink_log.c | 6 ++++-- 6 files changed, 25 insertions(+), 10 deletions(-)
Signature · 1 line
1.7.10.4
[email protected]
maintainerPATCH 1/6 netfilter: nfnetlink_log: fix NLA_PUT macro removal bug
From: Patrick McHardy <[email protected]>
Commit 1db20a52 (nfnetlink_log: Stop using NLA_PUT*().) incorrectly converted a NLA_PUT_BE16 macro to nla_put_be32() in nfnetlink_log:
- NLA_PUT_BE16(inst->skb, NFULA_HWTYPE, htons(skb->dev->type));
+ if (nla_put_be32(inst->skb, NFULA_HWTYPE, htons(skb->dev->type))
--- net/netfilter/nfnetlink_log.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/netfilter/nfnetlink_log.c +1 -1
@@ -480,7 +480,7 @@ __build_packet_message(struct nfulnl_instance *inst, } if (indev && skb_mac_header_was_set(skb)) { - if (nla_put_be32(inst->skb, NFULA_HWTYPE, htons(skb->dev->type)) || + if (nla_put_be16(inst->skb, NFULA_HWTYPE, htons(skb->dev->type)) || nla_put_be16(inst->skb, NFULA_HWLEN, htons(skb->dev->hard_header_len)) || nla_put(inst->skb, NFULA_HWHEADER, skb->dev->hard_header_len,
Signature · 1 line
1.7.10.4
[email protected]
maintainerPATCH 2/6 ipvs: fix error return code
In reply to [email protected]From: Julia Lawall <[email protected]>
Initialize return variable before exiting on an error path.
A simplified version of the semantic match that finds this problem is as
follows: (http://coccinelle.lip6.fr/)
// <smpl>
(
if@p1 (\(ret < 0\|ret != 0\))
{ ... return ret; }
|
ret@p1 = 0
)
... when != ret = e1
when != &ret
*if(...)
{
... when != ret = e2
when forall
return ret;
}
// </smpl>
--- net/netfilter/ipvs/ip_vs_ctl.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
net/netfilter/ipvs/ip_vs_ctl.c +3 -1
@@ -1171,8 +1171,10 @@ ip_vs_add_service(struct net *net, struct ip_vs_service_user_kern *u, goto out_err; } svc->stats.cpustats = alloc_percpu(struct ip_vs_cpu_stats); -if (!svc->stats.cpustats) +if (!svc->stats.cpustats) { + ret = -ENOMEM ; goto out_err; + }/* I'm the first user of the service */ atomic_set (&svc->usecnt,0 );
Signature · 1 line
1.7.10.4
[email protected]
maintainerPATCH 3/6 netfilter: ctnetlink: fix error return code in init path
In reply to [email protected]From: Julia Lawall <[email protected]>
Initialize return variable before exiting on an error path.
A simplified version of the semantic match that finds this problem is as
follows: (http://coccinelle.lip6.fr/)
// <smpl>
(
if@p1 (\(ret < 0\|ret != 0\))
{ ... return ret; }
|
ret@p1 = 0
)
... when != ret = e1
when != &ret
*if(...)
{
... when != ret = e2
when forall
return ret;
}
// </smpl>
--- net/netfilter/nf_conntrack_netlink.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
net/netfilter/nf_conntrack_netlink.c +2 -1
@@ -2790,7 +2790,8 @@ static int __init ctnetlink_init(void) goto err_unreg_subsys; } -if (register_pernet_subsys (&ctnetlink_net_ops)) { + ret =register_pernet_subsys (&ctnetlink_net_ops); +if (ret <0 ) {pr_err ("ctnetlink_init: cannot register pernet operations\n" ); goto err_unreg_exp_subsys; }
Signature · 1 line
1.7.10.4
[email protected]
maintainerPATCH 4/6 netfilter: nfnetlink_log: fix error return code in init path
In reply to [email protected]From: Julia Lawall <[email protected]>
Initialize return variable before exiting on an error path.
A simplified version of the semantic match that finds this problem is as
follows: (http://coccinelle.lip6.fr/)
// <smpl>
(
if@p1 (\(ret < 0\|ret != 0\))
{ ... return ret; }
|
ret@p1 = 0
)
... when != ret = e1
when != &ret
*if(...)
{
... when != ret = e2
when forall
return ret;
}
// </smpl>
--- net/netfilter/nfnetlink_log.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
net/netfilter/nfnetlink_log.c +3 -1
@@ -996,8 +996,10 @@ static int __init nfnetlink_log_init(void)#ifdef CONFIG_PROC_FS if (!proc_create ("nfnetlink_log" ,0440 , - proc_net_netfilter, &nful_file_ops)) + proc_net_netfilter, &nful_file_ops)) { + status = -ENOMEM ; goto cleanup_logger; + }#endif return status;
Signature · 1 line
1.7.10.4
[email protected]
maintainerPATCH 5/6 netfilter: nf_nat_sip: fix incorrect handling of EBUSY for RTCP expectation
In reply to [email protected]From: Pablo Neira Ayuso <[email protected]>
We're hitting bug while trying to reinsert an already existing expectation:
kernel BUG at kernel/timer.c:895!
invalid opcode: 0000 [#1] SMP
[...]
Call Trace: <IRQ> [<ffffffffa0069563>] nf_ct_expect_related_report+0x4a0/0x57a [nf_conntrack] [<ffffffff812d423a>] ? in4_pton+0x72/0x131 [<ffffffffa00ca69e>] ip_nat_sdp_media+0xeb/0x185 [nf_nat_sip] [<ffffffffa00b5b9b>] set_expected_rtp_rtcp+0x32d/0x39b [nf_conntrack_sip] [<ffffffffa00b5f15>] process_sdp+0x30c/0x3ec [nf_conntrack_sip] [<ffffffff8103f1eb>] ? irq_exit+0x9a/0x9c [<ffffffffa00ca738>] ? ip_nat_sdp_media+0x185/0x185 [nf_nat_sip]
We have to remove the RTP expectation if the RTCP expectation hits EBUSY since we keep trying with other ports until we succeed.
--- net/ipv4/netfilter/nf_nat_sip.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
net/ipv4/netfilter/nf_nat_sip.c +4 -1
@@ -502,7 +502,10 @@ static unsigned int ip_nat_sdp_media(struct sk_buff *skb, unsigned int dataoff, ret =nf_ct_expect_related (rtcp_exp);if (ret ==0 )break ; -else if (ret != -EBUSY ) { +else if (ret == -EBUSY ) { +nf_ct_unexpect_related (rtp_exp); +continue ; + }else if (ret <0 ) {nf_ct_unexpect_related (rtp_exp); port =0 ;break ;
Signature · 1 line
1.7.10.4
[email protected]
maintainerPATCH 6/6 netfilter: nf_conntrack: fix racy timer handling with reliable events
In reply to [email protected]From: Pablo Neira Ayuso <[email protected]>
Existing code assumes that del_timer returns true for alive conntrack entries. However, this is not true if reliable events are enabled. In that case, del_timer may return true for entries that were just inserted in the dying list. Note that packets / ctnetlink may hold references to conntrack entries that were just inserted to such list.
This patch fixes the issue by adding an independent timer for event delivery. This increases the size of the ecache extension. Still we can revisit this later and use variable size extensions to allocate this area on demand.
--- include/net/netfilter/nf_conntrack_ecache.h | 1 + net/netfilter/nf_conntrack_core.c | 16 +++++++++++----- 2 files changed, 12 insertions(+), 5 deletions(-)
include/net/netfilter/nf_conntrack_ecache.h +1 -0
@@ -18,6 +18,7 @@ struct nf_conntrack_ecache {u16 ctmask;/* bitmask of ct events to be delivered */ u16 expmask;/* bitmask of expect events to be delivered */ u32 pid;/* netlink pid of destroyer */ +struct timer_list timeout; }; static inline struct nf_conntrack_ecache *
net/netfilter/nf_conntrack_core.c +11 -5
@@ -249,12 +249,15 @@ static void death_by_event(unsigned long ul_conntrack) {struct nf_conn *ct = (void *)ul_conntrack;struct net *net =nf_ct_net (ct); +struct nf_conntrack_ecache *ecache =nf_ct_ecache_find (ct); + +BUG_ON (ecache ==NULL );if (nf_conntrack_event (IPCT_DESTROY , ct) <0 ) {/* bad luck, let's retry again */ - ct->timeout.expires = jiffies + + ecache->timeout.expires = jiffies + (random32 () % net->ct.sysctl_events_retry_timeout); -add_timer (&ct->timeout); +add_timer (&ecache->timeout);return ; }/* we've got the event delivered, now it's dying */
@@ -268,6 +271,9 @@ static void death_by_event(unsigned long ul_conntrack)void nf_ct_insert_dying_list (struct nf_conn *ct) {struct net *net =nf_ct_net (ct); +struct nf_conntrack_ecache *ecache =nf_ct_ecache_find (ct); + +BUG_ON (ecache ==NULL );/* add this conntrack to the dying list */ spin_lock_bh (&nf_conntrack_lock);
@@ -275,10 +281,10 @@ void nf_ct_insert_dying_list(struct nf_conn *ct) &net->ct.dying);spin_unlock_bh (&nf_conntrack_lock);/* set a new timer to retry event delivery */ -setup_timer (&ct->timeout, death_by_event, (unsigned long )ct); - ct->timeout.expires = jiffies + +setup_timer (&ecache->timeout, death_by_event, (unsigned long )ct); + ecache->timeout.expires = jiffies + (random32 () % net->ct.sysctl_events_retry_timeout); -add_timer (&ct->timeout); +add_timer (&ecache->timeout); }EXPORT_SYMBOL_GPL (nf_ct_insert_dying_list);
Signature · 1 line
1.7.10.4
David Miller
maintainerFrom: [email protected]
Date: Fri, 31 Aug 2012 16:03:03 +0200
Quoted 3 lines
You can pull these changes from:
git://1984.lsi.us.es/nfmaster
Pulled.
Quoted 3 lines
BTW, please merge net to net-next after this so I can resolve the conflict between the SIP helper and NAT IPv6 changes from Patrick, which is scheduled for net-next.
Done.