[PATCH v2 8/8] scsi: target: advance past escaped DIF blocks across data sgs
From: Jia Jia
Date: Tue Nov 17 2026 - 23:15:12 EST
An escaped protection tuple advances dsg_off by one logical block.
sbc_dif_verify() adjusts the cursor across only one data sg on the next
iteration. When the skipped block spans several short entries, the
offset can still exceed the next sg's length and the following CRC
reads beyond that entry.
Advance through data sgs until the offset is within the current entry
before checking the next block.
KASAN reports:
BUG: KASAN: use-after-free in crc_t10dif_update+0x91/0xf0
Read of size 1
crc_t10dif_update
sbc_dif_verify
target_execute_cmd
vhost_scsi_write_pending
transport_generic_new_cmd
Fixes: 18213afbd8ce ("target: handle odd SG mapping for data transfer memory")
Signed-off-by: Jia Jia <physicalmtea@xxxxxxxxx>
---
drivers/target/target_core_sbc.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/target/target_core_sbc.c b/drivers/target/target_core_sbc.c
index e752b23b1bef7..671427d9ae74a 100644
--- a/drivers/target/target_core_sbc.c
+++ b/drivers/target/target_core_sbc.c
@@ -1553,7 +1553,7 @@ sbc_dif_verify(struct se_cmd *cmd, sector_t start, unsigned int sectors,
return TCM_LOGICAL_BLOCK_GUARD_CHECK_FAILED;
}
- if (dsg_off >= dsg->length) {
+ while (dsg_off >= dsg->length) {
dsg_off -= dsg->length;
kunmap_atomic(daddr - dsg->offset);
dsg = sg_next(dsg);