Skip to contentSkip to conversation

block/iscsi: validate block size returned from target

PATCH Applied Peter Lieven 2 participants 3 messages Aug 14, 2015 – Sep 7, 2015 Block layer

lore
Share & tools
lore
#0 lore raw

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.

---
 block/iscsi.c | 4 ++++
 dtc           | 2 +-
 2 files changed, 5 insertions(+), 1 deletion(-)
block/iscsi.c +4 -0
index 5002916..fac3a7a 100644
@@ -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);
#1 lore raw

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.

---
  block/iscsi.c | 4 ++++
  dtc           | 2 +-
  2 files changed, 5 insertions(+), 1 deletion(-)
block/iscsi.c +0 -0
index 5002916..fac3a7a 100644

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

#2 lore raw
Quoted 11 lines · Peter Lieven
Quoted 11 lines
block/iscsi.c +1 -0
index 5002916..fac3a7a 100644
@@ -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