[PATCH] scsi: lpfc: Zero the RAS firmware log buffer before copying it out

From: Zijie Zhao via B4 Relay

Date: Wed Dec 02 2026 - 22:41:14 EST


From: Zijie Zhao <zzjas98@xxxxxxxxx>

lpfc_bsg_get_ras_fwlog() allocates fwlog_buff with vmalloc() and fills
it from the firmware log entry selected by read_offset. If no entry is
found, the reply is copied from the uninitialized buffer, leaking
kernel memory to user space.

Allocate the buffer with vzalloc() instead.

Found by a static analysis tool.

Fixes: d2cc9bcd7fa3 ("scsi: lpfc: add support to retrieve firmware logs")
Signed-off-by: Zijie Zhao <zzjas98@xxxxxxxxx>
---
The fix and the changelog were drafted with AI assistance (Claude Code,
with a second review by OpenAI Codex), then reviewed by the submitter.

Testing:
- Compile-tested on x86_64 (allmodconfig, W=1):
drivers/scsi/lpfc/lpfc_bsg.o; no new warnings.
- checkpatch.pl --strict: no errors or warnings.
---
drivers/scsi/lpfc/lpfc_bsg.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/lpfc/lpfc_bsg.c b/drivers/scsi/lpfc/lpfc_bsg.c
index 7354ae9ba8e5..511a968c47eb 100644
--- a/drivers/scsi/lpfc/lpfc_bsg.c
+++ b/drivers/scsi/lpfc/lpfc_bsg.c
@@ -5489,7 +5489,7 @@ lpfc_bsg_get_ras_fwlog(struct bsg_job *job)
rd_offset = ras_req->read_offset;

/* Allocate memory to read fw log*/
- fwlog_buff = vmalloc(ras_req->read_size);
+ fwlog_buff = vzalloc(ras_req->read_size);
if (!fwlog_buff) {
rc = -ENOMEM;
goto ras_job_error;

---
base-commit: 4be084ac36f95f95e21a1e39207e87326967a73d
change-id: 20261202-kbug-l979-745c05aaeca6

Best regards,
--
Zijie Zhao <zzjas98@xxxxxxxxx>