🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #24418

[PATCH net v3 1/1] netdevsim: fix the inverted queue count check in flow control

#24418
From: Kyuwon Cho
Date: Mon, 30 Nov 2026 05:56
61 lines
13581 bytes
nsim_start_xmit() maps the TX queues of the sending device onto the RX
queues of its peer, and flow control relies on one TX queue per RX
queue: nsim_stop_tx_queue() stops TX queue N when RX queue N is full,
and nsim_start_peer_tx_queue() wakes TX queue N after polling RX queue
N. Both skip this unless the queue counts match, but they compare the
wrong pair, the RX device's real_num_tx_queues with the TX device's
num_rx_queues.

A device with 8 queues whose channels were reduced to 1 with ethtool -L
passes this check once it is relinked to a peer with a single queue. If
one of its upper RX queues still holds traffic from the old peer,
nsim_start_peer_tx_queue() wakes a TX queue that the peer does not have:

  BUG: KASAN: slab-out-of-bounds in nsim_poll (include/linux/netdevice.h:3834 drivers/net/netdevsim/netdev.c:60)
  Read of size 8
  Call Trace:
   <IRQ>
   nsim_poll (drivers/net/netdevsim/netdev.c:409)
   __napi_poll.constprop.0 (net/core/dev.c:7997)
   net_rx_action (net/core/dev.c:8217)

Compare the TX device's real_num_tx_queues with the RX device's
num_rx_queues in both places. The polled RX queue index is below the RX
device's num_rx_queues, so the queue woken is then always inside the
peer's TX queue array. nsim_set_channels() can change
real_num_tx_queues of the other device at the same time, so read it
with READ_ONCE().

Fixes: ff2ac4df58ad ("netdevsim: implement peer queue flow control")
Suggested-by: Willem de Bruijn <willemb@google.com>
Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Kyuwon Cho <kyuwoncho18@gmail.com>
---
 drivers/net/netdevsim/netdev.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/netdevsim/netdev.c b/drivers/net/netdevsim/netdev.c
index eebc02ccc4a9..b0c4c00577e9 100644
--- a/drivers/net/netdevsim/netdev.c
+++ b/drivers/net/netdevsim/netdev.c
@@ -53,7 +53,7 @@ static void nsim_start_peer_tx_queue(struct net_device *dev, struct nsim_rq *rq)
 
 	/* TX device */
 	peer_dev = peer_ns->netdev;
-	if (dev->real_num_tx_queues != peer_dev->num_rx_queues)
+	if (READ_ONCE(peer_dev->real_num_tx_queues) != dev->num_rx_queues)
 		goto out;
 
 	txq = netdev_get_tx_queue(peer_dev, idx);
