Article View: linux.kernel.netdev
Article #12956[PATCH net-next 02/14] inet: frags: annotate data-races around fqdir->timeout and fqdir->max_dist
From: Jiayuan Chen
Date: Mon, 09 Nov 2026 02:52
Date: Mon, 09 Nov 2026 02:52
57 lines
11335 bytes
11335 bytes
fqdir->timeout and fqdir->max_dist are read without any lock while their
sysctl handlers update them with WRITE_ONCE(). Add READ_ONCE() to the
readers.
Signed-off-by: Jiayuan Chen <jiayuan.chen@linux.dev>
---
net/ipv4/inet_fragment.c | 2 +-
net/ipv4/ip_fragment.c | 6 +++---
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/net/ipv4/inet_fragment.c b/net/ipv4/inet_fragment.c
index 0b8d22ffafca6..ba10aec88cc9b 100644
--- a/net/ipv4/inet_fragment.c
+++ b/net/ipv4/inet_fragment.c
@@ -415,7 +415,7 @@ static struct inet_frag_queue *inet_frag_create(struct fqdir *fqdir,
inet_frag_putn(q, 2);
return NULL;
}
- mod_timer(&q->timer, jiffies + fqdir->timeout);
+ mod_timer(&q->timer, jiffies + READ_ONCE(fqdir->timeout));
spin_unlock_bh(&q->lock);
return q;
}
diff --git a/net/ipv4/ip_fragment.c b/net/ipv4/ip_fragment.c
index 36105dd192823..e70ef3fe5e331 100644
--- a/net/ipv4/ip_fragment.c
+++ b/net/ipv4/ip_fragment.c
@@ -89,7 +89,7 @@ static void ip4_frag_init(struct inet_frag_queue *q, const void *a)
q->key.v4 = *key;
qp->ecn = 0;
- if (q->fqdir->max_dist) {
+ if (READ_ONCE(q->fqdir->max_dist)) {
rcu_read_lock();
p = inet_getpeer_v4(net->ipv4.peers, key->saddr, key->vif);
if (p && !refcount_inc_not_zero(&p->refcnt))
@@ -220,7 +220,7 @@ static struct ipq *ip_find(struct net *net, struct iphdr *iph,
static int ip_frag_too_far(struct ipq *qp)
{
struct inet_peer *peer = qp->peer;
- unsigned int max = qp->q.fqdir->max_dist;
+ unsigned int max = READ_ONCE(qp->q.fqdir->max_dist);
unsigned int start, end;
int rc;
@@ -242,7 +242,7 @@ static int ip_frag_too_far(struct ipq *qp)
static int ip_frag_reinit(struct ipq *qp)
{
- if (!mod_timer_pending(&qp->q.timer, jiffies + qp->q.fqdir->timeout))
+ if (!mod_timer_pending(&qp->q.timer, jiffies + READ_ONCE(qp->q.fqdir->timeout)))
return -ETIMEDOUT;
inet_frag_queue_flush(&qp->q, SKB_DROP_REASON_FRAG_TOO_FAR);
--
2.43.0
Technical Details
Message-ID:
<20261109025425.328445-3-jiayuan.chen@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-358991-linux-kernel-netdev=dewy.ruReferences:
<20261109025425.328445-1-jiayuan.chen@linux.dev>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-358991-linux-kernel-netdev=dewy.ru From: jiayuan.chen@linux.dev (Jiayuan Chen) Newsgroups: linux.kernel.netdev Subject: [PATCH net-next 02/14] inet: frags: annotate data-races around fqdir->timeout and fqdir->max_dist Date: Mon, 9 Nov 2026 10:52:01 +0800 Organization: Usenet Network Message-ID: <20261109025425.328445-3-jiayuan.chen@linux.dev> References: <20261109025425.328445-1-jiayuan.chen@linux.dev> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="257239"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:rrCzROW9rJ8r22GJrq+NjCq+7xs= sha256:ASpvytyemUvdxPSizy4J2CY7pRkm/yCbsahtRi+QDKc= sha1:WASz5n9GtkSoWqitMNIGgYeXKuU= sha256:fIWxBtcr1bAs6SpGFXqkN0fVB79FE+7o9kcCXxIji6w= 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 889B61136B0; Mon, 9 Nov 2026 05:56:53 +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 qRlU6mMj7Ows; Mon, 9 Nov 2026 05:56:50 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-358991-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 tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114]) by mail.dewy.ru (Postfix) with ESMTPS id ABE12113691; Mon, 9 Nov 2026 05:56:40 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by tor.lore.kernel.org (Postfix) with ESMTP id 32A20290AC; Mon, 9 Nov 2026 02:56:17 +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=1794192976; b=CTkejh+/bHsjz1hR4ZkaQq3sLPB5b8i0GNyji6XHWko/BZx6S36YMVqABfwtyQgxOH+l ZPpKoSSOQ8lf7Gybkoyp2JnwXE1YyJznAMXJ/e1q6RxituYnSoktM09pT4cCGow7rcXEh T/EQfpItcCrhtIcyEUsa02cGlQ3BY6JG7hR3Ky3bTn7gNFDlPTsPtQES8BI8Xf+vVqDmW RGUFLYtxFOawF26IcV+1wYhKthpA8V01Qo82sp6Tw/9p3lsaqRwVA1jTN9NsTBezwz4Lj eEHSQpsOzt0GRt46Rfsr0gSvAW6qiy5qUkWWRlEHsN1pvuQy6Fz0/p220UiwcYZg95g== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794192976; h=X-Original-To:Received:DMARC-Filter:X-Envelope-To:DKIM-Signature: X-Envelope-To:Received:X-Mizu-Trace-ID:X-Migadu-Flow:From:To:Cc: Subject:Date:Message-ID:X-Mailer:In-Reply-To:References: X-Mailing-List:List-Id:List-Post:List-Help:List-Subscribe: List-Unsubscribe:List-Owner:Precedence:MIME-Version: Content-Transfer-Encoding; bh=RaQtkVcxzBk9BCoME2U3bmc9YHf7+BB9h58s0wdq0EY=; b=mWWKziKyoN6z6n8Tn+KqbO8GERJ55b8slDWlpA15CVo2/AOtytUg4xF711jqTbcsJNo0 S9UaJpL/fz8mClSR8kGTC8Pk8Et5JskQHHqF2OxWUlYNQvWQPxHodvKC/qtQN7ehczZtp dGXYsuqnUbXAHAaZwi1yUy0E2AMwZ3hDzP8BRHv2IQDJQ//KacThkQXqOBepRn9XRZrgT CbdSDl8j5NNppS3390aXHddqdrO/8FgRmtyzB+6phGuFpJiuA+QRfBfhgr3LGzyPR4uwv ZpnzANxu7OzTOMGM5zZLwQvSM0J/PWdWDI0SyNU05kWvqDmsgag3iWtmvk4y9I+uyuw== 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=pPsEyQj1; 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 3E9AC606A33F; Mon, 9 Nov 2026 02:56:16 +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=pPsEyQj1 X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=95.215.58.214 X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1794192975; b=zDUpIh99lqBStwZO7uW9RfGApJad9GNoWz4NFWVyIVLUV1b9lsd5BTnsZWUqeYXjBFW5 nTlIt0Z5gcV+nWwyEGsKVQsqMzF4puYVdksFz+oho2vFKboF8kdM525KSbGDBhZsNgVm7 hBBa9/qx3JJtUNCOxUqchethsVgwy/9tu7oTx8r3CYw1n5Fpyr0QM9WBOz6IGy6z+VBWw cuPwkysuoQ6bR5ljQdYbE2m8fkKq0ZHwKY/zbpdXgdxoyFvgYaBfPPZUVVJaTd1WjKs4h VE67VjzXkr8E5jM7Ea+Fr3t7Leuzr8LKIk96g9hxWjR/oJ8N0vNXdRGAJQGfrk9ti1w== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794192975; h=DMARC-Filter:X-Envelope-To:DKIM-Signature:X-Envelope-To:Received: X-Mizu-Trace-ID:X-Migadu-Flow:From:To:Cc:Subject:Date:Message-ID: X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding; bh=RaQtkVcxzBk9BCoME2U3bmc9YHf7+BB9h58s0wdq0EY=; b=ZJpRxCW0uzpFGu4EhiRaI5alhfp9DRt6S9wroUhRtbzzqVzQ9mo4EUatoZxFs7jzqIM5 wLfWHOuAX2L74gqRaKhzNZXhRxX0vrTwWH3iBstdD+1A/7KrP6DRQXQP/MgKRvVF9IlQj DqzmuZvF4eGlHPM1hXw2JoN0npQ7qkXTN1z1QTXHrVm/8vszF9cWDS2Awq2VrfHcWTS3V +mkSHDADLgvx9BqkOL0lwZYJFWGQXpwbkVJNRG77MT7ZkiG40l9xZZDlaCwSWFuPM2KK/ rxoX+9eQbFpluVtr/v1DaPO52ZLCzEh8sl9Ozh9cPz/62X+QAKkHxfoONhwuNZVTQuQ== 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=pPsEyQj1; arc=none smtp.remote-ip=95.215.58.214 X-Received: from mta1.migadu.com (out-214.mta1.migadu.com [95.215.58.214]) (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 B7425606A31C for <netdev@vger.kernel.org>; Mon, 9 Nov 2026 02:56:14 +0000 (UTC) X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org B7425606A31C 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=4k7ckGD6tUfxybB5EnqooZtc5aOl3FhWKSEZts3QU7E=; c=simple/simple; d=linux.dev; h=from:to:subject:date:message-id:mime-version:content-type; s=key1; t=1794192972; v=1; x=1794797772; b=pPsEyQj1uqZQPM1Q9MSE773hInHOYi4lRhr43uud/usXlQa6R5ezWeoAYGchkTLlJt1/XYpd TcidCn8H0VNDZm/N5UJBqTXFBRwllm5jMsext23W45FGCUuy0llqHd3RyMTN6oahRbWb76c22Om GJ4d1+tGLQaqRtOXNw94TIy8= X-Envelope-To: netdev@vger.kernel.org X-Received: by smtp.migadu.com with ESMTPS id 07673be978d49c6a; Mon, 09 Nov 2026 02:56:12 +0000 X-Mizu-Trace-ID: 07673be978d49c6a X-Migadu-Flow: FLOW_OUT X-Cc: Jiayuan Chen <jiayuan.chen@linux.dev>, 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-Mailer: git-send-email 2.43.0 X-In-Reply-To: <20261109025425.328445-1-jiayuan.chen@linux.dev> 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