cttimeout_default_set() and cttimeout_default_get() hand the per-netns
default timeout arrays to the l4proto nlattr_to_obj() and obj_to_nlattr()
callbacks, which write and read them with plain accesses while the
nf_conntrack_*_timeout* sysctl handlers update the same fields with
WRITE_ONCE(). Use WRITE_ONCE() and READ_ONCE() in the callbacks.
KCSAN reports both sides when the UDP default timeouts are set over
nfnetlink while UDP traffic goes through conntrack, or while the sysctl
is written:
BUG: KCSAN: data-race in nf_conntrack_udp_packet / udp_timeout_nlattr_to_obj
write to 0xffffffffb0829bc4 of 4 bytes by task 457 on cpu 1:
udp_timeout_nlattr_to_obj+0x3b/0xf0
ctnl_timeout_parse_policy+0xc0/0x100
[ ... ]
...
value changed: 0x00001d4c -> 0x00001e46
Signed-off-by: Jiayuan Chen <jiayuan.chen@linux.dev>
Sashiko has reviewed this patch and found no issues.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261109025425.328445-1-jiayuan.chen@linux.dev?part=14