From nobody Wed Apr 1 08:37:52 2026 Received: from mail-oi1-f171.google.com (mail-oi1-f171.google.com [209.85.167.171]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 49BAE264A9D for ; Wed, 1 Apr 2026 05:09:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.171 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775020143; cv=none; b=iqol4s8jcwguZ23zKK8+cuOR1ewSaRvXbTQ1534vDhG6eHtrDcPdff9BsYqA7eJbglTvuIiJaKVbZbLlIRtu9xYGBVL3xlXnP5aOuMwhw9op0FuRDFzpEJxAXVrX/TLLrYBzJ2uPfZOt5AtmvFBeiQVyO8UGTPC7SJHSjoKtA04= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775020143; c=relaxed/simple; bh=0iOuv2Jk9x6VT70uTCLFtSjtEKSW2vWQw9+L9R9XNyw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=hBY+5kyPkPn1FlKJBYTvtSoo4XYKnI8ptIrrbdrZyJvs7kRGrfJQrjyJAlk8RuzJVuTaqXSPKaIwpRNlYp1RFY8qr80nEzaJcEQoKFEq71Jlb+pNU69PLDksCygl+Q6vFfGKa6acZrhwK/40lSVz0mEKL36Ss4W1lGMCXTjAKvs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=bLlwu4hx; arc=none smtp.client-ip=209.85.167.171 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="bLlwu4hx" Received: by mail-oi1-f171.google.com with SMTP id 5614622812f47-4670676ba03so2103898b6e.1 for ; Tue, 31 Mar 2026 22:09:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1775020141; x=1775624941; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=x4ImYOWTG5LWu2AjZ0ViLWPRevzakMzCKB1uXh/hzS0=; b=bLlwu4hxGnKqbqM3eyubQnFER89IlaGgRcUnqrI3u7d3Oi4KXavH5J9s3gjmjAZYWw Kf8xNdcikqXnhqBediZGmSWMrUbYorEwtm/JGWHVLFLTukMxNVPldH6gMSX8LMtFTS6d iXEt9znnUcx8rPaq4Q4RpbUuoFcYpzcnGWg9YJ0u4zF9PC+3xxj03/itaohjENy3Xr7I 8Z7SfvzSGH8MOWRge2gl0USsMduw3o+CseJvqqnuP7UMAN4LSFmRKyWhyWblME7cMULV hqsOSfhCvpO5hntuuH3aLT1CJ4CA9kYU0F3iraJbBsFiquSfZMmjQFZyfVXUcms2MBQ2 oFow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775020141; x=1775624941; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=x4ImYOWTG5LWu2AjZ0ViLWPRevzakMzCKB1uXh/hzS0=; b=VOyZXN7kXND+WdHmkpqPwJBo7pOaAYiudDrj2tBswjnQw72snamScQAzQL/w5uZOPc ZInXW4WlM6czJLM+rIKJID9IDM/t+ZL2uCtLdFoEVS4KSFg1FYIAa5LCCYf62EZMwVOj 9LnHRoCF51Hgn46K87HVsumU6rG0mAvaK09mlIp3q5Xmv0rvXUrIqAzvEl2i00jiHjv/ ybGs+R6+s3mtla5zJ1xY9diTi6vb2wDs+f5fMf4LxN8nutbgAPal43YDa0QkqzNE6pW5 LtxPtXGcKzJQp9s43pg/tEyVF1fsKrdE+HdiJLiZBW8r9ScDRMAoR0N9QmhS6U2uXOC3 DRuw== X-Forwarded-Encrypted: i=1; AJvYcCU1oeZxRaTEMiihnljjVFIiLoyYQQ35TDAnMZYORRHizuuW/vtayLuseHKevBT9YEyvoHAJkxmecHlDq2w=@vger.kernel.org X-Gm-Message-State: AOJu0YzNWllG0f2jrnkBiPtVX4M0xHYVJksmVi8mIT6GUpJB7BWBkrDO 2pJuKaCf043zH+OzKHUTCU8bUE/kPB7Aw/LNMXClB4jnbcPimTMNF3iq X-Gm-Gg: ATEYQzxsbQilEiVVrpt0U2XYx+RdivD1Kba10apa23A7wxu2iGBbpl9UDBJt3RwHJ/w BcfXwAG0x0/DqXwvkpd+fQE5NSWaTD8Izgg4QrqUZA8K8VayUjGtmLTkTNiXldiHUkIOoMkwiVG BE22W+ydUFdFLP5KKnO8JE7s/MNdmqeSmWquG+b0CwpHB92HQr/dbX1fHuckkHWx4kyXmtOEyF4 YJujHfzgEbzItRIugw//9tPtq3wiNleoVTNIGRfm0pKyMg4T4IcPovMUu2nnGP7KmyaQOi+uGbU Ey3CqIYEcpNxJP7kiAbg3u1lSfTWhW7vWyDp25dEZX6ZciArUs5IzB2WyzTHfJkjzv9HcKA4llZ SYvG0HW8aZNqsDdx0fnCZfCuSDi2bgT/2HtRWWXaj9XxPUhqzk2Szv98gUBUkdNqet6cJ7hFIea SAP3ixGW0EWHDu4wYr/E5/5nb13hCGJByi+4SlEJacG3dIX719mFNIZtSpVE7Eo1DqCjmNRVrD0 RjJ X-Received: by 2002:a05:6808:670a:b0:468:12a9:d54e with SMTP id 5614622812f47-46ae01a4d6bmr1037751b6e.44.1775020141070; Tue, 31 Mar 2026 22:09:01 -0700 (PDT) Received: from CS-396-Lab-Machine.. (c-24-12-10-127.hsd1.il.comcast.net. [24.12.10.127]) by smtp.gmail.com with ESMTPSA id 5614622812f47-46aa0efdb75sm8015785b6e.13.2026.03.31.22.08.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 Mar 2026 22:08:59 -0700 (PDT) From: Tyllis Xu X-Google-Original-From: Tyllis Xu To: haren@linux.ibm.com, ricklind@linux.ibm.com Cc: nnac123@linux.ibm.com, sukadev@linux.ibm.com, davem@davemloft.net, kuba@kernel.org, pabeni@redhat.com, edumazet@google.com, andrew+netdev@lunn.ch, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org, ychen@northwestern.edu, Tyllis Xu , Yuhao Jiang Subject: [PATCH v2] ibmvnic: fix OOB array access in ibmvnic_xmit on queue count reduction Date: Wed, 1 Apr 2026 00:08:45 -0500 Message-ID: <20260401050845.1388145-1-LivelyCarpet87@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" When the number of TX queues is reduced (e.g., via ethtool -L), the Qdisc layer retains previously enqueued skbs with queue mappings from before the reduction. After the reset completes and tx_queues_active is set to true, netif_tx_start_all_queues() drains these stale skbs through ibmvnic_xmit(). The queue index from skb_get_queue_mapping() may exceed the newly allocated array bounds, causing out-of-bounds reads on tx_scrq[] and tx_pool[]/tso_pool[]. The existing tx_queues_active guard does not help here: it is set to true by __ibmvnic_open() before netif_tx_start_all_queues() restarts queue draining, so stale skbs pass the check with an invalid queue index. Fold a bounds check against num_active_tx_scrqs into the tx_queues_active guard, reusing the same drop-packet handling. Since tx_stats_buffers[] is allocated for IBMVNIC_MAX_QUEUES entries (not just num_active_tx_scrqs), all drop paths can safely fall through to the out: label's stats update. Also move rcu_read_unlock() to after the per-queue stats updates, as the RCU critical section is already large and releasing it a few instructions earlier provides no practical benefit. Fixes: 4219196d1f66 ("ibmvnic: fix race between xmit and reset") Reported-by: Yuhao Jiang Cc: stable@vger.kernel.org Signed-off-by: Tyllis Xu --- v2: Fold the bounds check into the existing !tx_queues_active guard rather than adding a separate if block with unlikely(), reusing the same drop-packet handling (dev_kfree_skb_any + tx_send_failed/tx_dropped increments + goto out). Remove the dedicated out_unlock: label; tx_stats_buffers[] is allocated for IBMVNIC_MAX_QUEUES entries so all drop paths can safely fall through to the out: stats update. Move rcu_read_unlock() to after the stats updates per maintainer suggestion. (Rick Lindsley) drivers/net/ethernet/ibm/ibmvnic.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/net/ethernet/ibm/ibmvnic.c b/drivers/net/ethernet/ibm/= ibmvnic.c index 5a510eed335e..d5c611c3d9ec 100644 --- a/drivers/net/ethernet/ibm/ibmvnic.c +++ b/drivers/net/ethernet/ibm/ibmvnic.c @@ -2444,14 +2444,15 @@ static netdev_tx_t ibmvnic_xmit(struct sk_buff *skb= , struct net_device *netdev) * rcu to ensure reset waits for us to complete. */ rcu_read_lock(); - if (!adapter->tx_queues_active) { + if (!adapter->tx_queues_active || + queue_num >=3D adapter->num_active_tx_scrqs) { dev_kfree_skb_any(skb); tx_send_failed++; tx_dropped++; ret =3D NETDEV_TX_OK; goto out; } tx_scrq =3D adapter->tx_scrq[queue_num]; txq =3D netdev_get_tx_queue(netdev, queue_num); @@ -2663,14 +2664,13 @@ static netdev_tx_t ibmvnic_xmit(struct sk_buff *skb= , struct net_device *netdev) netif_tx_stop_all_queues(netdev); netif_carrier_off(netdev); } out: - rcu_read_unlock(); adapter->tx_send_failed +=3D tx_send_failed; adapter->tx_map_failed +=3D tx_map_failed; adapter->tx_stats_buffers[queue_num].batched_packets +=3D tx_bpackets; adapter->tx_stats_buffers[queue_num].direct_packets +=3D tx_dpackets; adapter->tx_stats_buffers[queue_num].bytes +=3D tx_bytes; adapter->tx_stats_buffers[queue_num].dropped_packets +=3D tx_dropped; - + rcu_read_unlock(); return ret; } -- 2.43.0