From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CFA052690EC; Mon, 9 Feb 2026 14:48:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770648530; cv=none; b=U9B7UbP1/Z5Hm/7dshktkIxTWK7YayLIVgnYAavKMuJkPscPUgSuHDEISJgi8yq02PZbeCAWPtXVsclLZf/1ISmn070vLCmy44NnB0Aaw3qBnhtAg5PS5UZq8czSJaqLuXN7t7E4mIrYJN/X2Tuo7B242C0FkauTYUpQetLPcdY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770648530; c=relaxed/simple; bh=p8Ri8Kw3xlXEciE6OybU3YTL7jLk1jykZngo03CxJDs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=VuPNMWqnyStaS5OoidPLGMJ04v04elxDP3e1DBihWcfBTC+JIHEh5Kt3h+HnhgyuwoYZejfG/c4FK4/A/ZTa39pUZ2BVPglOseRad9Gh7t9Q+pTT2H+loLDHVQwjY2q1tTshp1NRBu5c4fUcY9lMkeOjq9sM5QPb8mwZwuviKEY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=CyepEZWI; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="CyepEZWI" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 57520C116C6; Mon, 9 Feb 2026 14:48:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1770648530; bh=p8Ri8Kw3xlXEciE6OybU3YTL7jLk1jykZngo03CxJDs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CyepEZWILqk1FYmeVQN0llDANkXD7ncjKSA/U/oCXf2HSgMtC7kjX+i9uv+Jcv6FQ DFOaeYIQP2Pu2u4x+DfFzi5S1CpY4/WyYABrdmsfduAiHxwqmP6QnCqydvLJtaAj1A doJVooT29egDWSlT3dwq0YM802LQtG77Jw4yDzBg= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Yuhao Jiang , Junrui Luo , Jakub Kicinski , Sasha Levin Subject: [PATCH 6.6 66/86] dpaa2-switch: add bounds check for if_id in IRQ handler Date: Mon, 9 Feb 2026 15:24:29 +0100 Message-ID: <20260209142307.152382938@linuxfoundation.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260209142304.770150175@linuxfoundation.org> References: <20260209142304.770150175@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Junrui Luo [ Upstream commit 31a7a0bbeb006bac2d9c81a2874825025214b6d8 ] The IRQ handler extracts if_id from the upper 16 bits of the hardware status register and uses it to index into ethsw->ports[] without validation. Since if_id can be any 16-bit value (0-65535) but the ports array is only allocated with sw_attr.num_ifs elements, this can lead to an out-of-bounds read potentially. Add a bounds check before accessing the array, consistent with the existing validation in dpaa2_switch_rx(). Reported-by: Yuhao Jiang Reported-by: Junrui Luo Fixes: 24ab724f8a46 ("dpaa2-switch: use the port index in the IRQ handler") Signed-off-by: Junrui Luo Link: https://patch.msgid.link/SYBPR01MB7881D420AB43FF1A227B84AFAF91A@SYBPR01MB7881.ausprd01.prod.outlook.com Signed-off-by: Jakub Kicinski Signed-off-by: Sasha Levin --- drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c b/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c index 6e3f65e3e8821..37e3224262ed4 100644 --- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c +++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c @@ -1530,6 +1530,10 @@ static irqreturn_t dpaa2_switch_irq0_handler_thread(int irq_num, void *arg) } if_id = (status & 0xFFFF0000) >> 16; + if (if_id >= ethsw->sw_attr.num_ifs) { + dev_err(dev, "Invalid if_id %d in IRQ status\n", if_id); + goto out; + } port_priv = ethsw->ports[if_id]; if (status & DPSW_IRQ_EVENT_LINK_CHANGED) { -- 2.51.0