@@ -73,7 +73,7 @@ static void nsim_stop_tx_queue(struct net_device *tx_dev,
 	/* If different queues size, do not stop, since it is not
 	 * easy to find which TX queue is mapped here
 	 */
-	if (rx_dev->real_num_tx_queues != tx_dev->num_rx_queues)
+	if (READ_ONCE(tx_dev->real_num_tx_queues) != rx_dev->num_rx_queues)
 		return;
 
 	/* rq is the queue on the receive side */
-- 
2.43.0
Technical Details
Message-ID: <179601706910.5004018.0001.158406812152456751@gmail.com>
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-373895-linux-kernel-netdev=dewy.ru
References: <179601706910.5004018.0000.310885856232254824@gmail.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-373895-linux-kernel-netdev=dewy.ru
From: kyuwoncho18@gmail.com (Kyuwon Cho)
Newsgroups: linux.kernel.netdev
Subject: [PATCH net v3 1/1] netdevsim: fix the inverted queue count check in flow control
Date: Mon, 30 Nov 2026 14:56:50 +0900
Organization: Usenet Network
Message-ID: <179601706910.5004018.0001.158406812152456751@gmail.com>
References: <179601706910.5004018.0000.310885856232254824@gmail.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="1348080"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:Jz2iYW7mAhRewVToJoSr+LMJvk4= sha256:ezwPlOmMHQEGPm1MfcMoQKBgaZvTbukfA6fTtFn9BWc=
	sha1:sxdAK3t7M2CVtYuQ8UPhvZP2f6Q= sha256:KJMHp8KIxZGlr3kecYo+9ifOmiUd43NDiJ9gnotjWEM=
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 84099125FC4; Mon, 30 Nov 2026 08:57:14 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.049
X-Spam-Status: No, score=-3.049 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, FREEMAIL_FORGED_FROMDOMAIN=0.001,
	FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249,
	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=gmail.com
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 pOKhjYKYDbjf;
	Mon, 30 Nov 2026 08:57:12 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-373895-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=gmail.com
X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])
	by mail.dewy.ru (Postfix) with ESMTPS id A3CC5125FC5; Mon, 30 Nov 2026 08:57:03 +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 63B8527A7B; Mon, 30 Nov 2026 05:57:00 +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=1796018220;
	b=eXlulgDhnrawF47S+E8poFmXEzSIMhur0L5NGsYeZUaBhVp7rGTJxyKhhfPuHh93IiaP
	 gkpwKAmy1kG9dxDlpXdw68+Y2BAto0RGXI2Cz2NChKay9oTyk7cH6pAToOoG7bJ4dkcR4
	 HGZy2S2sPzMXLCPfH+b4JJWdO3qH75MW5DBCKjhaEk2ra51AQgNvs1xyVjZ9hEwb7hIYC
	 /lyqmxzY4TX5CcvMzkQkAOsK6Qw0WNQO7noACu/q7L5hZogdOU9ajITPtt+zbRkJhjfB4
	 bYluWjlSqMmtYhbp2MPANY/62C/e1GRuCE3Jf3GKRbMJGcj4EDroGLiVgDimoLFQQMg==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796018220;
	h=X-Original-To:Received:DMARC-Filter:Received:DKIM-Signature:
	 X-Google-DKIM-Signature:X-Forwarded-Encrypted:X-Gm-Message-State:
	 X-Gm-Gg:X-Received:Received:From:To:Cc:Subject:Date:Message-ID:
	 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=0DneSxctMeD1brAZoI7300rdt5M+Yn55foap0lbt/XU=;
	b=frP7FWXuuZVh/97SVcFepLaQxGYdr6bRPl24UzY/6ypUjqB/+cyQ6h1EvychkdKR5zUb
	 HJCp4Ye12f+UF7wBFLYmjuvWHn+x4BoeN8LkpN0gyeY24sJprbK1Rv01WzHwSFSwf2K90
	 tasbRBS2LoOFH5N2fqjInUWr8Blbzz21drHqof6ys8RPkjneoSlsOVEI4VLNTf6Ibnl71
	 jeUDFzTaGahzxGjpwc1oImFc48d9Ym44+uBtdSTwJU3KWbqMW95owqo2DHHBySuEoaSvf
	 1r7b/e3t12cfHDWxzpkEc7LiLVPCFt9dFDcme2ggnir3siNjH3DCF/j0zplei9A12Tw==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=QregmIv0;
	dmarc=pass header.from=gmail.com;
	spf=pass smtp.mailfrom=gmail.com;
	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 3B591606A32D;
	Mon, 30 Nov 2026 05:57:00 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=QregmIv0
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.215.177
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1796018219;
	b=UkmUSgyeqy4U69oTrvUq3rGv7bnzmAWnOgxpp64+NftGn4pVbExuIH9Q9DzjPD+UxHTd
	 AhXrt8hD1YGkscmpNoZhA+sEa6YwUbINJgeWgDCHtQnuKkIvt/wiVtd+R1jvYgK9d4Hkb
	 rHsoNS5LPXwQAcP01A/oAgfdtO36ZLMc4uepihxPhUvKQ8CRXtzHxk94cWkkowfowB6g7
	 tFaYVnWlo69p8yUUqaHHnucwyiJgZscsS1zqM4G9GNWHFMOVylKePUgkiJrxxnlMc3uGQ
	 W59hhkpJAVuOSzgdRBUW1JLoLNssZQbE6W+dNGflBJN13YqsGWbgYuqlGdkpsrqqxgw==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796018219;
	h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature:
	 X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received:
	 From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References:
	 MIME-Version:Content-Transfer-Encoding;
	bh=0DneSxctMeD1brAZoI7300rdt5M+Yn55foap0lbt/XU=;
	b=U4lLGWVgbDaj5acQt5cxRTY3GidL9zJqrtIm7LbiWNdmOXSyFHzhvIT+zzUXwuMX3Urq
	 WxG8YjjhG+Ek9MIxjPPq8xFGQY27N9U8FZhDCQ56RfCtxNV7j1+1ZHPCzCTUYxOTcm0QQ
	 Lf/9RLJfv1v6FmuZ91V6d4C4F/aFIUV0MfXTjW6XixiuBGhGBOhM2EKwC92zEvNqfN9ZT
	 V4UfuePnarHP33DjKRA9ZiHdlTfMHgyd9XTbEUSHA85ayJesbNz0My2FaqrlpVQkUmd+4
	 PuHHKOS7NtNYw5kLzSk8F7LDY0kQb1DoOyraTn7BP8Vh4OnRVNPnleQO5md/Ehqspmw==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dmarc=pass header.from=gmail.com;
	spf=pass smtp.mailfrom=gmail.com;
	dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=QregmIv0;
	arc=none smtp.remote-ip=209.85.215.177
