Skip to content

Commit 8889676

Browse files
forsaken641martinkpetersen
authored andcommitted
scsi: sd: Fix VPD page 0xb7 length check
sd_read_block_limits_ext() currently assumes that vpd->len excludes the size of the page header. However, vpd->len describes the size of the entire VPD page, therefore the sanity check is incorrect. In practice this is not really a problem since we don't attach VPD pages unless they actually report data trailing the header. But fix the length check regardless. This issue was identified by Wukong-Agent (formerly Tencent Woodpecker), a code security AI agent, through static code analysis. [mkp: rewrote patch description] Signed-off-by: jackysliu <[email protected]> Link: https://lore.kernel.org/r/[email protected] Fixes: 96b171d ("scsi: core: Query the Block Limits Extension VPD page") Signed-off-by: Martin K. Petersen <[email protected]>
1 parent 00f452a commit 8889676

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/scsi/sd.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3384,7 +3384,7 @@ static void sd_read_block_limits_ext(struct scsi_disk *sdkp)
33843384

33853385
rcu_read_lock();
33863386
vpd = rcu_dereference(sdkp->device->vpd_pgb7);
3387-
if (vpd && vpd->len >= 2)
3387+
if (vpd && vpd->len >= 6)
33883388
sdkp->rscs = vpd->data[5] & 1;
33893389
rcu_read_unlock();
33903390
}

0 commit comments

Comments
 (0)