Article View: linux.kernel.netdev
Article #6764Re: [PATCH net] net: xps: bound the cleanup loop by the old map's num_tc
From: Antoine Tenart
Date: Fri, 23 Oct 2026 10:07
Date: Fri, 23 Oct 2026 10:07
72 lines
10729 bytes
10729 bytes
On Wed, Oct 21, 2026 at 11:55:38PM +0800, Dudu Lu wrote:
> __netif_set_xps_queue() walks the OLD dev_maps to free its entries. The
> per-row trip count uses the NEW num_tc while the row stride uses the OLD
> dev_maps->num_tc, so when dev->num_tc was raised without rebuilding the
> XPS map the last row indexes attr_map[] past the allocation:
>
> BUG: KASAN: slab-out-of-bounds in __netif_set_xps_queue+0x1458/0x1ee8
> Read of size 8 at addr ffff000014f69458 by task insmod/112
>
> The loop frees entries in dev_maps, so both the trip count and the stride
> must come from dev_maps->num_tc. The map is sized
> XPS_CPU_DEV_MAPS_SIZE(old num_tc)/XPS_RXQ_DEV_MAPS_SIZE(old num_tc, ...),
> so iterating the new (larger) num_tc reads past the end.
>
> Fixes: 255c04a87f43 ("net: embed num_tc in the xps maps")
> Assisted-by: LLM
> Signed-off-by: Dudu Lu <phx0fer@gmail.com>
Reviewed-by: Antoine Tenart <atenart@kernel.org>
> ---
> Tested base
> -----------
> Detected on Linux 7.3-rc4 (commit 93f51579e7df), arm64 QEMU guest.
> Re-checked against mainline f47d223627f8 (v7.3-341): the affected code
> is unchanged between the two, so the bug is still present there.
> Checked against linux-next next-20261021 (commit 9a482184d910): the
> affected code is unchanged there as well, so the bug is still present in
> linux-next too.
>
> Reproducer status
> -----------------
> A reproducer was written and executed on an arm64 QEMU guest (KASAN); it
> fires at the claimed sink, and still fires on a kernel built with 4da3b7b8b50f
> applied. The guest has no ndo_setup_tc NIC, so the reproducer stands in for
> that hardware with a small module that raises dev->num_tc the same way an
> in-tree driver does. The reproducer source is not posted here per
> Documentation/process/security-bugs.rst; it is available on request.
>
> Triggering conditions
> ---------------------
> CAP_NET_ADMIN to set the XPS mask. dev->num_tc is raised in-tree by the
> drivers that implement ndo_setup_tc (the Intel i40e/ice/ixgbe/iavf, mlx5
> and mvneta families, among others) and by the mqprio/taprio qdiscs. The
> QEMU guest used for the reproducer has no such NIC, so the num_tc change
> was driven through a small module; the defect itself is reached in-tree
> on that hardware.
>
> Notes
> -----
> Built and checkpatch-clean: this patch was applied on top of 7.3-rc4
> (commit 93f51579e7df) and a full arm64 kernel (defconfig) was built with
> it -- no new warnings or errors. scripts/checkpatch.pl reports 0 errors,
> 0 warnings.
>
> net/core/dev.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/net/core/dev.c b/net/core/dev.c
> index e76762e29360..3023f0ca4713 100644
> --- a/net/core/dev.c
> +++ b/net/core/dev.c
> @@ -3003,7 +3003,7 @@ int __netif_set_xps_queue(struct net_device *dev, const unsigned long *mask,
> goto out_no_old_maps;
>
> for (j = 0; j < dev_maps->nr_ids; j++) {
> - for (i = num_tc, tci = j * dev_maps->num_tc; i--; tci++) {
> + for (i = dev_maps->num_tc, tci = j * dev_maps->num_tc; i--; tci++) {
> map = xmap_dereference(dev_maps->attr_map[tci]);
> if (!map)
> continue;
Technical Details
Message-ID:
<atsw048yjNvNmFmk@kwain>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-351010-linux-kernel-netdev=dewy.ruReferences:
<20261021155538.67867-1-phx0fer@gmail.com>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-351010-linux-kernel-netdev=dewy.ru From: atenart@kernel.org (Antoine Tenart) Newsgroups: linux.kernel.netdev Subject: Re: [PATCH net] net: xps: bound the cleanup loop by the old map's num_tc Date: Fri, 23 Oct 2026 12:07:18 +0200 Organization: Usenet Network Message-ID: <atsw048yjNvNmFmk@kwain> References: <20261021155538.67867-1-phx0fer@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: usenet.network; logging-data="469592"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:GvyRo1cYQ2oxOnnQtj4lu6Omusk= sha256:/xF7IYqo9Q3EFlLvfyllsrJeaiVcoix01H3ygG5yH7E= sha1:T/AAnT2/V9qBn1jzzybYZlKyWg4= sha256:jzRAuxr3HfdHbEvlrKYMCu77ES22EAeqtnz4YTVXlEM= Content-Disposition: inline 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 BCA8B111463; Fri, 23 Oct 2026 13:07:40 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.838 X-Spam-Status: No, score=-3.838 tagged_above=-9999 required=6.31 tests=[DKIMWL_WL_HIGH=-0.339, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key) header.d=kernel.org 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 p-zE1foOQi_x; Fri, 23 Oct 2026 13:07:36 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.232.135.74; helo=sto.lore.kernel.org; envelope-from=netdev+bounces-351010-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org X-Received: from sto.lore.kernel.org (sto.lore.kernel.org [172.232.135.74]) by mail.dewy.ru (Postfix) with ESMTPS id A0CF7111432; Fri, 23 Oct 2026 13:07:26 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sto.lore.kernel.org (Postfix) with ESMTP id C4EE6605745; Fri, 23 Oct 2026 10:07:25 +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=1792750043; b=uiBFcuz5W5itKP7xbwu4X29QKMfAiqisd0J0IOLPeUnClDtHR0ECPpx2Hc+3/GT6Pf9w 2xcd2ulNrrbCibWIoD1zxgmihnZ777ve7S3oLvLg9X+nSZk32rdRdankzn5Oq6eDbwaBF O1iZtficSfwcUnPsO8/BCB//6vrCXlWk2JUfD36+yUb1TLiaLN53lJW1BEY/P7rwnIldz PqRbf3faNrRXcQW+rVDemYSI/0uN24/Qf4go3Bxf8C8YmYUYV4YCNDireLOsJ8ID1L7UM KaUXbzkIAGVv8SO2mloClx4++jwpKQPVM6A+J28NnfH5LfumMlB+11zg9rXCA8X+h3A== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1792750043; h=X-Original-To:Received:Received:DKIM-Signature:Date:From:To:Cc: Subject:Message-ID:References:X-Mailing-List:List-Id:List-Post: List-Help:List-Subscribe:List-Unsubscribe:List-Owner:Precedence: MIME-Version:Content-Type:Content-Disposition:In-Reply-To; bh=XQ6Qd7ctqTH9VpQVAVjBYXB1YUNZlX9qcPa7bFOPumQ=; b=KGh1SasUj8uN4/9hHsG+KMs+ce93FkjpbJnsCufKIajb+M+PyPrLXwnehL5tAKrLY6Ua nGl4hY2YVn5c9RzwNBhnUolhKP4kyyzQnL3YkM8Ksa0czX8/0bNXqh9lK/2SVtU9rp7xz 6FG/OptDFaQ75hQ2jvfriJZUGED0fiSQOELtt445p+z7jiwaE3chZI1DrJm840IN/qA6F 0iisCIIsz6fitEO8ScN2MLG6aY1Y7kRLgrytldEMS8V7hm+c1K8cG6dt6oFZMUE/YGPAt YIESoVMKzMD5/QAvTm82IDyoQ6YZoKs7HWHPEU7tfXvGLqAsjcnD7MnmBn7LC4eG+4A== X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=TXGxo9xu; 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 61A23606A322; Fri, 23 Oct 2026 10:07:23 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=TXGxo9xu X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1792750042; b=izdUZI+BCHcOfvrl9Lb0kb11ID26aMZUgHIMqyflYlHFd16GjpDFrKemybkD4viRAUUY YUcMssOmu2EFbwoFcfcpblohy5Bd/IdR5O+lplDuD0UrPC51FZMlznYcAtHNxNjprVbtG ZsLrNzC77oNaV51KEJP05RDoxf+DSxgICHIjMY0Rx0Nv9JRmzIrsuMX/dGTopfqAaXzwn umAYDfMreJX/avGKygS28YqUm/zw8+bEeW97ZONLenHmSGEU2TDU863aesSiUGv6Ra5bd yR1kvXNRWbxjav2J/BbFLCsAMkXSDIA0Sx7EJ6NduRzjq0FMo5Z1qkQ5E4NZa+INE5w== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1792750042; h=Received:DKIM-Signature:Date:From:To:Cc:Subject:Message-ID: References:MIME-Version:Content-Type:Content-Disposition:In-Reply-To; bh=XQ6Qd7ctqTH9VpQVAVjBYXB1YUNZlX9qcPa7bFOPumQ=; b=nrXDFyvs92Nll7W8/tpVhjwq+9nB2xl+duGdUA6ep4Y0LCANLI2NvMPePwzT2D10OY79 W2bOIL4vPxeHIlTLTLfi3Ij61tqSzReZYdBZszj1RGPoyDqseA42eXS4R3JConshDSdFd mlXth3AdNiKH7yuDndad/piMzfSN+aS2Emd5vOHhvbuR25VE6y+1npuU80z5Gd2PgOml8 0LmSg7P8ilbi/RxOpro7dbKcIuOgazBEZZDXA2Eig2YKLeh5n01h4daBGaCy8sE4xPd+s 8Sbo8TN6LUeijXhPOgbkExdDpbAObRkWLoVDangp03W827TAJp4VHlwV3chtmj2FoXA== X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=TXGxo9xu; arc=none smtp.remote-ip=100.103.45.18 X-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 3D458606A31A for <netdev@vger.kernel.org>; Fri, 23 Oct 2026 10:07:22 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 858C11F01825; Fri, 23 Oct 2026 10:07:21 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1792750042; bh=XQ6Qd7ctqTH9VpQVAVjBYXB1YUNZlX9qcPa7bFOPumQ=; h=Date:From:To:Cc:Subject:References:In-Reply-To; b=TXGxo9xuwO/LJzFcJ2SARJZzMcVZVlzPkIyh9HqrUqED2y1v/ooZ3YQn94qYOMeuX NfBMB1F2gKrN0DGQKV5JILer8vNKixFxsyhj4fuMlCBFCIAnD26WEzTHF1/g2rNr7h ercPN5RVLGRm7IVVDFn+/IA/hC+iJ97GNAzXs08ZSLP8QAa5m4aTHxSvLY5GiBLlNZ RwqesT6E1rPQepE/w01UfIAZhubALyZJeiYlZn450+TCXoOsyCsKdIvOli7Kz1FNNC 2fpEq3o3zUcOxv2Xdh2PhAbEJtxVVfsIjS+I1zfwIR2mp10LNrwf6Pxv/wkgWeYS5a h+d6ZObz3a2rg== X-Cc: davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com, netdev@vger.kernel.org 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 X-In-Reply-To: <20261021155538.67867-1-phx0fer@gmail.com>