Linux SCSI subsystem development
 help / color / mirror / Atom feed
* [PATCH] scsi: leapraid: bound the phy index used to update card links
@ 2026-12-04  6:29 Hongyu Guo
  2026-12-04  7:00 ` sashiko-bot
  2026-12-04  7:29 ` Hongyu Guo
  0 siblings, 2 replies; 4+ messages in thread
From: Hongyu Guo @ 2026-12-04  6:29 UTC (permalink / raw)
  To: linux-scsi
  Cc: Dongdong Hao, James E.J. Bottomley, Martin K. Petersen, stable,
	13057616121

SAS device page 0 provides phy_num, which leapraid passes straight
into leapraid_transport_update_links() as the index into
topo_node->card_phy[]. That array holds phys_num entries from the
IO-unit or expander page, and nothing compares the two. A controller
that reports a larger phy_num in the device page than the parent
topology node has makes the driver write past the card_phy[] array:
attached_hdl and the fields filled by
leapraid_transport_set_identify() land in unrelated slab memory.

Reject the update when the index does not fit the target topology
node.

Fixes: 5597088c9e79 ("scsi: leapraid: Add new SCSI driver")
Cc: stable@vger.kernel.org
Cc: Dongdong Hao <doubled@leap-io-kernel.com>
Signed-off-by: Hongyu Guo <guohongyu@cmss.chinamobile.com>
---
 drivers/scsi/leapraid/leapraid_transport.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/drivers/scsi/leapraid/leapraid_transport.c b/drivers/scsi/leapraid/leapraid_transport.c
index 77ffbd6ddce4..7468276b4a10 100644
--- a/drivers/scsi/leapraid/leapraid_transport.c
+++ b/drivers/scsi/leapraid/leapraid_transport.c
@@ -1146,6 +1146,15 @@ void leapraid_transport_update_links(
 		return;
 	}
 
+	if (phy_index >= topo_node->phys_num) {
+		spin_unlock_irqrestore(&adapter->dev_topo.topo_node_lock,
+				       flags);
+		dev_warn(&adapter->pdev->dev,
+			 "%s: phy index %u out of range, max %u\n",
+			 __func__, phy_index, topo_node->phys_num);
+		return;
+	}
+
 	card_phy = &topo_node->card_phy[phy_index];
 	card_phy->attached_hdl = hdl;
 	spin_unlock_irqrestore(&adapter->dev_topo.topo_node_lock, flags);
-- 
2.43.0




^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-12-04  7:38 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-04  6:29 [PATCH] scsi: leapraid: bound the phy index used to update card links Hongyu Guo
2026-12-04  7:00 ` sashiko-bot
2026-12-04  7:29 ` Hongyu Guo
2026-12-04  7:31   ` guohongyu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox