🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #6350

[BUG] net: tun: queue detach leaves stale flow steering indices

#6350
From: Cheng Yongkang
Date: Thu, 22 Oct 2026 09:14
44 lines
12277 bytes
Hi all,

The TUN flow-steering purge after queue detach does not remove all
entries affected by moving the last queue into the detached slot.

__tun_detach() decrements numqueues before calling
tun_flow_delete_by_queue(), then uses numqueues + 1 for the purge.
Entries recorded with the detached queue's old index, and entries for
the queue moved down from the old last slot, can therefore survive.
TX flow steering subsequently selects the wrong queue fd, or selects an
out-of-range index that netdev_cap_txqueue() clamps to queue 0.

Observed on Linux v7.3, commit
08ab31164c55f20c7a2653de3186ae333470e2c1, with a three-queue TAP:

  learn F1 on queue 2
  detach queue 2
  send F1 reply
  tun0 selects TX queue 2, but real number of TX queues is 2
  packet is clamped to queue 0

  learn F2 on queue 1
  detach queue 1, moving queue 2 into slot 1
  send F2 reply
  the flow is read from queue 2's fd, not the no-entry baseline queue

The second differential directly proves wrong queue ownership, not only
the expected clamp warning.  Candidate BR-027 is the same off-by-one
purge root.

The detach path should purge both the old queue index and the moved
end-slot index, preferably before their meaning changes, or rebuild the
flow indices atomically when queues move.

I found no matching upstream fix.

The PoC and complete program/console logs are available on request.

This was found with a multi-agent workflow; the
behavior was reproduced in QEMU.