X-Received: from mail-pg1-f177.google.com (mail-pg1-f177.google.com [209.85.215.177])
	(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 0F652606A32F
	for <netdev@vger.kernel.org>; Mon, 30 Nov 2026 05:56:58 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 0F652606A32F
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com
X-Received: by mail-pg1-f177.google.com with SMTP id 41be03b00d2f7-cde84cb8803so2810631a12.1
        for <netdev@vger.kernel.org>; Sun, 29 Nov 2026 21:56:58 -0800 (PST)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20260707; t=1796018218; x=1796623018; darn=vger.kernel.org;
        h=content-transfer-encoding:mime-version:references:in-reply-to
         :message-id:date:subject:cc:to:from:from:to:cc:subject:date
         :message-id:reply-to:content-type;
        bh=0DneSxctMeD1brAZoI7300rdt5M+Yn55foap0lbt/XU=;
        b=QregmIv0wgNYy60MMgaaif0EB5/IzjUyUmML3yWP1v8xuL3YN/D16MpnhIjryGDfKl
         jrnNyOyNT1rknM5lr9Pje6PbEnWlZWSbWCOSoMH5V15sA6oFmOGfDJ0hF+wnUjW+aDin
         APlsPcDkSQzJAG4sJ7WbL7GSHkXK3+J8HkhxGxaIh82RF8/APehoQe5g7zf2R1Dwv1zZ
         udNM89/t8uwZIs20CFdYd3KOBHSwde+3FcAa/SUct4L77Br9ihwwb6o1dJ1Dv2ODBitL
         Xf7lvD3q3LnNbhwGtwjRksNHX7OTyrgtvLM06ri+ETt4F1UyYwf/FE3GaJysI9crBqlZ
         uA7w==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20260707; t=1796018218; x=1796623018;
        h=content-transfer-encoding:mime-version:references:in-reply-to
         :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from
         :to:cc:subject:date:message-id:reply-to:content-type;
        bh=0DneSxctMeD1brAZoI7300rdt5M+Yn55foap0lbt/XU=;
        b=KU5NfiTOyGgJK8mxIlBHR9NseCYFo3fApaiNq8voVhUcsUHYmHBjNeGl38vpVbh4gF
         2HbJh2hE8RiRv8cbHI2Zn2VY3aZDqDofSoZEQFvq3dHHEBEE78qOqnT99IB0X6WX2V1Y
         xJuA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xJmVudq9ihtKiplUuzp3VPszYhMYgy205JJ/2VdKxcDv0NMBL43ENIg5TkcFws0=
X-Received: by 2002:a17:90b:17cd:b0:3b0:ce1c:e74f with SMTP id 98e67ed59e1d1-3b41c8fe346mr31086105a91.27.1796018218405;
        Sun, 29 Nov 2026 21:56:58 -0800 (PST)
X-Received: from d20be28ee783.tail196be.ts.net (vldb.skku.ac.kr. [115.145.173.180])
        by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3b41ad0b2c4sm50685765a91.4.2026.11.29.21.56.55
        (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
        Sun, 29 Nov 2026 21:56:58 -0800 (PST)
X-Cc: Andrew Lunn <andrew+netdev@lunn.ch>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@kernel.org>,
	Paolo Abeni <pabeni@redhat.com>,
	Breno Leitao <leitao@debian.org>,
	Willem de Bruijn <willemb@google.com>,
	Jiayuan Chen <jiayuan.chen@linux.dev>,
	netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org
X-In-Reply-To: <179601706910.5004018.0000.310885856232254824@gmail.com>
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