mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Zijie Zhao via B4 Relay <devnull+zzjas98.gmail.com@kernel.org>
To: Justin Tee <justin.tee@broadcom.com>, Paul Ely <paul.ely@broadcom.com>
Cc: "James E.J. Bottomley" <James.Bottomley@HansenPartnership.com>,
	 "Martin K. Petersen" <mkp@kernel.org>,
	 Dick Kennedy <dick.kennedy@broadcom.com>,
	 James Smart <jsmart2021@gmail.com>,
	linux-scsi@vger.kernel.org,  linux-kernel@vger.kernel.org,
	Zijie Zhao <zzjas98@gmail.com>
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@gmail.com> (raw)

From: Zijie Zhao <zzjas98@gmail.com>

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@gmail.com>
---
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@gmail.com>



                 reply	other threads:[~2026-12-03  3:41 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261202-kbug-l979-v1-1-a100dc314740@gmail.com \
    --to=devnull+zzjas98.gmail.com@kernel.org \
    --cc=James.Bottomley@HansenPartnership.com \
    --cc=dick.kennedy@broadcom.com \
    --cc=jsmart2021@gmail.com \
    --cc=justin.tee@broadcom.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=mkp@kernel.org \
    --cc=paul.ely@broadcom.com \
    --cc=zzjas98@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®