Skip to contentSkip to conversation

netfilter: ctnetlink: fix loop in ctnetlink_get_conntrack()

PATCH In review Florian Westphal 2 participants 2 messages Jan 13, 2011

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

PATCH 1/1 netfilter: ctnetlink: fix loop in ctnetlink_get_conntrack()

From: Pablo Neira Ayuso <[email protected]>

This patch fixes a loop in ctnetlink_get_conntrack() that can be triggered if you use the same socket to receive events and to perform a GET operation. Under heavy load, netlink_unicast() may return -EAGAIN, this error code is reserved in nfnetlink for the module load-on-demand. Instead, we return -ENOBUFS which is the appropriate error code that has to be propagated to user-space.

---
Looks like this patch got lost -- I cannot find in in linus' or net-2.6 trees...

net/netfilter/nf_conntrack_netlink.c +2 -1
index 5cb8d30..2b7eef3 100644
@@ -972,7 +972,8 @@ ctnetlink_get_conntrack(struct sock *ctnl, struct sk_buff *skb,
 free:
 	kfree_skb(skb2);
 out:
-	return err;
+	/* this avoids a loop in nfnetlink. */
+	return err == -EAGAIN ? -ENOBUFS : err;
 }
 
 #ifdef CONFIG_NF_NAT_NEEDED
Signature · 1 line
1.7.2.2
#1 lore raw
Quoted 9 lines · Florian Westphal

From: Pablo Neira Ayuso <[email protected]>

This patch fixes a loop in ctnetlink_get_conntrack() that can be triggered if you use the same socket to receive events and to perform a GET operation. Under heavy load, netlink_unicast() may return -EAGAIN, this error code is reserved in nfnetlink for the module load-on-demand. Instead, we return -ENOBUFS which is the appropriate error code that has to be propagated to user-space.

Indeed, it's in Patrick's tree but it didn't get the patch to reach the kernel. I'll pass it to davem.