Skip to contentSkip to conversation

netfilter 00/02: netfilter fixes

DISCUSSION Patrick McHardy 2 participants 4 messages Apr 17, 2009

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

Hi Dave,

the following two patches fix two netfilter bugs:

- missing socket notification for ctnetlink skb allocation errors

- an incorrect return code in nfnetlink for netlink_kernel_create() failure

Please apply or pull from:

git://git.kernel.org/pub/scm/linux/kernel/git/kaber/nf-2.6.git

Thanks!

 net/netfilter/nf_conntrack_netlink.c |   10 ++++++----
 net/netfilter/nfnetlink.c            |    2 +-
 2 files changed, 7 insertions(+), 5 deletions(-)

Pablo Neira Ayuso (2):
netfilter: ctnetlink: report error if event message allocation fails
netfilter: nfnetlink: return ENOMEM if we fail to create netlink socket

#1 lore raw

netfilter 01/02: ctnetlink: report error if event message allocation fails

commit 150ace0db360373d2016a2497d252138a59c5ba8

Author: Pablo Neira Ayuso <[email protected]>
Date:   Fri Apr 17 17:47:31 2009 +0200

netfilter: ctnetlink: report error if event message allocation fails

This patch fixes an inconsistency that results in no error reports to user-space listeners if we fail to allocate the event message.

net/netfilter/nf_conntrack_netlink.c +6 -4
index c6439c7..0ea36e0 100644
@@ -512,7 +512,7 @@ static int ctnetlink_conntrack_event(struct notifier_block *this,
 
 	skb = ctnetlink_alloc_skb(tuple(ct, IP_CT_DIR_ORIGINAL), GFP_ATOMIC);
 	if (!skb)
-		return NOTIFY_DONE;
+		goto errout;
 
 	b = skb->tail;
 
@@ -591,8 +591,9 @@ static int ctnetlink_conntrack_event(struct notifier_block *this,
 nla_put_failure:
 	rcu_read_unlock();
 nlmsg_failure:
-	nfnetlink_set_err(0, group, -ENOBUFS);
 	kfree_skb(skb);
+errout:
+	nfnetlink_set_err(0, group, -ENOBUFS);
 	return NOTIFY_DONE;
 }
 #endif /* CONFIG_NF_CONNTRACK_EVENTS */
@@ -1564,7 +1565,7 @@ static int ctnetlink_expect_event(struct notifier_block *this,
 
 	skb = alloc_skb(NLMSG_GOODSIZE, GFP_ATOMIC);
 	if (!skb)
-		return NOTIFY_DONE;
+		goto errout;
 
 	b = skb->tail;
 
@@ -1589,8 +1590,9 @@ static int ctnetlink_expect_event(struct notifier_block *this,
 nla_put_failure:
 	rcu_read_unlock();
 nlmsg_failure:
-	nfnetlink_set_err(0, 0, -ENOBUFS);
 	kfree_skb(skb);
+errout:
+	nfnetlink_set_err(0, 0, -ENOBUFS);
 	return NOTIFY_DONE;
 }
 #endif
#2 lore raw

netfilter 02/02: nfnetlink: return ENOMEM if we fail to create netlink socket

In reply to Patrick McHardy

commit a0142733a7ef2f3476e63938b330026a08c53f37

Author: Pablo Neira Ayuso <[email protected]>
Date:   Fri Apr 17 17:48:44 2009 +0200

netfilter: nfnetlink: return ENOMEM if we fail to create netlink socket

With this patch, nfnetlink returns -ENOMEM instead of -EPERM if we fail to create the nfnetlink netlink socket during the module loading. This is exactly what rtnetlink does in this case.

Ideally, it would be better if we propagate the error that has happened in netlink_kernel_create(), however, this function still does not implement this yet.

net/netfilter/nfnetlink.c +1 -1
index 2785d66..b8ab37a 100644
@@ -203,7 +203,7 @@ static int __init nfnetlink_init(void)
 				     nfnetlink_rcv, NULL, THIS_MODULE);
 	if (!nfnl) {
 		printk(KERN_ERR "cannot initialize nfnetlink!\n");
-		return -1;
+		return -ENOMEM;
 	}
 
 	return 0;
maintainer
#3 lore raw
In reply to Patrick McHardy

From: Patrick McHardy <[email protected]>
Date: Fri, 17 Apr 2009 18:09:13 +0200 (MEST)

Quoted 9 lines

the following two patches fix two netfilter bugs:

- missing socket notification for ctnetlink skb allocation errors

- an incorrect return code in nfnetlink for netlink_kernel_create() failure

Please apply or pull from:

git://git.kernel.org/pub/scm/linux/kernel/git/kaber/nf-2.6.git

Pulled, thanks a lot!