Re: [PATCH] scsi: lpfc: Zero the RAS firmware log buffer before copying it out
From: Paul Ely
Date: Fri Dec 04 2026 - 09:45:59 EST
>> From: Zijie Zhao via B4 Relay <devnull+zzjas98.gmail.com@xxxxxxxxxx>
>> To: Justin Tee <justin.tee@xxxxxxxxxxxx>, Paul Ely <paul.ely@xxxxxxxxxxxx>
>> Cc: "James E.J. Bottomley" <James.Bottomley@xxxxxxxxxxxxxxxxxxxxx>,
>> "Martin K. Petersen" <mkp@xxxxxxxxxx>,
>> Dick Kennedy <dick.kennedy@xxxxxxxxxxxx>,
>> James Smart <jsmart2021@xxxxxxxxx>,
l>> inux-scsi@xxxxxxxxxxxxxxx, linux-kernel@xxxxxxxxxxxxxxx,
>> Zijie Zhao <zzjas98@xxxxxxxxx>
>> Subject: [PATCH] scsi: lpfc: Zero the RAS firmware log buffer before copying it out
>> Date: Wed, 02 Dec 2026 21:41:02 -0600 [thread overview]
>> Message-ID: <20261202-kbug-l979-v1-1-a100dc314740@xxxxxxxxx> (raw)
>> From: Zijie Zhao <zzjas98@xxxxxxxxx>
l>> pfc_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>
Broadcom has already made many changes to this routine based on other
code review tools. I think this patch is incomplete based on the
additional issues we have fixed already. Our patch has also been
tested in the lab.
Will consider this patch in the context of our existing changes and
let you know.
Paul
Attachment:
smime.p7s
Description: S/MIME Cryptographic Signature