netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] late fixes for netfilter's ctnetlink
@ 2011-12-24 18:52 pablo
  2011-12-24 18:52 ` [PATCH 1/2] netfilter: ctnetlink: fix return value of ctnetlink_get_expect() pablo
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: pablo @ 2011-12-24 18:52 UTC (permalink / raw)
  To: netfilter-devel; +Cc: davem, netdev

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

Hi Dave,

These are a couple of late fixes for ctnetlink.

You can pull them from:

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

Please, apply!
Thanks.

Pablo Neira Ayuso (2):
  netfilter: ctnetlink: fix return value of ctnetlink_get_expect()
  netfilter: ctnetlink: fix scheduling while atomic if helper is
    autoloaded

 net/netfilter/nf_conntrack_netlink.c |   18 +++++++++++++-----
 1 files changed, 13 insertions(+), 5 deletions(-)

-- 
1.7.2.5


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

* [PATCH 1/2] netfilter: ctnetlink: fix return value of ctnetlink_get_expect()
  2011-12-24 18:52 [PATCH 0/2] late fixes for netfilter's ctnetlink pablo
@ 2011-12-24 18:52 ` pablo
  2011-12-24 18:52 ` [PATCH 2/2] netfilter: ctnetlink: fix scheduling while atomic if helper is autoloaded pablo
  2011-12-24 21:11 ` [PATCH 0/2] late fixes for netfilter's ctnetlink David Miller
  2 siblings, 0 replies; 4+ messages in thread
From: pablo @ 2011-12-24 18:52 UTC (permalink / raw)
  To: netfilter-devel; +Cc: davem, netdev

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

This fixes one bogus error that is returned to user-space:

libnetfilter_conntrack/utils# ./expect_get
TEST: get expectation (-1)(Unknown error 18446744073709551504)

This patch includes the correct handling for EAGAIN (nfnetlink
uses this error value to restart the operation after module
auto-loading).

Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
---
 net/netfilter/nf_conntrack_netlink.c |   15 ++++++++++-----
 1 files changed, 10 insertions(+), 5 deletions(-)

diff --git a/net/netfilter/nf_conntrack_netlink.c b/net/netfilter/nf_conntrack_netlink.c
index ef21b22..3d7ea7a 100644
--- a/net/netfilter/nf_conntrack_netlink.c
+++ b/net/netfilter/nf_conntrack_netlink.c
@@ -1869,25 +1869,30 @@ ctnetlink_get_expect(struct sock *ctnl, struct sk_buff *skb,
 
 	err = -ENOMEM;
 	skb2 = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
-	if (skb2 == NULL)
+	if (skb2 == NULL) {
+		nf_ct_expect_put(exp);
 		goto out;
+	}
 
 	rcu_read_lock();
 	err = ctnetlink_exp_fill_info(skb2, NETLINK_CB(skb).pid,
 				      nlh->nlmsg_seq, IPCTNL_MSG_EXP_NEW, exp);
 	rcu_read_unlock();
+	nf_ct_expect_put(exp);
 	if (err <= 0)
 		goto free;
 
-	nf_ct_expect_put(exp);
+	err = netlink_unicast(ctnl, skb2, NETLINK_CB(skb).pid, MSG_DONTWAIT);
+	if (err < 0)
+		goto out;
 
-	return netlink_unicast(ctnl, skb2, NETLINK_CB(skb).pid, MSG_DONTWAIT);
+	return 0;
 
 free:
 	kfree_skb(skb2);
 out:
-	nf_ct_expect_put(exp);
-	return err;
+	/* this avoids a loop in nfnetlink. */
+	return err == -EAGAIN ? -ENOBUFS : err;
 }
 
 static int
-- 
1.7.2.5


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

* [PATCH 2/2] netfilter: ctnetlink: fix scheduling while atomic if helper is autoloaded
  2011-12-24 18:52 [PATCH 0/2] late fixes for netfilter's ctnetlink pablo
  2011-12-24 18:52 ` [PATCH 1/2] netfilter: ctnetlink: fix return value of ctnetlink_get_expect() pablo
@ 2011-12-24 18:52 ` pablo
  2011-12-24 21:11 ` [PATCH 0/2] late fixes for netfilter's ctnetlink David Miller
  2 siblings, 0 replies; 4+ messages in thread
From: pablo @ 2011-12-24 18:52 UTC (permalink / raw)
  To: netfilter-devel; +Cc: davem, netdev

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

This patch fixes one scheduling while atomic error:

[  385.565186] ctnetlink v0.93: registering with nfnetlink.
[  385.565349] BUG: scheduling while atomic: lt-expect_creat/16163/0x00000200

It can be triggered with utils/expect_create included in
libnetfilter_conntrack if the FTP helper is not loaded.

Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
---
 net/netfilter/nf_conntrack_netlink.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/net/netfilter/nf_conntrack_netlink.c b/net/netfilter/nf_conntrack_netlink.c
index 3d7ea7a..b697777 100644
--- a/net/netfilter/nf_conntrack_netlink.c
+++ b/net/netfilter/nf_conntrack_netlink.c
@@ -1358,12 +1358,15 @@ ctnetlink_create_conntrack(struct net *net, u16 zone,
 						    nf_ct_protonum(ct));
 		if (helper == NULL) {
 			rcu_read_unlock();
+			spin_unlock_bh(&nf_conntrack_lock);
 #ifdef CONFIG_MODULES
 			if (request_module("nfct-helper-%s", helpname) < 0) {
+				spin_lock_bh(&nf_conntrack_lock);
 				err = -EOPNOTSUPP;
 				goto err1;
 			}
 
+			spin_lock_bh(&nf_conntrack_lock);
 			rcu_read_lock();
 			helper = __nf_conntrack_helper_find(helpname,
 							    nf_ct_l3num(ct),
-- 
1.7.2.5


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

* Re: [PATCH 0/2] late fixes for netfilter's ctnetlink
  2011-12-24 18:52 [PATCH 0/2] late fixes for netfilter's ctnetlink pablo
  2011-12-24 18:52 ` [PATCH 1/2] netfilter: ctnetlink: fix return value of ctnetlink_get_expect() pablo
  2011-12-24 18:52 ` [PATCH 2/2] netfilter: ctnetlink: fix scheduling while atomic if helper is autoloaded pablo
@ 2011-12-24 21:11 ` David Miller
  2 siblings, 0 replies; 4+ messages in thread
From: David Miller @ 2011-12-24 21:11 UTC (permalink / raw)
  To: pablo; +Cc: netfilter-devel, netdev

From: pablo@netfilter.org
Date: Sat, 24 Dec 2011 19:52:46 +0100

> These are a couple of late fixes for ctnetlink.
> 
> You can pull them from:
> 
> git://1984.lsi.us.es/net nf

Pulled, thanks!

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

end of thread, other threads:[~2011-12-24 21:11 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-12-24 18:52 [PATCH 0/2] late fixes for netfilter's ctnetlink pablo
2011-12-24 18:52 ` [PATCH 1/2] netfilter: ctnetlink: fix return value of ctnetlink_get_expect() pablo
2011-12-24 18:52 ` [PATCH 2/2] netfilter: ctnetlink: fix scheduling while atomic if helper is autoloaded pablo
2011-12-24 21:11 ` [PATCH 0/2] late fixes for netfilter's ctnetlink 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).