Thanks,
Cheng Yongkang
Technical Details
Message-ID: <20261022091427.3650281-1-teel4res@gmail.com>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-350454-linux-kernel-netdev=dewy.ru

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-350454-linux-kernel-netdev=dewy.ru
From: teel4res@gmail.com (Cheng Yongkang)
Newsgroups: linux.kernel.netdev
Subject: [BUG] net: tun: queue detach leaves stale flow steering indices
Date: Thu, 22 Oct 2026 02:14:27 -0700
Organization: Usenet Network
Message-ID: <20261022091427.3650281-1-teel4res@gmail.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="172530"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:rWIGgjqoyFOTwhIXTkE9kqr1KMU= sha256:hg5IxOx0X+z066tPxdrwlSM99VB2DFs76uS2Nm3JQHU=
	sha1:6jJIeBiI4tnjaIrSDd9iBkRPzrY= sha256:BhEgu1MZFtxBDxnZZdlpUWeYRKHoyKxbbQbIL132zBY=
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 877BE1111FB; Thu, 22 Oct 2026 12:19:25 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.048
X-Spam-Status: No, score=-3.048 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.25,
	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 tuVlpOdf0h6l;
	Thu, 22 Oct 2026 12:19:22 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=104.64.211.4; helo=sin.lore.kernel.org; envelope-from=netdev+bounces-350454-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 sin.lore.kernel.org (sin.lore.kernel.org [104.64.211.4])
	by mail.dewy.ru (Postfix) with ESMTPS id 121381111D8; Thu, 22 Oct 2026 12:19:14 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by sin.lore.kernel.org (Postfix) with ESMTP id A2F812EC0A; Thu, 22 Oct 2026 09:14:38 +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=1792660476;
	b=MxL+N+PluEN2kFJkDP17WYai9CKE9qJKtNOhPYyGSbpl+KJdvoopGPnu7dVt7U3+y+r7
	 kDMeEbCgiaaLt7oa8yVVJqs5F7rb92rFJ5Q65ql7G2kzWizbO1K+FbrQw9CXRrrXfMZpj
	 X4RRNj8FoeSqpQMraFJDYmMan6C8vX+COG9+57ekOA2YFFC28iRmuCttRGYqao3kVTesX
	 fWs+/7dOOONAUKyNkYNHatRIim+dXyZ5+m7/B3bBglaaghcZ2vVrCXS4Dg/vblrSVVgXT
	 EgnvU/LdhyLRmxrQeFQvuNq11jR1FnvtZq/j9o3FCtSpZdnUiquXjG1O2KHy8cZemzw==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1792660476;
	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:
	 X-Mailer:X-Mailing-List:List-Id:List-Post:List-Help:List-Subscribe:
	 List-Unsubscribe:List-Owner:Precedence:MIME-Version:Content-Type:
	 Content-Transfer-Encoding;
	bh=+FdxbDW163sXl7PSrtKq2x3hScBeEWK+b0ZUQ8/Dwtw=;
	b=W3vGjr/Fs143a1tEgaFvvsZFSThQc//oeLTr+ZIr0qa9FzTaGf1saR40chimje+hSyEE
	 zdu/C7PUKNkOcwQV5xuIPD9QXBymbA8vPw1pF8GKwB3nGDUi2eG0rWgsunT4n8ZqTCHyH
	 +wk4dUQ82cHkQjfTWkBLUezJmx65OgahEPSKN52LBXG94OaD7SSj3O4HWH3Qfq1331ptx
	 h07icA8Qy5dGjH3S5SHkr5b1iHwBBNC4ff9RsqC3Ujm6aRZ1ZAYWfugZe3vqmjwu93ZVN
	 wxfmZEWJ4LBQyhiqY/Q/qDRrWVkwV6IOmZfbvF1xL6derQEpcflbdQ8nnLdQHxzwRyw==
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=20251104 header.b=laJovtXn;
	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 17867606A329;
	Thu, 22 Oct 2026 09:14:36 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key, unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20251104 header.b=laJovtXn
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.82.172
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1792660475;
	b=TrA6Q3YMHkcLTVJsUfuz/S80iQ4IAG/ayEY0xzdZb67EZK6kDeG/AA1Nt5U9pQNbhEJY
	 mz3BuAYChUuqw7wSg3etlKAc0dEGi8QLwyWFn1Z+uxZsyLyNa82BqX3qfPVTbrrbY3aZ+
	 nT9mMUDIDL9eEOO6NOGagfDN67j2S4hHOeicayJxqlARdBhmgzOHygmQtpgzMDIvpVnS8
	 M8QmqTsuPXE/V3nOFVZBKA/k/orCV0ZjTM/9ud7yzybWRCw38DGP8yxHMuU66CKEVkYCr
	 BnL9DH0fRbdpH2KGG3mwiWN05Xc1fPkNzbOrnemS/6PCLnvgsvcHjz2bDjjumu2kpgA==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1792660475;
	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:X-Mailer:MIME-Version:Content-Type:
	 Content-Transfer-Encoding;
	bh=+FdxbDW163sXl7PSrtKq2x3hScBeEWK+b0ZUQ8/Dwtw=;
	b=axtubDvReF5/IwHLafjiH/IPRm1Q5wAF39GrHi1LbCma3mUeqM4194We/HoM8pTkPtPX
	 9aRaKQBQUiQWhkh4MosLZ1K95xVacdy0lg2tsImboJY1fEEmdeZIvQj2w9VD8pWMwGWt6
	 QB5VmH4jUtDy9wD+5rlZ2NX6POYB4rVz1SKdz8FSeBjyntbNR7LntnjzkN8ncM7fSs68d
	 zzs7xHTAPSBOFiHismiq0V4gf9OFfZem6fL2Ct/j1aCxxxzr+DM5P655x1MGAV5IKzU0k
	 vxxHWjMNO7xR6fiuD3jNQwceEHZ9w1oATWDtpuwlmGXibz0GBrb405EpRYzCcDvU3DA==
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=20251104 header.b=laJovtXn;
	arc=none smtp.remote-ip=74.125.82.172
