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: Nilesh Javali <njavali@marvell.com>,
	 GR-QLogic-Storage-Upstream@marvell.com,
	 "Martin K. Petersen" <mkp@kernel.org>
Cc: "James E.J. Bottomley" <James.Bottomley@HansenPartnership.com>,
	 Saurav Kashyap <skashyap@marvell.com>,
	 Himanshu Madhani <himanshu.madhani@oracle.com>,
	linux-scsi@vger.kernel.org,  linux-kernel@vger.kernel.org,
	stable@vger.kernel.org,  Zijie Zhao <zzjas98@gmail.com>
Subject: [PATCH] scsi: qla2xxx: Fix heap overflow in qla2x00_get_tgt_stats()
Date: Tue, 01 Dec 2026 21:26:35 -0600	[thread overview]
Message-ID: <20261201-kbug-l941-v1-1-f18d98e4ca0b@gmail.com> (raw)

From: Zijie Zhao <zzjas98@gmail.com>

qla2x00_get_tgt_stats() requires a 16-byte request payload
(sizeof(struct ql_vnd_stat_entry)) but copies it into an 8-byte
struct ql_vnd_tgt_stats_param. Every accepted QL_VND_GET_TGT_STATS
request therefore writes 8 bytes of caller data past the end of the
allocation, which can corrupt adjacent slab memory.

The handler only uses tgt_id and stat_type, so copy just
sizeof(*req_data) bytes. Keep the length check so that the 16-byte
requests user space sends today are still accepted.

Found by a static analysis tool.

The fix and this changelog were drafted with AI assistance (Claude Code,
with a second review by OpenAI Codex), then reviewed by the submitter.

Fixes: dbf1f53cfd23 ("scsi: qla2xxx: Implementation to get and manage host, target stats and initiator port")
Cc: stable@vger.kernel.org
Signed-off-by: Zijie Zhao <zzjas98@gmail.com>
---
Testing:
- Compile-tested on x86_64 (allmodconfig, W=1):
  drivers/scsi/qla2xxx/qla_bsg.o; no new warnings.
- checkpatch.pl --strict: no errors or warnings.
---
 drivers/scsi/qla2xxx/qla_bsg.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/qla2xxx/qla_bsg.c b/drivers/scsi/qla2xxx/qla_bsg.c
index ab559048dbb8..65dbe71ff309 100644
--- a/drivers/scsi/qla2xxx/qla_bsg.c
+++ b/drivers/scsi/qla2xxx/qla_bsg.c
@@ -3258,7 +3258,7 @@ qla2x00_get_tgt_stats(struct bsg_job *bsg_job)
 	/* Copy the request buffer in req_data */
 	sg_copy_to_buffer(bsg_job->request_payload.sg_list,
 			  bsg_job->request_payload.sg_cnt,
-			  req_data, req_data_len);
+			  req_data, sizeof(*req_data));
 
 	response_len = sizeof(struct ql_vnd_tgt_stats_resp) +
 		sizeof(struct ql_vnd_stat_entry);

---
base-commit: 4be084ac36f95f95e21a1e39207e87326967a73d
change-id: 20261201-kbug-l941-4a769b0d018c

Best regards,
--  
Zijie Zhao <zzjas98@gmail.com>



                 reply	other threads:[~2026-12-02  3:26 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=20261201-kbug-l941-v1-1-f18d98e4ca0b@gmail.com \
    --to=devnull+zzjas98.gmail.com@kernel.org \
    --cc=GR-QLogic-Storage-Upstream@marvell.com \
    --cc=James.Bottomley@HansenPartnership.com \
    --cc=himanshu.madhani@oracle.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=mkp@kernel.org \
    --cc=njavali@marvell.com \
    --cc=skashyap@marvell.com \
    --cc=stable@vger.kernel.org \
    --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®