block/iscsi: validate block size returned from target
PATCH 1/1 block/iscsi: validate block size returned from target
It has been reported that at least tgtd returns a block size of 0 for LUN 0. To avoid running into divide by zero later on and protect against other problematic block sizes validate the block size right at connection time.
Reported-by Andrey Korolyov <[email protected]>
Signed-off-by Peter Lieven <[email protected]>
--- block/iscsi.c | 4 ++++ dtc | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-)
block/iscsi.c +4 -0
@@ -1214,6 +1214,10 @@ static void iscsi_readcapacity_sync(IscsiLun *iscsilun, Error **errp)if (task ==NULL || task->status !=SCSI_STATUS_GOOD ) {error_setg (errp,"iSCSI: failed to send readcapacity10 command." ); + }else if (!iscsilun->block_size || + iscsilun->block_size %BDRV_SECTOR_SIZE ) { +error_setg (errp,"iSCSI: the target returned an invalid " +"block size of %d." , iscsilun->block_size); }if (task) {scsi_free_scsi_task (task);
Am 14.08.2015 um 13:33 schrieb Peter Lieven:
Quoted 18 lines
It has been reported that at least tgtd returns a block size of 0 for LUN 0. To avoid running into divide by zero later on and protect against other problematic block sizes validate the block size right at connection time.
Reported-by Andrey Korolyov <[email protected]>Signed-off-by Peter Lieven <[email protected]>--- block/iscsi.c | 4 ++++ dtc | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-)block/iscsi.c +0
-0
block/iscsi.c static void iscsi_readcapacity_sync(IscsiLun *iscsilun, Error **errp) · line 1223
Quoted 10 lines
block/iscsi.c +4
-0@@ -1214,6 +1214,10 @@ static void iscsi_readcapacity_sync(IscsiLun *iscsilun, Error **errp)if (task ==NULL || task->status !=SCSI_STATUS_GOOD ) {error_setg (errp,"iSCSI: failed to send readcapacity10 command." ); + }else if (!iscsilun->block_size || + iscsilun->block_size %BDRV_SECTOR_SIZE ) { +error_setg (errp,"iSCSI: the target returned an invalid " +"block size of %d." , iscsilun->block_size); }if (task) {scsi_free_scsi_task (task);
Ping
Paolo Bonzini
AppliedQuoted 11 lines · Peter Lieven
Quoted 11 lines
block/iscsi.c +1
-0@@ -1214,6 +1214,10 @@ static void iscsi_readcapacity_sync(IscsiLun *iscsilun, Error **errp)if (task ==NULL || task->status !=SCSI_STATUS_GOOD ) { error_setg(errp, "iSCSI: failed to send readcapacity10 command."); + } else if (!iscsilun->block_size ||
Quoted 8 lines
Quoted 6 lines
block/iscsi.c +3
-0+ iscsilun->block_size % BDRV_SECTOR_SIZE) { +error_setg (errp,"iSCSI: the target returned an invalid " +"block size of %d." , iscsilun->block_size); }if (task) {scsi_free_scsi_task(task);Ping
Queued but not sent due to KVM Forum and vacation.
Paolo