X-Received: from mail-dy1-f172.google.com (mail-dy1-f172.google.com [74.125.82.172])
	(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 E0165606A31A
	for <netdev@vger.kernel.org>; Thu, 22 Oct 2026 09:14:34 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org E0165606A31A
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-dy1-f172.google.com with SMTP id 5a478bee46e88-33fb4680717so3990923eec.1
        for <netdev@vger.kernel.org>; Thu, 22 Oct 2026 02:14:34 -0700 (PDT)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20251104; t=1792660474; x=1793265274; darn=vger.kernel.org;
        h=content-transfer-encoding:content-type:mime-version:message-id:date
         :subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to
         :content-type;
        bh=+FdxbDW163sXl7PSrtKq2x3hScBeEWK+b0ZUQ8/Dwtw=;
        b=laJovtXnSYFUn2fHAoo9hWJWxpjWrfAl2s7kwQSMXaYBwObYltX7rx7y040ej7nREH
         PLwyGlaBZj3720EWPYkuj3GZU5VUCwfr+f4EmF1XBWXDiFOMgHsv6VeBXljb/tptahtx
         DdDQyOOhWljYrsKPRM6fLg8x0X1EogYFtg7kg6t+38N57AMking25uAwArcZ+qLqLgXm
         vFY0wj09bUfnY1Ia0Lc9fgoqgtr+fMorLPnnC0KNQ/CPYf37HbnGMQIpGxOo1xxtnG8x
         Dj5SV7yjIcH4MVaOBPy1ZlqdkrLhSUrGRjFZuznMfZEbLeuw5KFCBhaEScsdROjKU5gD
         hK+A==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20260707; t=1792660474; x=1793265274;
        h=content-transfer-encoding:content-type:mime-version: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=+FdxbDW163sXl7PSrtKq2x3hScBeEWK+b0ZUQ8/Dwtw=;
        b=Dkj45HZFqbRAgRCxd+sOSmJ/eFgnIWLZvd5KL1aMSV1Am/tiKy4CLnpBmgwJnqCb03
         5NmoGpEpD2ZwuvsPu/WMS+ECYlN34R9zIhspK7lLbr9Y3ow1PovSM1SOkZ5Xz3StpoVd
         w5PlvgUwX1y3A0z0PwEmzK/BFL/AfQ4vRvNHDItvBTLM84kKBssgeYrPSXRxLUHsU+40
         0yLpuHZ2yxgXjWpoctNbHHIY5IXc4exVX+YeAwB4R74nJp20s0vJncyLmmc20YjFDaZ4
         IIBJVd8Rs1q9JBXFpZF2ALc7kYOnQzXgmj3vlN8bJ2QjKl6CUaW6txRTfN4vGwfYu6kc
         QKbQ==
X-Forwarded-Encrypted: i=1; AKwUvBxX/Kh60vI487gw6zsQIRPpyOPYTXNl65EzQJj+GolK1bcsNo9C9FnOYKUzt74MqWWo+jP2Bxs=@vger.kernel.org
X-Gm-Message-State: AFq9FYJoHZha33/YT9wm+nn/pFftRKZV5G7TWe7cVwVQmXZXhjkSr1dV
	CoitlLIRKKVcIcdvlUY3sBDW/8AS7eI63uNru54mIrwcGIoqrachhlaO
X-Gm-Gg: AYBFou0Xe0OJcDcJSG/ZZ0wTkpQAYxO6pqoCAvHh2NvdkSgr67dHK85DZzWBoGfFpkD
	tM2WC8ukNMepK3g3ipls7v2khj6wl5O+uJ5gf3Yppw3ultehLxAij28al1oj0sdFWxwLv5oKgY7
	HnnfcBsrV4r0hCzVPfC2HMGrAPMy3sWBA2h89kkZHMAIT2uqIKgQYgDXkN3PP+Xj/VBYHVTaUho
	uaCGl5HOTEGJTlY0FsKQs+N9czCEkhxa1pCBSSNMGm3h1FLBQJ4LmFHPX8uLzUnVkIMys2b0x6+
	XbYRbXLfEd3iz5lISnzuOPhMeyV84yOhVsJ0l+0K76gn+jPMRRDNKK0wCCEGmWJglJ6NlvUoPd6
	lbcwh37tEbGBPGo2BEHXfIjzBo5q8UG+cjWtdD58sR92JegPuvOlM0R7OUk/gR2y4V8jXlRklum
	T+2KrJHslAbnNIgxABugoKxeRwxeC+nwND/sGboIGEh/J26wFK5mx/J9nLmZRD5jqNRSBvcEXWC
	lRX8RUS5FXFMDzh6XXrn/mZpQsagpz2+3Tazfsm0AgZyTvD43lu35aIAKrO55h9FfagkWDA7TBV
	GvJV5SpildR/ruQs04eKTlSIsTB3pL861qzcrpjq
X-Received: by 2002:a05:7300:7aa5:b0:360:8a6e:640f with SMTP id 5a478bee46e88-3674e64d8ccmr5989884eec.39.1792660473992;
        Thu, 22 Oct 2026 02:14:33 -0700 (PDT)
X-Received: from youngkk-vm.localdomain (67.216.200.102.16clouds.com. [67.216.200.102])
        by smtp.gmail.com with ESMTPSA id 5a478bee46e88-367416a1fb9sm12845003eec.20.2026.10.22.02.14.30
        (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
        Thu, 22 Oct 2026 02:14:33 -0700 (PDT)
X-Cc: Andrew Lunn <andrew+netdev@lunn.ch>,
	"David S . Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@kernel.org>,
	Jakub Kicinski <kuba@kernel.org>,
	Paolo Abeni <pabeni@redhat.com>,
	netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org
X-Mailer: git-send-email 2.34.1
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