Skip to content

Commit 3facdec

Browse files
avasummergregkh
authored andcommitted
scsi: target: core: Fix integer overflow in UNMAP bounds check
[ Upstream commit 2bf2d65 ] sbc_execute_unmap() checks LBA + range does not exceed the device capacity, but does not guard against LBA + range wrapping around on 64-bit overflow. Add an overflow check matching the pattern already used for WRITE_SAME in the same file. Fixes: 86d7182 ("target: Add sbc_execute_unmap() helper") Reported-by: Yuhao Jiang <danisjiang@gmail.com> Signed-off-by: Junrui Luo <moonafterrain@outlook.com> Link: https://patch.msgid.link/SYBPR01MB7881593C61AD52C69FBDB0BDAF7CA@SYBPR01MB7881.ausprd01.prod.outlook.com Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 3493a23 commit 3facdec

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

drivers/target/target_core_sbc.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1136,7 +1136,8 @@ sbc_execute_unmap(struct se_cmd *cmd)
11361136
goto err;
11371137
}
11381138

1139-
if (lba + range > dev->transport->get_blocks(dev) + 1) {
1139+
if (lba + range < lba ||
1140+
lba + range > dev->transport->get_blocks(dev) + 1) {
11401141
ret = TCM_ADDRESS_OUT_OF_RANGE;
11411142
goto err;
11421143
}

0 commit comments

Comments
 (0)