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 4109F37F734; Mon, 9 Feb 2026 14:39:37 +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=1770647977; cv=none; b=gIs1dhIpTpcCRGYIZRKKBaJxeo6lkWjnLOc7LMT+dVsAFH61NRjRWNdjvGM4weAj0KqW1cTEusde//+6URrhV5nHbDGyWb5Lw9b2TWj4WoG3K53jm82ohSPOrUiavBKGkWTDIASnCOuS3WXjRp8H8JPT2sA3xtRT60eme8v0NEc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770647977; c=relaxed/simple; bh=1ckv9Wcq9VLkx0qZnskWfpzrY7i0ClehK4Oq1ugkX4k=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=N6oxs8diAG9PHIQ1Cou/Cy1vo6KAvNXkkGT9LSJMa5q7CSshu3hNF/HLLMre/suqHK2x2oRxcjEHn8rfn23N86ECo3nPVh//kGxkgGVj1upui8Ycdv4b8ZWwwvr+wmzi08fEqkenN+tjOTV1ju5KcFFfZw1sibUX38KuFy7esIA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=xjLDpUIF; 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="xjLDpUIF" Received: by smtp.kernel.org (Postfix) with ESMTPSA id BD4E9C116C6; Mon, 9 Feb 2026 14:39:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1770647977; bh=1ckv9Wcq9VLkx0qZnskWfpzrY7i0ClehK4Oq1ugkX4k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=xjLDpUIFv9DrgaGJdKcQ5bFr0Y76C8IRTttfya7UD7IkiL6v9DfokYpLSTH+tgiAg aZOiI3qN0wvq/BNQmO+wf4mezPBlM3ozn4+XaMSyuewtHd4IKqIiMnk2INVWxEPbvZ fqbtckOTGAfIPvLHtkClZyPGHeyz6pfA+3MIxwyE= 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.12 084/113] dpaa2-switch: add bounds check for if_id in IRQ handler Date: Mon, 9 Feb 2026 15:23:53 +0100 Message-ID: <20260209142313.201537545@linuxfoundation.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260209142310.204833231@linuxfoundation.org> References: <20260209142310.204833231@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.12-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 84c7079d8672d..6ea58fc22783f 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