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=1796384721; b=OU9KUMdi+lmfa4z1dDvdepN0cp+iL8hc9Sr/PA57bdlOqELllJVm3Djxk+6DH6/tkCI8 3hxjeYsCddlRi9gQminaAsfYUhJRq8S9rk9HksVpWXv74j55VSZNb4FUyXI8QSgqvjq3T WeAfEXvMmlQNI0L48GRmr5wkAJ3CRlLvZg0gFEQxuSmeZYfm6G1inhLcJNG63RJDRpnWZ QMtm6Y7pMxZuc5uKfiAQwjfz0iiZ7/RM78HHtfMamJaGiPf/j2u/EljfXtjLk6W0xo6po mV41nIsisc8zM+sGDOPT+q29XRnYts9wRbGx22yd26ciGdazUnRxMBhwtQv02CP/6Sw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796384721; 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=QqvuVDR1wMeT5oq4kBRi/R9vXeYh6ARUykoalvjeaJM=; b=NEoYQ2TuTgTAbHqTQ/NaS/E0jimBzeNkq9DVfTYuQNBs2sCQYzFiV8cUcE8642kqmkWF nDYfK8JWtBzmscxJweabtulip3ZW3+CcLN6FPu77IFGH+O6AYnQFtjDN8quZJDPnDAKdm ktgQpf05oUaRm9sZP3Bq6UOm/ciyzhYg4etHkT7LJcy0hBvAQqkK1iim70kCZBrqXEPVt 63iLcTKDhDjWzd2/qHilYmB7Fl5r9zY74u6WoUKEMEsxJXjSfxw01+GFlugXOg23KHNHK MuUe1xR1KDJsdmG9oy+frmmOtRz2wm0xw5Po61kl/zWb7BlzOIUosaiqotDtshWN4Kg== 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=gOgyvrz7; 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 5BC1A606A32C; Fri, 4 Dec 2026 11:45:21 +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=gOgyvrz7 Received: by smtp.kernel.org (Postfix) with ESMTPSA id C95481F000CE; Fri, 4 Dec 2026 11:45:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796384721; bh=QqvuVDR1wMeT5oq4kBRi/R9vXeYh6ARUykoalvjeaJM=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=gOgyvrz70FHVj4lHtT50OkaI6dj5UM9tyN1T24WXhugHOy0xxhO61036s74ZVRT6/ X514sFeCzBhgiX+VcjowhsQde7F7dKN+8gbZlnpNJgjmXUt5YMmHouwJFpWPL+qOQu 6f7XqFAG9oHkBQCS1yRGJoDp66eGcgEPIgaMf3/I= 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.6 0238/1167] tun: delete the flow entries of the moved queue on detach Date: Fri, 4 Dec 2026 18:54:25 +0900 Message-ID: <20261204100708.271459418@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100702.047403948@linuxfoundation.org> References: <20261204100702.047403948@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: patches@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.6-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 c3349bcff7ab1..df752791ecabd 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