Linux SCSI subsystem development
 help / color / mirror / Atom feed
* [PATCH] scsi: megaraid: clear ioctl DMA buffers before use
@ 2026-06-25  9:01 Yousef Alhouseen
  2026-06-25  9:31 ` sashiko-bot
  0 siblings, 1 reply; 2+ messages in thread
From: Yousef Alhouseen @ 2026-06-25  9:01 UTC (permalink / raw)
  To: Kashyap Desai, Sumit Saxena, Shivasharan S, Chandrakanth patil,
	James E . J . Bottomley, Martin K . Petersen
  Cc: megaraidlinux.pdl, linux-scsi, linux-kernel, Yousef Alhouseen

The MIMD ioctl path reuses DMA buffers from per-adapter pools, or
allocates a fresh pool buffer when the shared buffers are busy. Read
commands copy the requested user-visible length back after firmware
completion, but firmware is not guaranteed to overwrite every byte in the
bounce buffer.

Clear the attached DMA buffer before issuing the command so short device
writes cannot return stale data from a previous ioctl or allocation. This
covers both regular DCMDs and passthrough commands after their requested
lengths have been validated.

Signed-off-by: Yousef Alhouseen <alhouseenyousef@gmail.com>
---
 drivers/scsi/megaraid/megaraid_mm.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/scsi/megaraid/megaraid_mm.c b/drivers/scsi/megaraid/megaraid_mm.c
index 75f6b7198..1e011e4f7 100644
--- a/drivers/scsi/megaraid/megaraid_mm.c
+++ b/drivers/scsi/megaraid/megaraid_mm.c
@@ -544,6 +544,7 @@ mraid_mm_attach_buf(mraid_mmadp_t *adp, uioc_t *kioc, int xferlen)
 			kioc->buf_paddr		= pool->paddr;
 
 			spin_unlock_irqrestore(&pool->lock, flags);
+			memset(kioc->buf_vaddr, 0, xferlen);
 			return 0;
 		}
 		else {
@@ -575,6 +576,8 @@ mraid_mm_attach_buf(mraid_mmadp_t *adp, uioc_t *kioc, int xferlen)
 	if (!kioc->buf_vaddr)
 		return -ENOMEM;
 
+	memset(kioc->buf_vaddr, 0, xferlen);
+
 	return 0;
 }
 
-- 
2.54.0


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

end of thread, other threads:[~2026-06-25  9:31 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-25  9:01 [PATCH] scsi: megaraid: clear ioctl DMA buffers before use Yousef Alhouseen
2026-06-25  9:31 ` sashiko-bot

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