Skip to content

Commit cdc937a

Browse files
Nicholas Bellingersashalevin
authored andcommitted
target: Check for LBA + sectors wrap-around in sbc_parse_cdb
commit aa17993 upstream. This patch adds a check to sbc_parse_cdb() in order to detect when an LBA + sector vs. end-of-device calculation wraps when the LBA is sufficently large enough (eg: 0xFFFFFFFFFFFFFFFF). Cc: Martin Petersen <martin.petersen@oracle.com> Cc: Christoph Hellwig <hch@lst.de> Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org> Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
1 parent f38a130 commit cdc937a

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
@@ -967,7 +967,8 @@ sbc_parse_cdb(struct se_cmd *cmd, struct sbc_ops *ops)
967967
unsigned long long end_lba;
968968
check_lba:
969969
end_lba = dev->transport->get_blocks(dev) + 1;
970-
if (cmd->t_task_lba + sectors > end_lba) {
970+
if (((cmd->t_task_lba + sectors) < cmd->t_task_lba) ||
971+
((cmd->t_task_lba + sectors) > end_lba)) {
971972
pr_err("cmd exceeds last lba %llu "
972973
"(lba %llu, sectors %u)\n",
973974
end_lba, cmd->t_task_lba, sectors);

0 commit comments

Comments
 (0)