Article View: linux.kernel.netdev
Article #6348[BUG] net: tun: flow update can repopulate a purged detached queue
From: Cheng Yongkang
Date: Thu, 22 Oct 2026 09:13
Date: Thu, 22 Oct 2026 09:13
45 lines
12321 bytes
12321 bytes
Hi all, tun_get_user() checks !tfile->detached before entering its receive RCU section, but calls tun_flow_update() after leaving that section. Queue detach can complete between those points. Detach's synchronize_net() does not cover the hash computation made before the RCU section or the flow insertion made after RCU unlock. The late write therefore installs a flow entry with the detached queue's queue_index after detach has already purged flow entries for that queue. A matching TX can then steer to a detached or out-of-range queue. Observed on Linux v7.3, commit 08ab31164c55f20c7a2653de3186ae333470e2c1. A two-stage GDB condition observed both: detach completed its flow purge tfile->detached == tun tun_flow_update() still ran queue_index=2, numqueues=2 The later TX produced: tun0 selects TX queue 2, but real number of TX queues is 2 The condition was hit in two independent runs and is distinct from the purge off-by-one in candidate BR-018/027: even a complete purge can be followed by this stale insertion. The detached state and the flow update need to be covered by the same ordering rule. One option is to perform the flow lookup/update while the receive RCU protection still guarantees that detach cannot pass its synchronize_net(), then avoid using a detached tfile after unlock. I found no matching upstream fix. The reproducer, GDB script, and full logs are available on request. This was found with a multi-agent workflow; the TOCTOU was observed under QEMU/KVM. Thanks, Cheng Yongkang
Technical Details
Message-ID:
<20261022091358.3649925-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-350453-linux-kernel-netdev=dewy.ruShow 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-350453-linux-kernel-netdev=dewy.ru
From: teel4res@gmail.com (Cheng Yongkang)
Newsgroups: linux.kernel.netdev
Subject: [BUG] net: tun: flow update can repopulate a purged detached queue
Date: Thu, 22 Oct 2026 02:13:58 -0700
Organization: Usenet Network
Message-ID: <20261022091358.3649925-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="172442"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:Bs583enm7ileQOE0xrEO89/0PQo= sha256:qSUHALnSFDrSdRHwAVp4SiUtYmqmt9ZKiGaw4RC+CZA=
sha1:BLzF2Bh4Vu5y52JzWiDglI411c8= sha256:rjV3ElPh2l/aEK0XpnycpnfMU+LJDBakYW1ZrN/KkC0=
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 5B5051111FA; Thu, 22 Oct 2026 12:18:39 +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 hQkuJ5x0Onp0;
Thu, 22 Oct 2026 12:18:36 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=104.64.211.4; helo=sin.lore.kernel.org; envelope-from=netdev+bounces-350453-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 863F51111F7; Thu, 22 Oct 2026 12:18:27 +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 823762E7A1; Thu, 22 Oct 2026 09:14:14 +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=1792660453;
b=HC6HUD4wHNpQDgfn9o2VGPWvYs/yj6m9PVdxcmieh0YyaSlAsSypu39vjgbCz49lxd/8
cafWpTGsv23C7OUXAivModIsSw9v4IJg4L/g12WgTJJgowXUd32HefGhR7otgVSsFt69p
ZDSYk+/Wyg+CuQ8cn5lgLME4q0vHihOlkPEMyeZho4RyyUTN9Q8XoR1ewIRdjZbKp13vI
3ywr8VZTlereFcuhneP1evLiaAH/wHnNqRyQC6aKW7ygfiNx/bKtlrfNMgUiyv1H97sko
W2nF26pnEAn/rwUa7RSf2XG/8Y5IM03COOC7FGV0YD/vcuQAoYo/8TIv9WghPxf589A==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
a=rsa-sha256; c=relaxed/relaxed; t=1792660453;
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=+9oT4imqO89h7CVLXvxpremnNC03kOCP6LBQBAbm8aQ=;
b=xyHHSVIY8iG3rwucRnEfnDbNE8PmOrVGQcJKZk9BVIupYH4xjQxW6kWL/tIuDbdk3lBx
AGMgf0ZYH3zTsxsHltCLoDamkgmKRoDecVm6EBbYjINF3p9jG3urydoYee67ICbQINDeU
1bkl56JL/KgAPWso/S/WNyLCtdTj/e8eLYi6WlyRYBIqt1jgwKdz7dNu9CBwB7MLk15d0
cxv70kAvxIGo/+DrrOOhnWb+0F58+tkzGq+tzJq/82v5yuNO0Qi2RnEPjfsuRLQmNI8FA
uwGzaGV52tsyC+2DEXdTr9U/O4VeHJ/2Z/CM2xGjrmj6aiwlm/sAefAITr4YkDhBrIw==
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=CbS8nk9f;
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 656DF606A323;
Thu, 22 Oct 2026 09:14:13 +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=CbS8nk9f
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.82.180
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
t=1792660447;
b=iPRivtShVLMPgqJZVdpS5wnMXoq8KopenC05yMgv20Fv+z7UT/wjQns+/ppWAva8w2be
VwLZc0I0Jg1j/7/d//iotE7tSGumvk/CJ1mk+GFXs3JdbYeY1IZfwn4/eF/CPorEoJD53
t2XmkZ2QfTaCSBrL7kCMVkkLsHa7aq/S3edmnT/4tnBYiXtOdXQM3wD0V994PLh51CrNK
MlwXu2VXANbTiLqzif9dVqkbI/ntbPlJrckzL+s2Pf7ivNP6Uc/neBem+SNBfrmQ7/07O
QdjwlHHRvNQKt9215Opgv1PC5IfO3LRDBpkM6HJWXm3MrEfDEYbYwuliQKO07pLROAw==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
a=rsa-sha256; c=relaxed/relaxed; t=1792660447;
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=+9oT4imqO89h7CVLXvxpremnNC03kOCP6LBQBAbm8aQ=;
b=JtNlVGDgVcbBxhzet39GbiEi2c798YB9tzhPHNPyJBLN6+UkvDbpk5/Pa3aUupOI7U8l
tTmiMq7N4VWFtNXQ7nML0mkHq7O2LJBbYnySg9v27LMD34ASTMJShNUtw6UYpCW/r8rzK
G4KiHZV9pK6tia0INZ9Zf9CHrSlATqskRBdTC1uX9Gra9IDJLKSWCf6KhUAUr+4ccam1A
UI0mSOhCfNRsxW7n0DM11D5Gv07XryUWZ59dSit3G4LxNOmjXv6Ij6BYma37hcub8l22+
lTbf+P+3nSvzVRJfEhOwq8vQ7bVIDijrR3cymABzMveI8DSxxQFdmAEOMTresAkokZw==
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=CbS8nk9f;
arc=none smtp.remote-ip=74.125.82.180
X-Received: from mail-dy1-f180.google.com (mail-dy1-f180.google.com [74.125.82.180])
(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 33DF9606A319
for <netdev@vger.kernel.org>; Thu, 22 Oct 2026 09:14:07 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 33DF9606A319
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-f180.google.com with SMTP id 5a478bee46e88-35f1f76ea84so2359521eec.1
for <netdev@vger.kernel.org>; Thu, 22 Oct 2026 02:14:07 -0700 (PDT)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=gmail.com; s=20251104; t=1792660446; x=1793265246; 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=+9oT4imqO89h7CVLXvxpremnNC03kOCP6LBQBAbm8aQ=;
b=CbS8nk9fkQttCIGca4DgbM3jNHnogueW7r8s22CgeBshvtIgS8J3/0zXYw2a2XRJem
g2aDx72b/vDDre35lOA1+TwKVoJRtP531DHwhNl/UqNLZKoZJp7L2oR8QMbZZ8RAmecc
9J0z+0Mk5bgDyK7hm6+Fye2lnOBIYTa20yfUe3yV/vc6yGm6yZvCyFcvh3y1+PBgHFEN
UmThTWLK96bgkLScd/z2yAJm0EEHv6XyrKZnqFvvOjrE7K0ziDahnV6ijp+cXwl3aJMS
gYGZwZVHLM5EUQ2YLpI3P6XciI9ktWelTHeUyLYZ2Ty4Xkm28X2mwQKI3YX2QjJ16A8h
hLSA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20260707; t=1792660446; x=1793265246;
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=+9oT4imqO89h7CVLXvxpremnNC03kOCP6LBQBAbm8aQ=;
b=gAOukkHdL3Hglvyt05oWQZtwbO53WK2/qseSRBp/D+FerJvA/Eqanf8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Zj
iIYgPFZv4t0PdpnCTZge5eGY/akavF/6VLk2jN5wWnTtJ/bNMd4WBGSahXaYAuo5pcXKhy5IyGE
iM3Pk8zwWh8l/gOlLYg=
X-Received: by 2002:a05:7300:6c85:b0:35f:5591:e40c with SMTP id 5a478bee46e88-3674de4ca70mr9773380eec.22.1792660446301;
Thu, 22 Oct 2026 02:14:06 -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-368ca914bb8sm5375478eec.5.2026.10.22.02.14.02
(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
Thu, 22 Oct 2026 02:14:05 -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