Re: [PATCH v3 3/5] scsi: sd: Fix data corruption in WRITE SAME(10) discards

From: Christoph Hellwig

Date: Mon Nov 30 2026 - 04:19:12 EST


On Sun, Nov 29, 2026 at 11:25:26AM -0800, Chris Down wrote:
> We already cap the discard length in writesame_10 and writesame_zero
> mode, but we still truncate the starting LBA to 32 bits. A discard at
> or above block 2^32 can corrupt live data near the start of the disk
> and still report success.
>
> The reason is that both modes send WRITE SAME(10), which only has a
> 32-bit LBA. Given this, let's only select writesame_10 when a 32-bit
> LBA can address the whole disk, and not accept either of them in
> provisioning_mode for a bigger disk. This means that a bigger disk that
> only reports LBPWS10 ends up with discard disabled.

This commit log seems totally disconnect from that the patch does.



>
> Fixes: c98a0eb0e90d ("[SCSI] sd: Logical Block Provisioning update")
> Cc: stable@xxxxxxxxxxxxxxx
> Signed-off-by: Chris Down <chris@xxxxxxxxxxxxxx>
> ---
> drivers/scsi/sd.c | 8 +++++++-
> 1 file changed, 7 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
> index 26f40db3fd75..09cb64ca6db4 100644
> --- a/drivers/scsi/sd.c
> +++ b/drivers/scsi/sd.c
> @@ -616,6 +616,12 @@ provisioning_mode_store(struct device *dev, struct device_attribute *attr,
> return -EINVAL;
>
> lim = queue_limits_start_update(sdkp->disk->queue);
> + /* A revalidate can change the capacity, so check it under the lock. */

And this comment looks more than weird to.

I think you'd be best of folding this into the previous patch and write
your own commit logs and comments.