* [PATCH v3 1/5] scsi: sd: Fix stale max_hw_wzeroes_unmap_sectors after a mode change
2026-11-29 19:25 [PATCH v3 0/5] scsi: sd: Fix WRITE SAME(10) data corruption Chris Down
@ 2026-11-29 19:25 ` Chris Down
2026-11-29 19:25 ` [PATCH v3 2/5] scsi: sd: Fix data corruption in WRITE SAME(10) write zeroes Chris Down
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Chris Down @ 2026-11-29 19:25 UTC (permalink / raw)
To: Martin K. Petersen, James E.J. Bottomley
Cc: Christoph Hellwig, linux-scsi, linux-kernel, kernel-team,
sashiko-bot, Bart Van Assche
sd_config_write_same() sets max_hw_wzeroes_unmap_sectors when the
zeroing mode requires unmap. However, it does not clear it later. If
the mode changes to one that doesn't unmap, the old value stays, and
the queue still reports that write zeroes will unmap.
blk_validate_limits() also wants max_hw_wzeroes_unmap_sectors to be
either zero or equal to max_write_zeroes_sectors. This means that if
the write zeroes limit changes as well, the whole update is rejected
and none of the new limits are applied.
This can already be triggered from sysfs. On a disk that was in one of
the unmap modes, writing "write" to zeroing_mode and then 0 to
max_write_same_blocks makes that store fail with -EINVAL. From that
point forward, so does the limits update in each revalidate. The next
patch makes the zeroing mode depend on the capacity as well, and then
resizing a disk can trigger it too.
So, let's clear the limit when the mode doesn't unmap.
Writing to zeroing_mode doesn't update the limit at all, so it can go
stale in either direction there. Let's set it from the new mode in
zeroing_mode_store() as well.
Fixes: 6dffe079fe36 ("scsi: sd: set max_hw_wzeroes_unmap_sectors if device supports SD_ZERO_*_UNMAP")
Cc: stable@vger.kernel.org
Signed-off-by: Chris Down <chris@chrisdown.name>
---
drivers/scsi/sd.c | 25 +++++++++++++++++++------
1 file changed, 19 insertions(+), 6 deletions(-)
diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index dc45df819c42..13e399631fa8 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -146,6 +146,17 @@ static void sd_large_pool_destroy(void)
mutex_unlock(&sd_mutex_lock);
}
+static void sd_config_wzeroes_unmap(struct scsi_disk *sdkp,
+ struct queue_limits *lim)
+{
+ if (sdkp->zeroing_mode == SD_ZERO_WS16_UNMAP ||
+ sdkp->zeroing_mode == SD_ZERO_WS10_UNMAP)
+ lim->max_hw_wzeroes_unmap_sectors =
+ lim->max_write_zeroes_sectors;
+ else
+ lim->max_hw_wzeroes_unmap_sectors = 0;
+}
+
static void sd_disable_discard(struct scsi_disk *sdkp)
{
sdkp->provisioning_mode = SD_LBP_DISABLE;
@@ -621,7 +632,8 @@ zeroing_mode_store(struct device *dev, struct device_attribute *attr,
const char *buf, size_t count)
{
struct scsi_disk *sdkp = to_scsi_disk(dev);
- int mode;
+ struct queue_limits lim;
+ int mode, err;
if (!capable(CAP_SYS_ADMIN))
return -EACCES;
@@ -630,8 +642,12 @@ zeroing_mode_store(struct device *dev, struct device_attribute *attr,
if (mode < 0)
return -EINVAL;
+ lim = queue_limits_start_update(sdkp->disk->queue);
sdkp->zeroing_mode = mode;
-
+ sd_config_wzeroes_unmap(sdkp, &lim);
+ err = queue_limits_commit_update_frozen(sdkp->disk->queue, &lim);
+ if (err)
+ return err;
return count;
}
static DEVICE_ATTR_RW(zeroing_mode);
@@ -1245,10 +1261,7 @@ out:
lim->max_write_zeroes_sectors =
sdkp->max_ws_blocks * (logical_block_size >> SECTOR_SHIFT);
- if (sdkp->zeroing_mode == SD_ZERO_WS16_UNMAP ||
- sdkp->zeroing_mode == SD_ZERO_WS10_UNMAP)
- lim->max_hw_wzeroes_unmap_sectors =
- lim->max_write_zeroes_sectors;
+ sd_config_wzeroes_unmap(sdkp, lim);
}
static blk_status_t sd_setup_flush_cmnd(struct scsi_cmnd *cmd)
--
2.56.1
^ permalink raw reply related [flat|nested] 6+ messages in thread* [PATCH v3 2/5] scsi: sd: Fix data corruption in WRITE SAME(10) write zeroes
2026-11-29 19:25 [PATCH v3 0/5] scsi: sd: Fix WRITE SAME(10) data corruption Chris Down
2026-11-29 19:25 ` [PATCH v3 1/5] scsi: sd: Fix stale max_hw_wzeroes_unmap_sectors after a mode change Chris Down
@ 2026-11-29 19:25 ` Chris Down
2026-11-29 19:25 ` [PATCH v3 3/5] scsi: sd: Fix data corruption in WRITE SAME(10) discards Chris Down
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Chris Down @ 2026-11-29 19:25 UTC (permalink / raw)
To: Martin K. Petersen, James E.J. Bottomley
Cc: Christoph Hellwig, linux-scsi, linux-kernel, kernel-team,
sashiko-bot, Bart Van Assche
In writesame_10_unmap mode we send write zeroes as WRITE SAME(10).
If the LBA or count doesn't fit, we truncate it and can return
success without zeroing the requested range. If the LBA wraps, we
can also corrupt live data near the start of the disk.
The LBA doesn't always fit because WRITE SAME(10) only has 32 bits for
it. Given that, we should only select writesame_10_unmap when a 32-bit
LBA can address the whole disk, and we shouldn't accept it in
zeroing_mode for a bigger disk either. A bigger disk gets WRITE SAME
without UNMAP instead, which already uses the 16-byte command where it
has to.
For the count, let's cap the queue limit when sd selects this mode so
large requests can still unmap in chunks. Writing to zeroing_mode
doesn't change the write zeroes limit, so don't accept
writesame_10_unmap there if max_write_same_blocks is too big for it.
A revalidate changes the capacity and max_write_same_blocks under the
limits lock, so zeroing_mode_store() checks them under it too.
sdkp->capacity is also set to zero as soon as the medium of a removable
disk is found to be gone, while the gendisk keeps the old capacity
until the next revalidate. So, check the gendisk capacity as well.
Fixes: e4b878371b85 ("sd: implement unmapping Write Zeroes")
Cc: stable@vger.kernel.org
Signed-off-by: Chris Down <chris@chrisdown.name>
---
drivers/scsi/sd.c | 29 ++++++++++++++++++++++++++++-
1 file changed, 28 insertions(+), 1 deletion(-)
diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index 13e399631fa8..26f40db3fd75 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -146,6 +146,20 @@ static void sd_large_pool_destroy(void)
mutex_unlock(&sd_mutex_lock);
}
+/* WRITE SAME(10) only has a 32-bit LBA field. */
+static bool sd_can_use_ws10(struct scsi_disk *sdkp)
+{
+ sector_t max_blocks = (sector_t)U32_MAX + 1;
+
+ /*
+ * A removable disk without a medium has an sdkp->capacity of zero,
+ * but the gendisk keeps its old capacity until the next revalidate.
+ */
+ return sdkp->capacity <= max_blocks &&
+ get_capacity(sdkp->disk) <=
+ logical_to_sectors(sdkp->device, max_blocks);
+}
+
static void sd_config_wzeroes_unmap(struct scsi_disk *sdkp,
struct queue_limits *lim)
{
@@ -643,6 +657,14 @@ zeroing_mode_store(struct device *dev, struct device_attribute *attr,
return -EINVAL;
lim = queue_limits_start_update(sdkp->disk->queue);
+ /* A revalidate can change these, so check them under the lock. */
+ if (mode == SD_ZERO_WS10_UNMAP &&
+ (!sd_can_use_ws10(sdkp) ||
+ sdkp->max_ws_blocks > SD_MAX_WS10_BLOCKS)) {
+ queue_limits_cancel_update(sdkp->disk->queue);
+ return -EINVAL;
+ }
+
sdkp->zeroing_mode = mode;
sd_config_wzeroes_unmap(sdkp, &lim);
err = queue_limits_commit_update_frozen(sdkp->disk->queue, &lim);
@@ -1230,13 +1252,18 @@ static void sd_config_write_same(struct scsi_disk *sdkp,
if (sdkp->lbprz && sdkp->lbpws)
sdkp->zeroing_mode = SD_ZERO_WS16_UNMAP;
- else if (sdkp->lbprz && sdkp->lbpws10)
+ else if (sdkp->lbprz && sdkp->lbpws10 && sd_can_use_ws10(sdkp))
sdkp->zeroing_mode = SD_ZERO_WS10_UNMAP;
else if (sdkp->max_ws_blocks)
sdkp->zeroing_mode = SD_ZERO_WS;
else
sdkp->zeroing_mode = SD_ZERO_WRITE;
+ /* Split large requests so they can still unmap. */
+ if (sdkp->zeroing_mode == SD_ZERO_WS10_UNMAP)
+ sdkp->max_ws_blocks = min(sdkp->max_ws_blocks,
+ (u32)SD_MAX_WS10_BLOCKS);
+
if (sdkp->max_ws_blocks &&
sdkp->physical_block_size > logical_block_size) {
/*
--
2.56.1
^ permalink raw reply related [flat|nested] 6+ messages in thread* [PATCH v3 3/5] scsi: sd: Fix data corruption in WRITE SAME(10) discards
2026-11-29 19:25 [PATCH v3 0/5] scsi: sd: Fix WRITE SAME(10) data corruption Chris Down
2026-11-29 19:25 ` [PATCH v3 1/5] scsi: sd: Fix stale max_hw_wzeroes_unmap_sectors after a mode change Chris Down
2026-11-29 19:25 ` [PATCH v3 2/5] scsi: sd: Fix data corruption in WRITE SAME(10) write zeroes Chris Down
@ 2026-11-29 19:25 ` Chris Down
2026-11-29 19:25 ` [PATCH v3 4/5] scsi: sd: Fix WRITE SAME(10) count truncation when the mode changes Chris Down
2026-11-29 19:25 ` [PATCH v3 5/5] scsi: sd: Fix truncation of WRITE SAME(10) requests that don't fit Chris Down
4 siblings, 0 replies; 6+ messages in thread
From: Chris Down @ 2026-11-29 19:25 UTC (permalink / raw)
To: Martin K. Petersen, James E.J. Bottomley
Cc: Christoph Hellwig, linux-scsi, linux-kernel, kernel-team,
sashiko-bot, Bart Van Assche
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.
Fixes: c98a0eb0e90d ("[SCSI] sd: Logical Block Provisioning update")
Cc: stable@vger.kernel.org
Signed-off-by: Chris Down <chris@chrisdown.name>
---
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. */
+ if ((mode == SD_LBP_WS10 || mode == SD_LBP_ZERO) &&
+ !sd_can_use_ws10(sdkp)) {
+ queue_limits_cancel_update(sdkp->disk->queue);
+ return -EINVAL;
+ }
sd_config_discard(sdkp, &lim, mode);
err = queue_limits_commit_update_frozen(sdkp->disk->queue, &lim);
if (err)
@@ -3453,7 +3459,7 @@ static unsigned int sd_discard_mode(struct scsi_disk *sdkp)
return SD_LBP_UNMAP;
if (sdkp->lbpws)
return SD_LBP_WS16;
- if (sdkp->lbpws10)
+ if (sdkp->lbpws10 && sd_can_use_ws10(sdkp))
return SD_LBP_WS10;
return SD_LBP_DISABLE;
}
--
2.56.1
^ permalink raw reply related [flat|nested] 6+ messages in thread* [PATCH v3 4/5] scsi: sd: Fix WRITE SAME(10) count truncation when the mode changes
2026-11-29 19:25 [PATCH v3 0/5] scsi: sd: Fix WRITE SAME(10) data corruption Chris Down
` (2 preceding siblings ...)
2026-11-29 19:25 ` [PATCH v3 3/5] scsi: sd: Fix data corruption in WRITE SAME(10) discards Chris Down
@ 2026-11-29 19:25 ` Chris Down
2026-11-29 19:25 ` [PATCH v3 5/5] scsi: sd: Fix truncation of WRITE SAME(10) requests that don't fit Chris Down
4 siblings, 0 replies; 6+ messages in thread
From: Chris Down @ 2026-11-29 19:25 UTC (permalink / raw)
To: Martin K. Petersen, James E.J. Bottomley
Cc: Christoph Hellwig, linux-scsi, linux-kernel, kernel-team,
sashiko-bot, Bart Van Assche
sd sets provisioning_mode and zeroing_mode before it freezes the queue
to commit the new limits. Until then, requests are still sized for the
old mode, including the ones that are already queued. For example,
take a slow disk in unmap mode with a backlog of 0x20000-block
discards. Writing writesame_10 to provisioning_mode sends the queued
ones as WRITE SAME(10) with a count of zero. Now that the zeroing mode
depends on the capacity, the same happens to queued write zeroes when a
disk shrinks and sd moves it to writesame_10_unmap.
A request is only sized once it has entered the queue, so none that
were sized for the old limits are left once the queue is frozen. Let's
change the modes at that point, as nvme_update_ns_info_block() does for
its own state.
The same goes for zeroing_mode_store() and
max_write_same_blocks_store(). The latter also sets max_ws_blocks
before it takes the limits lock, so zeroing_mode_store() can accept
writesame_10_unmap for the new value while write zeroes sized for the
old one are still queued. Set it with the queue frozen as well.
sd_revalidate_disk() can't freeze the queue while it's still sending
commands to the disk, so move sd_config_discard() down to where the
limits are committed. That is after the new capacity is set, though.
If the disk has just grown past 2^32 blocks, a request to the new
blocks would then go out as WRITE SAME(10) with its LBA truncated until
the mode changes. So, set the capacity after the modes when the disk
has grown. When it has shrunk it still has to come first, because the
modes for the smaller disk can't address all of the old one.
Committing the limits drops the limits lock, so another revalidate may
have picked the modes for a different capacity by the time we set a
grown one. Take the lock again for that, and set it from
sdkp->capacity, which is what the current modes were picked for.
You might wonder why we don't set the capacity with the queue frozen,
as nvme does. That sends the uevent with the queue frozen, which
lockdep complains about.
Fixes: c98a0eb0e90d ("[SCSI] sd: Logical Block Provisioning update")
Cc: stable@vger.kernel.org
Signed-off-by: Chris Down <chris@chrisdown.name>
---
drivers/scsi/sd.c | 61 ++++++++++++++++++++++++++++++++++++++---------
1 file changed, 50 insertions(+), 11 deletions(-)
diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index 09cb64ca6db4..f4db971d7abe 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -603,6 +603,7 @@ provisioning_mode_store(struct device *dev, struct device_attribute *attr,
struct scsi_disk *sdkp = to_scsi_disk(dev);
struct scsi_device *sdp = sdkp->device;
struct queue_limits lim;
+ unsigned int memflags;
int mode, err;
if (!capable(CAP_SYS_ADMIN))
@@ -622,8 +623,12 @@ provisioning_mode_store(struct device *dev, struct device_attribute *attr,
queue_limits_cancel_update(sdkp->disk->queue);
return -EINVAL;
}
+
+ /* Queued discards are sized for the old mode. */
+ memflags = blk_mq_freeze_queue(sdkp->disk->queue);
sd_config_discard(sdkp, &lim, mode);
- err = queue_limits_commit_update_frozen(sdkp->disk->queue, &lim);
+ err = queue_limits_commit_update(sdkp->disk->queue, &lim);
+ blk_mq_unfreeze_queue(sdkp->disk->queue, memflags);
if (err)
return err;
return count;
@@ -653,6 +658,7 @@ zeroing_mode_store(struct device *dev, struct device_attribute *attr,
{
struct scsi_disk *sdkp = to_scsi_disk(dev);
struct queue_limits lim;
+ unsigned int memflags;
int mode, err;
if (!capable(CAP_SYS_ADMIN))
@@ -671,9 +677,12 @@ zeroing_mode_store(struct device *dev, struct device_attribute *attr,
return -EINVAL;
}
+ /* Queued write zeroes are sized for the old mode. */
+ memflags = blk_mq_freeze_queue(sdkp->disk->queue);
sdkp->zeroing_mode = mode;
sd_config_wzeroes_unmap(sdkp, &lim);
- err = queue_limits_commit_update_frozen(sdkp->disk->queue, &lim);
+ err = queue_limits_commit_update(sdkp->disk->queue, &lim);
+ blk_mq_unfreeze_queue(sdkp->disk->queue, memflags);
if (err)
return err;
return count;
@@ -722,6 +731,7 @@ max_write_same_blocks_store(struct device *dev, struct device_attribute *attr,
struct scsi_disk *sdkp = to_scsi_disk(dev);
struct scsi_device *sdp = sdkp->device;
struct queue_limits lim;
+ unsigned int memflags;
unsigned long max;
int err;
@@ -736,16 +746,19 @@ max_write_same_blocks_store(struct device *dev, struct device_attribute *attr,
if (err)
return err;
+ lim = queue_limits_start_update(sdkp->disk->queue);
+
+ /* Queued write zeroes are sized for the old limit and mode. */
+ memflags = blk_mq_freeze_queue(sdkp->disk->queue);
if (max == 0)
sdp->no_write_same = 1;
else if (max <= SD_MAX_WS16_BLOCKS) {
sdp->no_write_same = 0;
sdkp->max_ws_blocks = max;
}
-
- lim = queue_limits_start_update(sdkp->disk->queue);
sd_config_write_same(sdkp, &lim);
- err = queue_limits_commit_update_frozen(sdkp->disk->queue, &lim);
+ err = queue_limits_commit_update(sdkp->disk->queue, &lim);
+ blk_mq_unfreeze_queue(sdkp->disk->queue, memflags);
if (err)
return err;
return count;
@@ -3825,7 +3838,9 @@ static void sd_revalidate_disk(struct gendisk *disk)
sector_t old_capacity = sdkp->capacity;
struct queue_limits *lim = NULL;
unsigned char *buffer = NULL;
- unsigned int dev_max;
+ unsigned int dev_max, memflags;
+ sector_t sectors;
+ bool grown;
int err;
SCSI_LOG_HLQUEUE(3, sd_printk(KERN_INFO, sdkp,
@@ -3879,8 +3894,6 @@ static void sd_revalidate_disk(struct gendisk *disk)
sd_zbc_read_zones(sdkp, lim, buffer);
}
- sd_config_discard(sdkp, lim, sd_discard_mode(sdkp));
-
sd_print_capacity(sdkp, old_capacity);
sd_read_write_protect_flag(sdkp, buffer);
@@ -3923,10 +3936,36 @@ static void sd_revalidate_disk(struct gendisk *disk)
sdkp->first_scan = 0;
- set_capacity_and_notify(disk, logical_to_sectors(sdp, sdkp->capacity));
- sd_config_write_same(sdkp, lim);
+ /*
+ * The WRITE SAME(10) modes can't address all of a disk with more than
+ * 2^32 blocks, so don't show a bigger capacity until they are gone.
+ */
+ sectors = logical_to_sectors(sdp, sdkp->capacity);
+ grown = sectors > get_capacity(disk);
+ if (!grown)
+ set_capacity_and_notify(disk, sectors);
- err = queue_limits_commit_update_frozen(sdkp->disk->queue, lim);
+ /*
+ * Queued requests are sized for the old modes, so only change the
+ * modes once the queue is frozen.
+ */
+ memflags = blk_mq_freeze_queue(sdkp->disk->queue);
+ if (sdkp->media_present)
+ sd_config_discard(sdkp, lim, sd_discard_mode(sdkp));
+ sd_config_write_same(sdkp, lim);
+ err = queue_limits_commit_update(sdkp->disk->queue, lim);
+ blk_mq_unfreeze_queue(sdkp->disk->queue, memflags);
+ if (grown) {
+ /*
+ * The commit dropped the limits lock, so another revalidate
+ * may have run since. Show the capacity that the modes are
+ * for now.
+ */
+ mutex_lock(&sdkp->disk->queue->limits_lock);
+ sectors = logical_to_sectors(sdp, sdkp->capacity);
+ set_capacity_and_notify(disk, sectors);
+ mutex_unlock(&sdkp->disk->queue->limits_lock);
+ }
if (err)
goto out;
--
2.56.1
^ permalink raw reply related [flat|nested] 6+ messages in thread* [PATCH v3 5/5] scsi: sd: Fix truncation of WRITE SAME(10) requests that don't fit
2026-11-29 19:25 [PATCH v3 0/5] scsi: sd: Fix WRITE SAME(10) data corruption Chris Down
` (3 preceding siblings ...)
2026-11-29 19:25 ` [PATCH v3 4/5] scsi: sd: Fix WRITE SAME(10) count truncation when the mode changes Chris Down
@ 2026-11-29 19:25 ` Chris Down
4 siblings, 0 replies; 6+ messages in thread
From: Chris Down @ 2026-11-29 19:25 UTC (permalink / raw)
To: Martin K. Petersen, James E.J. Bottomley
Cc: Christoph Hellwig, linux-scsi, linux-kernel, kernel-team,
sashiko-bot, Bart Van Assche
The modes and the limits keep most requests that don't fit in WRITE
SAME(10) away from sd_setup_write_same10_cmnd(), but they can't stop
all of them. One that gets there is sent with its LBA or count
truncated.
For example, bio_check_eod() only checks a bio against its partition,
and it does that before the bio enters the queue. If a disk shrinks to
2^32 blocks or fewer while a partition on it still ends above that, a
discard to the end of the partition is sent as WRITE SAME(10) with its
LBA truncated. So is one that was checked before the shrink and entered
the queue after it.
The block layer also doesn't split a discard when max_discard_sectors
is zero or below the discard granularity. With scsi_debug, 512-byte
blocks and an unmap granularity of 0x10000 blocks, a 64 MiB discard in
writesame_10 mode goes out as a single WRITE SAME(10) with a count of
zero. scsi_debug doesn't unmap anything in that case, but in SBC a
count of zero is intended to imply that every block from the LBA to the
end of the disk should be unmapped unless the device sets WSNZ. Writing
0 to discard_max_bytes while a large discard is running sends the rest
of the bio unsplit as well.
sd_setup_read_write_cmnd() already fails reads and writes beyond the
end of the disk. Let's fail a request that doesn't fit in WRITE
SAME(10) too. The block layer still has to learn to split or refuse the
discards above, but that is a separate fix.
Fixes: c98a0eb0e90d ("[SCSI] sd: Logical Block Provisioning update")
Cc: stable@vger.kernel.org
Signed-off-by: Chris Down <chris@chrisdown.name>
---
drivers/scsi/sd.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index f4db971d7abe..ab264a829930 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -1188,6 +1188,9 @@ static blk_status_t sd_setup_write_same10_cmnd(struct scsi_cmnd *cmd,
u32 data_len = sdp->sector_size;
blk_status_t ret;
+ if (lba > U32_MAX || nr_blocks > U16_MAX)
+ return BLK_STS_TARGET;
+
if (!sd_set_special_bvec(cmd, data_len))
return BLK_STS_RESOURCE;
--
2.56.1
^ permalink raw reply related [flat|nested] 6+ messages in thread