Article View: linux.kernel.netdev
Article #12981Re: [PATCH net-next 00/14] net: annotate data-races around sysctl knobs
From: Jiayuan Chen
Date: Mon, 09 Nov 2026 03:33
Date: Mon, 09 Nov 2026 03:33
45 lines
11645 bytes
11645 bytes
On 11/9/26 11:11 AM, Jason Xing wrote: > On Mon, Nov 9, 2026 at 10:55 AM Jiayuan Chen <jiayuan.chen@linux.dev> wrote: >> While testing the recent sysctl range fixes I noticed that a lot of our >> sysctl knobs are read with plain loads while the handlers update them >> with WRITE_ONCE() and no lock, so KCSAN reports them as data races. I >> then used an LLM to go through every ctl_table under net/ and list the >> readers that were left behind. This series annotates them with >> READ_ONCE(), and adds WRITE_ONCE() to a few custom handlers and netlink >> paths that store to the same fields with plain writes. Most of it is a >> plain READ_ONCE() at each read; where a function reads the same knob >> twice to make one decision, it now reads it once into a local, so the >> comparison and the value it acts on cannot come from two different >> writes. >> >> There are no Fixes tags. Done one knob per patch this would be well over >> a hundred commits, so I grouped them by subsystem and feature instead to >> keep the review manageable. If maintainers prefer, I can split it up >> further with a Fixes tag on each one, as several smaller series. > Over the last year, I've been thinking about the annotation stuff > especially around sysctls, which, I suppose, shouldn't actually affect > the real workload but does affect the outcome of the syzbot. > > Out of sheer curiosity, my question would be what is the point of > trying to change all of them? Or what kind of benefits can we get from > the big series? Three things: 1. A plain load may be emitted twice by the compiler. ip_error() compares peer->rate_tokens against ip_rt_error_cost and then subtracts it again; if the sysctl changes in between, the u32 wraps. A few readers have that shape and now read the knob once into a local. 2. Tearing is not involved here, all the fields are at most word sized. 3. The rest is the memory model: a lockless read of a field written with WRITE_ONCE() is a data race unless it is marked (tools/memory-model/Documentation/access-marking.txt). That is what KCSAN reports, and why most of the series is plain READ_ONCE(). I think the benefit is doing it in one pass.
Technical Details
Message-ID:
<dbdb9385-89cd-4e4f-bfb8-b72510e8801b@linux.dev>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-359018-linux-kernel-netdev=dewy.ruReferences:
<20261109025425.328445-1-jiayuan.chen@linux.dev> <CAL+tcoDvFNAZubOjw9+Z1eyaVeiBzt_Xg3KMNucY879bg-ZLow@mail.gmail.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-359018-linux-kernel-netdev=dewy.ru From: jiayuan.chen@linux.dev (Jiayuan Chen) Newsgroups: linux.kernel.netdev Subject: Re: [PATCH net-next 00/14] net: annotate data-races around sysctl knobs Date: Mon, 9 Nov 2026 11:33:09 +0800 Organization: Usenet Network Message-ID: <dbdb9385-89cd-4e4f-bfb8-b72510e8801b@linux.dev> References: <20261109025425.328445-1-jiayuan.chen@linux.dev> <CAL+tcoDvFNAZubOjw9+Z1eyaVeiBzt_Xg3KMNucY879bg-ZLow@mail.gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="263751"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:q+TbVS6rAbr7c6MEid9zN0kdFZo= sha256:yw0N7fnZRWgTv2JT1Y01ehQbNBn9GNI9pgAMUNu1SJI= sha1:tr8EAWvyYNG/HmsTkjKPPU1Sioc= sha256:9941UuE0ElHIZlQZLX4Gam+7j7uZ7979LEtCf5MJG/Q= 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 BF7091136CB; Mon, 9 Nov 2026 06:36:16 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -2.051 X-Spam-Status: No, score=-2.051 tagged_above=-9999 required=6.31 tests=[DCC_REPUT_70_89=0.1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.249, HK_RANDOM_FROM=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 (1024-bit key) header.d=linux.dev 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 DH6qV8l0hM-N; Mon, 9 Nov 2026 06:36:07 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-359018-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=linux.dev X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10]) by mail.dewy.ru (Postfix) with ESMTPS id 9F9B51136C9; Mon, 9 Nov 2026 06:35:58 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sea.lore.kernel.org (Postfix) with ESMTP id 977396B974; Mon, 9 Nov 2026 03:33:24 +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=1794195204; b=VDwb0I5DC8HxDfIxyc3HC09Zkr6ux7W7373KUeXk82rFXSl6GPaTakuK4r+OjgZkaA4J qtOPAxKUjT+5xOj/ho0Fs7m/Yzp1HlmeiA7opxMiqCvOYUg5hyKIUUTPUh3pZxwyNRi+m bjnSTmAEfj1J8Tx1UtdPvEXjQ4agiKLEyaT67d/g27AKNALzCdL3a+qfwoySJSM9b/J0e QzJP7T0KT7UfCTTBA2MY4UwaI7Y2S43PUSWUSqc9vhyRfYB0tYWBIaw3nPLpM7GaTwYDn 6Ly3DwOij23w2zvllj/0iKVE6dwTXqPg9yNVfIwEdWwbU4Tbb0O4DIVFS4oKZJFABlA== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794195204; h=X-Original-To:Received:DMARC-Filter:X-Envelope-To:DKIM-Signature: X-Envelope-To:Received:X-Mizu-Trace-ID:X-Migadu-Flow:Message-ID:Date: X-Mailing-List:List-Id:List-Post:List-Help:List-Subscribe: List-Unsubscribe:List-Owner:Precedence:MIME-Version:User-Agent: Subject:To:Cc:References:From:In-Reply-To:Content-Type: Content-Transfer-Encoding; bh=fSXkQFvYokTP7/zdJJbPcVi6eQ2VnCwRvk+/9wXmlm4=; b=UWGlzBUF4/gE2nayotWL40G5t25sVRCKBE8Z/bd8p4S+/qh9h31aWibVoqCTdLqFTjNF 6eaE19LN1djnk7Maf+wqTDqRG+8Zwn4E/wOG5xshhqGOO0BmjYUDme/B6C7OCKgCH1qkH xhZiwkWt1TE6f6LKI6S9LLBbUv9BDf7rz0INRruA7ATIJ1KYe+iLfXLKL4O+Rcvh+aeL3 tK7TkYPda6NV4r8PKwO5D7tM9B5ZCl+dSCC8T1OC8prqTZh6bt21JF6bfSX1yfKeCV5m4 urbTww8tDz8+Go4ih1cWJ2U0smu3Rqbk4tVnojM5IOpWJcGrMxqmZvnJ9iVBSBNw7Lg== X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=r16QktDB; dmarc=pass header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; 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 DD3C5606D809; Mon, 9 Nov 2026 03:33:23 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key, unprotected) header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=r16QktDB X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=91.218.175.28 X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1794195203; b=V1OI7ujoxH7CGLeIzRlv29hwfoD9HfbRwCiZgZgJ9q2+5QyhjeK5Dukex5NDPEtxx9Oe kIuxW/Ttl9x4XAmLykxnB3EiYcceoOeuHjP6xP2GuMokcb0pY1oDiaHqPZZB2NZv8/x+s 173wn3/aoa3XNRb3vQh4YHMlgpJuWqf80J+LkdIaLDc/5uDaErfvvneTaSbNioGXFevmN 7cm7ViJRVJ7JNfG4yJ6pSQgOlyVMrfxw7K1Es932wwo2GCli+c9OebuGqDz7nYQET/6tj nMCI6VNNZnFZxCMhK5OS3zzuqfHsaXoNdHiUCVDCrVTiNprXcmZsuQfvteqgYuTW0kA== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794195203; h=DMARC-Filter:X-Envelope-To:DKIM-Signature:X-Envelope-To:Received: X-Mizu-Trace-ID:X-Migadu-Flow:Message-ID:Date:MIME-Version:User-Agent: Subject:To:Cc:References:From:In-Reply-To:Content-Type: Content-Transfer-Encoding; bh=fSXkQFvYokTP7/zdJJbPcVi6eQ2VnCwRvk+/9wXmlm4=; b=x20st71VCpLe/VrXAuXix98/XBE+I9Xhgx5HBgteK2YyOwi0PDML0uiawcQK+US6JhA9 nDVD+x3ebmaTpbqKoxm2dOosgkBrw4c4NhJiOpg+p6MoyciKGJSoVnbbz0rX2Hr5TVc6d S6mwzSvZrVKrwVH1yn6uvU7hPPhVXO0fA8VkGC42X+Zrg1zKYf+yuNsNy2JDZ05VqqjLQ soA6z0XnLYSsAu2bzgHBqFL5OSknz5GKFjiIb98uqyd0XQjIR4+bvQX3HKHMgR4hs0OE6 jDL/VaRa+Bp8ylCDx+7jsw7QKpIRH5aCehumj9t0r6tVMdjmwSEzd/Fi4HgS9/2JMSQ== X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=r16QktDB; arc=none smtp.remote-ip=91.218.175.28 X-Received: from mta0.migadu.com (out-28.mta0.migadu.com [91.218.175.28]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EFE4A606A31C for <netdev@vger.kernel.org>; Mon, 9 Nov 2026 03:33:21 +0000 (UTC) X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org EFE4A606A31C X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev X-Envelope-To: netdev@vger.kernel.org X-DKIM-Signature: a=rsa-sha256; bh=fSXkQFvYokTP7/zdJJbPcVi6eQ2VnCwRvk+/9wXmlm4=; c=simple/simple; d=linux.dev; h=from:to:subject:date:message-id:mime-version:content-type; s=key1; t=1794195200; v=1; x=1794800000; b=r16QktDBtgrve2lJtXf+k6gXH2JSF2UEsOe+NTp+H98CZ49wJ1Z7BJczkYK9T6Di3A8RlBwI ZmVorwwBFY77q8no22m3Of4AAcVaDARx6SWh9e1i206khZ08QONc2ddINsWniDSlUhMtxdUeT3n JGi03KI7efrxXB4Ev5FI0UVQ= X-Envelope-To: netdev@vger.kernel.org X-Received: by smtp.migadu.com with ESMTPS id 1b12e287425c2338; Mon, 09 Nov 2026 03:33:19 +0000 X-Mizu-Trace-ID: 1b12e287425c2338 X-Migadu-Flow: FLOW_OUT 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-User-Agent: Mozilla Thunderbird X-Cc: netdev@vger.kernel.org, David Ahern <dsahern@kernel.org>, Ido Schimmel <idosch@nvidia.com>, "David S. Miller" <davem@davemloft.net>, Eric Dumazet <edumazet@kernel.org>, Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>, Simon Horman <horms@kernel.org>, Pablo Neira Ayuso <pablo@netfilter.org>, Florian Westphal <fw@strlen.de>, Phil Sutter <phil@nwl.cc>, Nikolay Aleksandrov <razor@blackwall.org>, Paul Moore <paul@paul-moore.com>, Matthieu Baerts <matttbe@kernel.org>, Mat Martineau <martineau@kernel.org>, Geliang Tang <geliang@kernel.org>, Julian Anastasov <ja@ssi.bg>, Allison Henderson <achender@kernel.org>, Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>, Xin Long <lucien.xin@gmail.com>, "D. Wythe" <alibuda@linux.alibaba.com>, Dust Li <dust.li@linux.alibaba.com>, Sidraya Jayagond <sidraya@linux.ibm.com>, Mahanta Jambigi <mjambigi@linux.ibm.com>, Tony Lu <tonylu@linux.alibaba.com>, Wen Gu <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-In-Reply-To: <CAL+tcoDvFNAZubOjw9+Z1eyaVeiBzt_Xg3KMNucY879bg-ZLow@mail.gmail.com>