Message ID | 20240912134308.282824-1-mwilck@suse.com (mailing list archive) |
---|---|
State | Accepted |
Commit | f81eaf08385ddd474a2f41595a7757502870c0eb |
Headers | show |
Series | scsi: fix off-by-one error in sd_read_block_characteristics() | expand |
Martin, > if the device returns page 0xb1 with length 8 (happens with qemu v2.x, > for example), sd_read_block_characteristics() may attempt an > out-of-bounds memory access when accessing the zoned field at offset > 8. Applied to 6.12/scsi-staging, thanks!
diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c index 9db86943d04c..9513406ad640 100644 --- a/drivers/scsi/sd.c +++ b/drivers/scsi/sd.c @@ -3404,7 +3404,7 @@ static void sd_read_block_characteristics(struct scsi_disk *sdkp, rcu_read_lock(); vpd = rcu_dereference(sdkp->device->vpd_pgb1); - if (!vpd || vpd->len < 8) { + if (!vpd || vpd->len <= 8) { rcu_read_unlock(); return; }
if the device returns page 0xb1 with length 8 (happens with qemu v2.x, for example), sd_read_block_characteristics() may attempt an out-of-bounds memory access when accessing the zoned field at offset 8. Fixes: 7fb019c46eee ("scsi: sd: Switch to using scsi_device VPD pages") Signed-off-by: Martin Wilck <mwilck@suse.com> --- drivers/scsi/sd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)