Thread (2 messages) flat view 2 messages, 2 authors, 2025-11-19

Re: [PATCH nf-next v2] netfilter: conntrack: Add missing modification about data-race around ct->timeout

From: Florian Westphal <fw@strlen.de>
Date: 2025-11-19 12:25:44
Also in: lkml, netfilter-devel

Chenguang Zhao [off-list ref] wrote:
struct nf_conn)->timeout can be read/written locklessly,
add READ_ONCE()/WRITE_ONCE() to prevent load/store tearing.
Do you have a KCSAN splat or similar?
The patch 'commit 802a7dc5cf1b ("netfilter: conntrack: annotate
data-races around ct->timeout")'fixed it, but there was a
missing part that this patch completes it.
I'm no longer sure this was missing.
quoted hunk ↗ jump to hunk
diff --git a/net/netfilter/nf_conntrack_core.c b/net/netfilter/nf_conntrack_core.c
index 344f88295976..df4426adc9c8 100644
--- a/net/netfilter/nf_conntrack_core.c
+++ b/net/netfilter/nf_conntrack_core.c
@@ -1297,7 +1297,7 @@ __nf_conntrack_confirm(struct sk_buff *skb)
 	/* Timeout is relative to confirmation time, not original
 	   setting time, otherwise we'd get timer wrap in
 	   weird delay cases. */
-	ct->timeout += nfct_time_stamp;
+	WRITE_ONCE(ct->timeout, READ_ONCE(ct->timeout) + nfct_time_stamp);
Here we hold the bucket insert locks for ct, so I don't see
how we can have concurrent modification here.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help