Skip to contentSkip to conversation

netfilter: evict stale entries when user reads /proc/net/nf_conntrack

PATCH Applied Florian Westphal 2 participants 2 messages Sep 22, 2016 – Sep 25, 2016

Subsystems (2)
lore
Share & tools
lore

Florian Westphal

author maintainer
#0 lore raw

PATCH 1/1 netfilter: evict stale entries when user reads /proc/net/nf_conntrack

Fabian reports a possible conntrack memory leak (could not reproduce so far), however, one minor issue can be easily resolved:

Quoted 2 lines

cat /proc/net/nf_conntrack | wc -l = 5
4 minutes required to clean up the table.

We should not report those timed-out entries to the user in first place. And instead of just skipping those timed-out entries while iterating over the table we can also zap them (we already do this during ctnetlink walks, but I forgot about the /proc interface).

Fixes f330a7fdbe16 ("netfilter: conntrack: get rid of conntrack timer")
---
 net/netfilter/nf_conntrack_standalone.c | 5 +++++
 1 file changed, 5 insertions(+)
net/netfilter/nf_conntrack_standalone.c +5 -0
index 7d52f8401afd..5f446cd9f3fd 100644
@@ -212,6 +212,11 @@ static int ct_seq_show(struct seq_file *s, void *v)
 	if (unlikely(!atomic_inc_not_zero(&ct->ct_general.use)))
 		return 0;
 
+	if (nf_ct_should_gc(ct)) {
+		nf_ct_kill(ct);
+		goto release;
+	}
+
 	/* we only want to print DIR_ORIGINAL */
 	if (NF_CT_DIRECTION(hash))
 		goto release;
Signature · 1 line
2.7.3
maintainer Applied
#1 lore raw
Quoted 6 lines · Florian Westphal

Fabian reports a possible conntrack memory leak (could not reproduce so far), however, one minor issue can be easily resolved:

Quoted 2 lines

cat /proc/net/nf_conntrack | wc -l = 5
4 minutes required to clean up the table.

Quoted 8 lines

We should not report those timed-out entries to the user in first place. And instead of just skipping those timed-out entries while iterating over the table we can also zap them (we already do this during ctnetlink walks, but I forgot about the /proc interface).

Fixes f330a7fdbe16 ("netfilter: conntrack: get rid of conntrack timer")

Applied, thanks.