From: sashiko-bot@kernel.org
To: "Niklas Cassel" <cassel@kernel.org>
Cc: linux-scsi@vger.kernel.org
Subject: Re: [PATCH v2 1/4] scsi: scsi_debug: Do not advance the write pointer of a failed write
Date: Thu, 17 Sep 2026 11:17:38 +0000 [thread overview]
Message-ID: <20260917111738.DFFE91F00893@smtp.kernel.org> (raw)
In-Reply-To: <20260917110316.1104863-7-cassel@kernel.org>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] scsi: scsi_debug: ZBC specification violation by returning GOOD status without advancing WP
- [Medium] scsi: scsi_debug: integer overflow in short write check allows incorrect WP advancement
--
commit 2b6fea07514157218eac4ea45ff1ba17e05b5125
Author: Niklas Cassel <cassel@kernel.org>
scsi: scsi_debug: Do not advance the write pointer of a failed write
This commit modifies the write pointer advancement logic for ZBC sequential
write required zones. It ensures the write pointer is only incremented when
all requested data is successfully written.
> diff --git a/drivers/scsi/scsi_debug.c b/drivers/scsi/scsi_debug.c
> index 6941809dfdb75..3ce2dbdff177c 100644
> --- a/drivers/scsi/scsi_debug.c
> +++ b/drivers/scsi/scsi_debug.c
> @@ -5150,8 +5150,8 @@ static int resp_write_dt0(struct scsi_cmnd *scp, struct sdebug_dev_info *devip)
> if (unlikely(scsi_debug_lbp()))
> map_region(sip, lba, num);
>
> - /* If ZBC zone then bump its write pointer */
> - if (sdebug_dev_is_zoned(devip))
> + /* If ZBC zone then bump its write pointer, if all data was written */
> + if (sdebug_dev_is_zoned(devip) && ret == num * sdebug_sector_size)
[Severity: Medium]
Could the multiplication num * sdebug_sector_size overflow 32-bit arithmetic
for large num? If the module is loaded with a capacity >= 4GB, an extremely
large num and an empty data-out buffer might cause do_device_access() to
safely return 0. If the multiplication overflows and evaluates to 0, this
check might erroneously pass and incorrectly advance the write pointer.
[Severity: High]
If do_device_access() returns a short count due to a small data-out buffer,
this check prevents advancing the write pointer. However, the function then
proceeds to return 0 (GOOD status) without calling scsi_set_resid(). Does
this violate the ZBC specification, which requires that if a write terminates
with GOOD status, the write pointer must be advanced by the transfer length?
Could this lead to silent data corruption or UNALIGNED WRITE COMMAND errors
on subsequent sequential writes?
> zbc_inc_wp(devip, lba, num);
> if (meta_data_locked)
> sdeb_meta_write_unlock(sip);
[ ... ]
> @@ -5314,8 +5314,8 @@ static int resp_write_scat(struct scsi_cmnd *scp,
> * writes behaviour as possible.
> */
> ret = do_device_access(sip, scp, sg_off, lba, num, group, true, true);
> - /* If ZBC zone then bump its write pointer */
> - if (sdebug_dev_is_zoned(devip))
> + /* If ZBC zone then bump its write pointer, if all data was written */
> + if (sdebug_dev_is_zoned(devip) && ret == num_by)
[Severity: Medium]
Does the num_by variable suffer from a similar 32-bit overflow issue?
Earlier in resp_write_scat(), num_by is calculated as num * lb_size. If
this truncates to 0 on a massive transfer, could this condition falsely
match a 0-byte return from do_device_access(), tricking the driver into
advancing the write pointer anyway?
[Severity: High]
Similar to resp_write_dt0(), if this skips the write pointer advancement for
scattered writes on short buffers, it still continues and eventually returns
0 (GOOD status) at the end of the function. Should this set a residual count
when skipping the write pointer increment to avoid ZBC specification
violations?
> zbc_inc_wp(devip, lba, num);
> if (unlikely(scsi_debug_lbp()))
> map_region(sip, lba, num);
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260917110316.1104863-6-cassel@kernel.org?part=1
next prev parent reply other threads:[~2026-09-17 11:17 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-17 11:03 [PATCH v2 0/4] scsi: scsi_debug: fix zoned write validation Niklas Cassel
2026-09-17 11:03 ` [PATCH v2 1/4] scsi: scsi_debug: Do not advance the write pointer of a failed write Niklas Cassel
2026-09-17 11:17 ` sashiko-bot [this message]
2026-09-17 12:21 ` Niklas Cassel
2026-09-17 13:00 ` Damien Le Moal
2026-09-17 11:03 ` [PATCH v2 2/4] scsi: scsi_debug: Enforce physical block alignment of zoned writes Niklas Cassel
2026-09-17 11:03 ` [PATCH v2 3/4] scsi: scsi_debug: Map the region written by WRITE ATOMIC (16) Niklas Cassel
2026-09-17 11:20 ` sashiko-bot
2026-09-17 13:04 ` Damien Le Moal
2026-09-17 11:03 ` [PATCH v2 4/4] scsi: scsi_debug: Validate zone access for " Niklas Cassel
2026-09-17 13:03 ` Damien Le Moal
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=20260917111738.DFFE91F00893@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=cassel@kernel.org \
--cc=linux-scsi@vger.kernel.org \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.