Linux SCSI subsystem development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Nihar Panda" <niharp@linux.ibm.com>
Cc: linux-s390@vger.kernel.org, "Vasily Gorbik" <gor@linux.ibm.com>,
	"Heiko Carstens" <hca@linux.ibm.com>,
	"Alexander Gordeev" <agordeev@linux.ibm.com>,
	linux-scsi@vger.kernel.org
Subject: Re: [PATCH 1/4] zfcp: Enhance fsf status read buffer tracing
Date: Fri, 24 Jul 2026 06:18:01 +0000	[thread overview]
Message-ID: <20260724061801.996BB1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260724053934.2781087-2-niharp@linux.ibm.com>

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:

Pre-existing issues:
- [High] An integer underflow occurs when the hardware/firmware provides a non-zero `srb->length` smaller than the `payload` offset, leading to a massive out-of-bounds read and potential kernel panic.
- [High] Missing bounds check on hardware-provided `log_start` and `log_length` allows an out-of-bounds read and information leak.
--

--- Patch [1]: [PATCH 1/4] zfcp: Enhance fsf status read buffer tracing ---
commit 2318c7a31a1b9a647e0a90e8e4d57fd114b807d1
Author: Chinmaya Kajagar <chinmayk@linux.ibm.com>

zfcp: Enhance fsf status read buffer tracing

This commit appends the remaining SRB fields to the unsolicited status trace
records and extends the driver to get the 3-byte source ID from the reserved
field. This helps fully trace the incoming FSF status read buffer.

> diff --git a/drivers/s390/scsi/zfcp_dbf.c b/drivers/s390/scsi/zfcp_dbf.c
> index 71f625926ae19..89b859176b8bd 100644
> --- a/drivers/s390/scsi/zfcp_dbf.c
> +++ b/drivers/s390/scsi/zfcp_dbf.c

[ ... ]

> @@ -220,6 +220,13 @@ void zfcp_dbf_hba_fsf_uss(char *tag, struct zfcp_fsf_req *req)
>  	rec->u.uss.lun = srb->fcp_lun;
>  	memcpy(&rec->u.uss.queue_designator, &srb->queue_designator,
>  	       sizeof(rec->u.uss.queue_designator));
> +	rec->u.uss.length = srb->length;
> +	rec->u.uss.res1 = srb->res1;
> +	rec->u.uss.res2 = srb->res2;
> +	rec->u.uss.class = srb->class;
> +	rec->u.uss.res3 = srb->res3;
> +	rec->u.uss.s_id = ntoh24(srb->s_id);
> +	memcpy(&rec->u.uss.res4, &srb->res4, sizeof(rec->u.uss.res4));
>  
>  	/* status read buffer payload length */
>  	rec->pl_len = (!srb->length) ? 0 : srb->length -
> 			offsetof(struct fsf_status_read_buffer, payload);
> 
> 	if (rec->pl_len)
> 		zfcp_dbf_pl_write(dbf, srb->payload.data, rec->pl_len,
> 				  "fsf_uss", req->req_id, ZFCP_DBF_PAY_LEVEL);

[Severity: High]
This is a pre-existing issue, but is there a risk of an integer underflow
here if the firmware returns a non-zero srb->length that is smaller than the
payload offset?

If srb->length is less than offsetof(struct fsf_status_read_buffer, payload),
the subtraction will underflow. Because rec->pl_len is a u16, it would store a
large truncated positive integer.

Could this cause zfcp_dbf_pl_write() to perform a massive out-of-bounds read
beyond the srb buffer, potentially leading to a kernel panic from unmapped
memory access or leaking adjacent sensitive kernel heap data into the trace
ring buffer?

An identical instance of this calculation seems to exist in
zfcp_dbf_san_in_els() as well.


While reviewing this tracing code, I also noticed another pre-existing issue
in zfcp_dbf_hba_fsf_res():

drivers/s390/scsi/zfcp_dbf.c:zfcp_dbf_hba_fsf_res() {
	...
	if (q_head->log_length) {
		rec->pl_len = q_head->log_length;
		zfcp_dbf_pl_write(dbf, (char *)q_pref + q_head->log_start,
				  rec->pl_len, "fsf_res", req->req_id,
				  ZFCP_DBF_PAY_LEVEL);
	}
	...
}

[Severity: High]
This is also a pre-existing issue, but does this code adequately validate the
hardware-provided q_head->log_length and q_head->log_start values?

Since these values are read directly from the hardware-populated qtcb header,
is it possible for a malfunctioning or compromised firmware to provide
arbitrary offsets and lengths?

Without bounds checking to ensure they fall strictly within the allocated qtcb
structure, could zfcp_dbf_pl_write() perform an out-of-bounds read from the
kernel heap, potentially leaking sensitive data or causing a crash?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260724053934.2781087-1-niharp@linux.ibm.com?part=1

  reply	other threads:[~2026-07-24  6:18 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-24  5:39 [PATCH 0/4] Request to queue zfcp enhancements for upstream v7.3 merge window Nihar Panda
2026-07-24  5:39 ` [PATCH 1/4] zfcp: Enhance fsf status read buffer tracing Nihar Panda
2026-07-24  6:18   ` sashiko-bot [this message]
2026-07-24  5:39 ` [PATCH 2/4] zfcp: Trace plogi and prli within open port response as payload Nihar Panda
2026-07-24  6:11   ` sashiko-bot
2026-07-24  5:39 ` [PATCH 3/4] zfcp: trace return values of sysfs unit add store Nihar Panda
2026-07-24  6:09   ` sashiko-bot
2026-07-24  5:39 ` [PATCH 4/4] fixup! " Nihar Panda
2026-07-24  6:13   ` sashiko-bot

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=20260724061801.996BB1F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=agordeev@linux.ibm.com \
    --cc=gor@linux.ibm.com \
    --cc=hca@linux.ibm.com \
    --cc=linux-s390@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=niharp@linux.ibm.com \
    --cc=sashiko-reviews@lists.linux.dev \
    /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