From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796387287; b=xJmac1vWMz/GJNmP2Oxz4lt/TKIpFmXzSYYIKo/wjwwcP3ve9QFMXK63oD8NcYutFoss VZ3OlUCUyxCSrvEqi9guucMg/+DhmBdm8Pls5FnKMgqoC/QOH89vakvFTDGs93GkXUNQU Sx13M9F5XmqBvASlAifTnmm93swK2sGyu+qSWoq2hm2NsRlYn4sL1zkJdFZUOFFQRMVKX ZE9mHW4cvlwYiPyxJLuzADhxoTU0ZD8wCprs5oQ4EaxN4/rIqEih2uoILnN6Q1KrQyGZi dXjypC5bzxLPlR1nbEXCRFDaYuBqhbFNT9GeI5er77xmRmvko6cEMTneGaGL7UkEyoQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796387287; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=8FKIFefpGMB0+KJOZ5v0sxlCf4wtCozOCDmU9mNMHYQ=; b=G9opKRcVhbIPo2uTO0gQhYJ8T/L7LLLlQmb+OaQu4FIoKEPNjpFMVliwEj3+gD6EWpK2 hDTU9GKvdT0HYW8nQWMfOJNbdRJgDkCQLLTIYKsQIpjC8vFiR5DBicL9+cwlyUVlt0nBP jwwKEebP4VJPynLus4eCB703ZI/SNerc471WNhFpAWE88JUkF5mKOy/ZfqTGgPnVQHM9F Gz5bY6rTyEK0Dj5dKcAwWhX5Qj09EYOIW1X+r2aJ4fpYkDRhE03AK1ZCCR0Djtl3in5Tw Ap764q+RhYLF2vRYt9+Zia//3sMESARimqcXAXnl4f9ZqAmjj58cqs/yNSrbbnvpVZA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=FA1KI7DN; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B9FE2606A322; Fri, 4 Dec 2026 12:28:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=FA1KI7DN Received: by smtp.kernel.org (Postfix) with ESMTPSA id E972D1F000C2; Fri, 4 Dec 2026 12:28:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796387287; bh=8FKIFefpGMB0+KJOZ5v0sxlCf4wtCozOCDmU9mNMHYQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=FA1KI7DNB8E98aHnohIJZZllnoGQOjasJTU/JP/RoJuio72AcQ7vl23O0hyq4VuDE Wo5LX3z3ytJAQc0QJpI5/tyk5Uy+o3rmbUHTCUGNWH2sy9jz4HKb4QmYoplNocG8HX kPBOx0pzU7rCUpwsseHfL9lNMRgsCCrQWNLZPDyg= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Umang Pokhriyal , Willem de Bruijn , Jakub Kicinski , Sasha Levin Subject: [PATCH 6.1 0181/1059] tun: delete the flow entries of the moved queue on detach Date: Fri, 4 Dec 2026 18:55:12 +0900 Message-ID: <20261204100648.966923094@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100643.980430235@linuxfoundation.org> References: <20261204100643.980430235@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: Umang Pokhriyal [ Upstream commit 4cc0a3f897074cea28dae38f1cd9bb230dae5d86 ] When a queue is detached, __tun_detach() moves the last queue into the freed slot and decrements tun->numqueues. The flow entries that point at the old index of the moved queue, now tun->numqueues, are meant to be deleted, but the call passes tun->numqueues + 1, an index that never exists, so nothing is deleted. Until those entries are refreshed by a write on their flow or age out, tun_automq_select_queue() returns an index past the last queue, and netdev_core_pick_tx() sends every such flow to queue 0 and warns: tapq0 selects TX queue 3, but real number of TX queues is 3 Found with an LLM while testing how a VMM detaches tap queues when a guest lowers its virtio-net queue pairs. With four queues, 30 flows learned on queue 3 and queue 1 detached, all 30 went to queue 0 with the warning; with this patch they are spread by hash and no warning is printed (3 runs each, in a guest booted on net). Pass tun->numqueues. Fixes: 96442e42429e ("tuntap: choose the txq based on rxq") Signed-off-by: Umang Pokhriyal Reviewed-by: Willem de Bruijn Link: https://patch.msgid.link/20261104174240.138491-1-umangpokhriyall@gmail.com Signed-off-by: Jakub Kicinski Signed-off-by: Sasha Levin --- drivers/net/tun.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/tun.c b/drivers/net/tun.c index 1b4700feed4db..22f35e92f5424 100644 --- a/drivers/net/tun.c +++ b/drivers/net/tun.c @@ -671,7 +671,7 @@ static void __tun_detach(struct tun_file *tfile, bool clean) } synchronize_net(); - tun_flow_delete_by_queue(tun, tun->numqueues + 1); + tun_flow_delete_by_queue(tun, tun->numqueues); /* Drop read queue */ tun_queue_purge(tfile); tun_set_real_num_queues(tun); -- 2.53.0