Article View: linux.kernel.netdev
Article #15867Re: [PATCH net-next 14/14] netfilter: cttimeout: annotate data-races around the default timeouts
From: Simon Horman
Date: Fri, 13 Nov 2026 17:20
Date: Fri, 13 Nov 2026 17:20
99 lines
12506 bytes
12506 bytes
On Tue, Nov 10, 2026 at 05:53:27AM +0000, netdev-bot+sashiko@kernel.org wrote:
> Thank you for your contribution! Sashiko AI review found 1 potential
> issue(s) to consider.
>
> Critical: 0 ยท High: 0 ยท Medium: 1 ยท Low: 0
>
> If you believe none of the issues are legitimate, please reply to each
> issue of Medium severity or higher and explain why the AI is wrong.
> If any of them are legitimate and you plan to respin, please let patchwork
> know by including "pw-bot: cr" as a separate line at the end of your reply
> (one such reply per series is enough).
>
> - [Medium] A concurrent sysctl write to a default conntrack timeout can
> still be silently undone.
>
> --
>
> netfilter: cttimeout: annotate data-races around the default timeouts
>
> This commit changes the l4proto nlattr_to_obj() and obj_to_nlattr()
> timeout callbacks to use WRITE_ONCE() and READ_ONCE() instead of plain
> accesses. It targets races between cttimeout_default_set() and
> cttimeout_default_get(), the conntrack packet path, and the
> nf_conntrack_*_timeout* sysctl handlers, which all touch the same
> per-netns default timeout arrays.
>
> > diff --git a/net/netfilter/nf_conntrack_proto_udp.c b/net/netfilter/nf_conntrack_proto_udp.c
> > index 99eedaa2b1183..777b21da3bcff 100644
> > --- a/net/netfilter/nf_conntrack_proto_udp.c
> > +++ b/net/netfilter/nf_conntrack_proto_udp.c
> > @@ -155,16 +155,16 @@ static int udp_timeout_nlattr_to_obj(struct nlattr *tb[],
> > timeouts = un->timeouts;
> >
> > /* set default timeouts for UDP. */
> > - timeouts[UDP_CT_UNREPLIED] = un->timeouts[UDP_CT_UNREPLIED];
> > - timeouts[UDP_CT_REPLIED] = un->timeouts[UDP_CT_REPLIED];
> > + WRITE_ONCE(timeouts[UDP_CT_UNREPLIED], READ_ONCE(un->timeouts[UDP_CT_UNREPLIED]));
> > + WRITE_ONCE(timeouts[UDP_CT_REPLIED], READ_ONCE(un->timeouts[UDP_CT_REPLIED]));
>
> [Severity: Medium]
>
> Can a concurrent sysctl write still be lost here?
>
> cttimeout_default_set() passes a NULL destination:
>
> net/netfilter/nfnetlink_cttimeout.c:cttimeout_default_set() {
> ...
> ret = ctnl_timeout_parse_policy(NULL, l4proto, info->net,
> cda[CTA_TIMEOUT_DATA]);
> ...
> }
>
> So udp_timeout_nlattr_to_obj() sets timeouts to un->timeouts, and the
> default copy turns into a self-copy of the live per-netns array:
>
> WRITE_ONCE(un->timeouts[UDP_CT_REPLIED],
> READ_ONCE(un->timeouts[UDP_CT_REPLIED]));
>
> That is still a separate load and store. The sysctl handler writes the
> same field through proc_dointvec_jiffies() and does not take the nfnl
> mutex. Take a request that carries only CTA_TIMEOUT_UDP_UNREPLIED, sent
> while nf_conntrack_udp_timeout_stream is being written:
>
> CPU0 (IPCTNL_MSG_TIMEOUT_DEFAULT_SET)
> old = READ_ONCE(un->timeouts[UDP_CT_REPLIED])
>
> CPU1 (sysctl write)
> WRITE_ONCE(un->timeouts[UDP_CT_REPLIED], new)
>
> CPU0
> WRITE_ONCE(un->timeouts[UDP_CT_REPLIED], old)
>
> The sysctl value gets reverted, even though the netlink request never
> named that attribute.
>
> The second KCSAN splat in the commit message (proc_int_u2k_conv_uop vs
> udp_timeout_nlattr_to_obj) comes from this access pair. Once both sides
> are marked, KCSAN stops reporting it, but the update can still be lost.
>
> The same self-copy happens in these places:
>
> tcp_timeout_nlattr_to_obj(), where timeouts = tn->timeouts and the
> loop covers all TCP_CONNTRACK_TIMEOUT_MAX entries
> sctp_timeout_nlattr_to_obj(), where timeouts = sn->timeouts
> gre_timeout_nlattr_to_obj(), where timeouts = gre_get_timeouts(net)
> the else branch of generic_timeout_nlattr_to_obj(), when timeout is
> &gn->timeout
> the else branch of icmpv6_timeout_nlattr_to_obj(), when timeout
> falls back to icmpv6_get_timeouts(net)
>
> When the destination already points at the per-netns array, could the
> default copy be skipped, so that fields missing from the request are
> never stored?
This also looks like it should be addressed.
--
pw-bot: changes-requested
Technical Details
Message-ID:
<20261113172036.GW18859@horms.kernel.org>Path:
mbox-mo1.pugleaf.net!news-lax.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-362810-linux-kernel-netdev=dewy.ruReferences:
<20261109025425.328445-15-jiayuan.chen@linux.dev> <179429000729.994134.16108041301574145842@kernel.org>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-362810-linux-kernel-netdev=dewy.ru From: horms@kernel.org (Simon Horman) Newsgroups: linux.kernel.netdev Subject: Re: [PATCH net-next 14/14] netfilter: cttimeout: annotate data-races around the default timeouts Date: Fri, 13 Nov 2026 17:20:36 +0000 Organization: Usenet Network Message-ID: <20261113172036.GW18859@horms.kernel.org> References: <20261109025425.328445-15-jiayuan.chen@linux.dev> <179429000729.994134.16108041301574145842@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="1399336"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:pR3brS8sNs0UI5FSLvNmzeIFoR8= sha256:fu9EOpfsFZN0y4yxHp69FVkyEKB1b0hdHyAZpPj2ImQ= sha1:70Ln9jXFpilhgCj1YAX+zwg1XPk= sha256:sTnyXKKOU5BOLcFxmGuBJ1uC3j32SAQm8FgXQeqnrtI= Content-Disposition: inline List-ID: <netdev.vger.kernel.org> X-Mailpost-Empty-Hdrs: X-Spam-Level X-Received: from localhost (localhost [127.0.0.1]) by mail.dewy.ru (Postfix) with ESMTP id D9C241145D9; Fri, 13 Nov 2026 20:46:31 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.501 X-Spam-Status: No, score=-3.501 tagged_above=-9999 required=6.31 tests=[DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001] autolearn=ham autolearn_force=no X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key) header.d=kernel.org X-Received: from mail.dewy.ru ([127.0.0.1]) by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id a_yTUqWm-2xW; Fri, 13 Nov 2026 20:46:27 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.232.135.74; helo=sto.lore.kernel.org; envelope-from=netdev+bounces-362810-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org X-Received: from sto.lore.kernel.org (sto.lore.kernel.org [172.232.135.74]) by mail.dewy.ru (Postfix) with ESMTPS id C912A1145AC; Fri, 13 Nov 2026 20:46:19 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sto.lore.kernel.org (Postfix) with ESMTP id E9C0A6C8251; Fri, 13 Nov 2026 17:29:50 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1794590446; b=SNchEZT27KITZTvdy9CysCu7PDsGlTovo1hxqopek6XrSttm0RSiQ50HFo4OZ+XP99d8 3fFrRZXx6ahIeqW9cbgebJTSYwTo12r8b/jASLv7yVRtr8yNiuwNPga/Du9JM/y3TtAih w0FF9t1aEI3c2keZwQHsMebF/ZhIw9vJy3I+894xhubD6YTvL6KrOJOibF/vJDPtRwr72 REWTyx5DkPUxQS1ycj58K1osOx+z04A/WPTkqkbWKunAlvID/xlwY1l6jTKvSVpKtV+yh J8mjVht+ho5OdTFaKH8KE9euyi9m5XxVITILXO3wTZJUE6DJ+xl2oNK98BpaYnUUeZA== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794590446; h=X-Original-To:Received:Received:DKIM-Signature:Date:From:To:Cc: Subject:Message-ID:References:X-Mailing-List:List-Id:List-Post: List-Help:List-Subscribe:List-Unsubscribe:List-Owner:Precedence: MIME-Version:Content-Type:Content-Disposition: Content-Transfer-Encoding:In-Reply-To; bh=+k0lqC5iZylsBxTYDQ63TRyQvvV+TPUwb4IvUKy1hP4=; b=UThoXmIQ/5o0tulXYCaOVET8dKzUQKy98/ANa4qFk2XBII1iqMvZIxeSPRweFk+3FI1T HP3V7PXnzsU6q8J6i7VL50PYD9pe6VkT8WHfvPxDAXVg8aaDaAc+TitYWyA8GpBx+aJrP unikSBhjIiCdSqPrkPlA2iwKoeQJ9rJhmA2RhyW3Gu4pH7k00a3ODB+f1tCey8hAsuNa3 41+gXazNGCGV4L28IPgSitj0qH1Fl8rdvg01T9xmWu40vTUEntSgtiVntHPDlgyQ2Fnf0 A3yHebDYjHSPTPvA+gm1K7wTdjgxucS/+vJ5PNgWUQv5Y3T1CKBnGUauhSc+rrjVeAw== X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=n5Muh8jS; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3B859607140E; Fri, 13 Nov 2026 17:20:46 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=n5Muh8jS X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1794590445; b=O4GiBB2cwTEIVWbIKGBef60NpOBwT4lYTYMZFWObpzeZUJjZDB+1RLm9R8JaLpODhzZX g8Kwt9vZDgyKuN8ysVBNlncPIH0sIXsP/7E6Ibn78XmgcZCaVTbeAAOftIV7+Fl6fd0bw g9efJCJ/mD3qA7bRBQtgmbtmFB1vvwqvXXKHvuUnULOD65vyI9ocNf7Xym1xlkt14e7/0 lpnPo+Ab6afSPFzPK244vklEJzMqa22V5RTq3RlFMDcVXILAXgPReJ5WNQQ0Q73uCFn5U 3zbiJF3JVPQzcQaMhL+zUnljNmG0j3MIsD5x03CgCvKHZ56JjmDHTIsD5I/fyXXCmBA== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794590445; h=Received:DKIM-Signature:Date:From:To:Cc:Subject:Message-ID: References:MIME-Version:Content-Type:Content-Disposition: Content-Transfer-Encoding:In-Reply-To; bh=+k0lqC5iZylsBxTYDQ63TRyQvvV+TPUwb4IvUKy1hP4=; b=CmuUT925COvKAIyxkLX2eqsixWo5DSAg+ey6aOU+xJZACCwe6h3m5cZVCPJUp0/V0bK2 O4uej3QXN1lio2Zdd1uDpMOIIQxgpgvvduD8oIe/QoG1BGrz/48dMxRya+n4w947kXrfo WiOwnytMAGlwmOjmMaepwti7aGjcly32JCrXMnpGQ2JNcDGcJ5uc8lOmxlzNXUi+FyzS0 jqn+0R9gjnEbKFy0NtnvJN3LYXEycAKFIfp5rmpibBOTlafBsbddZLphUUIWxwz4mA4cE zrYzzxM/Ck8HLma029qM9YtEIZ1bEQOk8f2uHZHg3HLbDHaTotZn/Xxu0bCmJyENrgg== X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=n5Muh8jS; arc=none smtp.remote-ip=100.103.45.18 X-Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5546460703EC; Fri, 13 Nov 2026 17:20:45 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id CCEEE1F000C4; Fri, 13 Nov 2026 17:20:38 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1794590444; bh=+k0lqC5iZylsBxTYDQ63TRyQvvV+TPUwb4IvUKy1hP4=; h=Date:From:To:Cc:Subject:References:In-Reply-To; b=n5Muh8jSgVmkNwqxcUlVS3OCHfJbmgFlvueQBcwmyX4XUknjc9caIY94yJXAz76fj ULkdD71jXxojR41jlEXhcEWDtan5DFpbap3wY0mF3VU0xKRjcDIlqXYKUK6tqrL1Mi xskqn8VYAffU/Y4LS92Z2pyfhtg1NlBR+zGrU0kkVBptLtpoMpUcP6SFTvGTQ+12WQ wl8FM7AfsdDASl2HM7NkacojDcIugzZnkoz8hTAqXa0yBEyH+g7hztvx+FUOb88gJW MaznShSFrgbPVqlg2WdR0aeaTcnnBk7dUqqh+i/GZ4rlTAxxy3U2QWoo4sRiLZMbrZ 1cfJgBZiOaABQ== X-Cc: jiayuan.chen@linux.dev, netdev@vger.kernel.org, dsahern@kernel.org, idosch@nvidia.com, davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com, pablo@netfilter.org, fw@strlen.de, phil@nwl.cc, razor@blackwall.org, paul@paul-moore.com, matttbe@kernel.org, martineau@kernel.org, geliang@kernel.org, ja@ssi.bg, achender@kernel.org, marcelo.leitner@gmail.com, lucien.xin@gmail.com, alibuda@linux.alibaba.com, dust.li@linux.alibaba.com, sidraya@linux.ibm.com, mjambigi@linux.ibm.com, tonylu@linux.alibaba.com, guwen@linux.alibaba.com, linux-kernel@vger.kernel.org, netfilter-devel@vger.kernel.org, coreteam@netfilter.org, bridge@lists.linux.dev, linux-security-module@vger.kernel.org, mptcp@lists.linux.dev, lvs-devel@vger.kernel.org, linux-rdma@vger.kernel.org, rds-devel@oss.oracle.com, linux-sctp@vger.kernel.org, linux-s390@vger.kernel.org X-Mailing-List: netdev@vger.kernel.org X-List-Post: <mailto:netdev@vger.kernel.org> X-List-Help: <mailto:netdev+help@vger.kernel.org> X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org> X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org> X-List-Owner: <mailto:netdev+owner@vger.kernel.org> X-Precedence: list X-In-Reply-To: <179429000729.994134.16108041301574145842@kernel.org>