Linux SCSI subsystem development
 help / color / mirror / Atom feed
* [PATCH] scsi: mpt3sas: validate data_out size before SMP link-reset check
@ 2026-10-15  2:07 Weibin Liu
  2026-10-15  2:22 ` sashiko-bot
  0 siblings, 1 reply; 2+ messages in thread
From: Weibin Liu @ 2026-10-15  2:07 UTC (permalink / raw)
  To: linux-scsi, suganath-prabu.subramani, sreekanth.reddy,
	ranjan.kumar, sathya.prakash
  Cc: linux-kernel, James.Bottomley, MPT-FusionLinux.pdl, mkp, stable,
	Weibin Liu, Guanglei Zhu

_ctl_do_mpt_command() handles MPI2_FUNCTION_SMP_PASSTHROUGH by reading
data[1] and data[10] of the data_out buffer to detect SMP link-reset
requests. The non-IMMEDIATE path sets data = data_out without checking
data_out_sz, so a request whose data_out payload is smaller than 11
bytes reads past the end of the DMA coherent buffer, and out-of-bounds
bytes can silently set ioc_link_reset_in_progress and ignore_loginfos.

Require data_out_sz >= 11 bytes alongside !data_out before touching
the payload. The IMMEDIATE path reads within the request frame itself
and needs no guard.

Fixes: f92363d12359 ("[SCSI] mpt3sas: add new driver supporting 12GB SAS")
Cc: stable@vger.kernel.org # 3.8+
Signed-off-by: Weibin Liu <liuwb@xiaopeng.com>
Reviewed-by: Guanglei Zhu <zhugl3@xiaopeng.com>
---
 drivers/scsi/mpt3sas/mpt3sas_ctl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/mpt3sas/mpt3sas_ctl.c b/drivers/scsi/mpt3sas/mpt3sas_ctl.c
index 8bb947004885..ae9b2be51ce0 100644
--- a/drivers/scsi/mpt3sas/mpt3sas_ctl.c
+++ b/drivers/scsi/mpt3sas/mpt3sas_ctl.c
@@ -968,7 +968,7 @@ _ctl_do_mpt_command(struct MPT3SAS_ADAPTER *ioc, struct mpt3_ioctl_command karg,
 		    MPI2_SMP_PT_REQ_PT_FLAGS_IMMEDIATE)
 			data = (u8 *)&smp_request->SGL;
 		else {
-			if (unlikely(data_out == NULL)) {
+			if (unlikely(!data_out || data_out_sz < 11)) {
 				pr_err("failure at %s:%d/%s()!\n",
 				    __FILE__, __LINE__, __func__);
 				mpt3sas_base_free_smid(ioc, smid);

---
base-commit: 24a19b953e2a3d0ea5a8c4951a0ab8f32720c907
change-id: 20261015-mpt3sas-dataout-sz-a8a0b367cd4f

Best regards,
-- 
Weibin Liu <liuwb@xiaopeng.com>


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

end of thread, other threads:[~2026-10-15  2:22 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-15  2:07 [PATCH] scsi: mpt3sas: validate data_out size before SMP link-reset check Weibin Liu
2026-10-15  2:22 ` sashiko-bot

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