iscsi: Don't access non-existent scsi_lba_status_descriptor
PATCH 1/1 iscsi: Don't access non-existent scsi_lba_status_descriptor
In iscsi_co_block_status(), we may have received num_descriptors == 0 from the iscsi server. Therefore, we can't unconditionally access lbas->descriptors[0]. Add the missing check.
--- block/iscsi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
block/iscsi.c +1 -1
@@ -753,7 +753,7 @@ retry: } lbas =scsi_datain_unmarshall (iTask.task); -if (lbas ==NULL ) { +if (lbas ==NULL || lbas->num_descriptors ==0 ) { ret = -EIO ; goto out_unlock; }
Signature · 1 line
2.20.1
Quoted 29 lines · Kevin Wolf
In
iscsi_co_block_status(), we may have receivednum_descriptors== 0 from the iscsi server. Therefore, we can't unconditionally access lbas->descriptors[0]. Add the missing check.Signed-off-by Kevin Wolf <[email protected]>---
block/iscsi.c| 2 +-1 file changed, 1 insertion(+), 1 deletion(-)block/iscsi.c +1
-1@@ -753,7 +753,7 @@ retry: } lbas =scsi_datain_unmarshall (iTask.task); -if (lbas ==NULL ) { +if (lbas ==NULL || lbas->num_descriptors ==0 ) { ret = -EIO ; goto out_unlock; }Signature · 1 line
2.20.1
Quoted 15 lines · Kevin Wolf
In
iscsi_co_block_status(), we may have receivednum_descriptors== 0 from the iscsi server. Therefore, we can't unconditionally access lbas->descriptors[0]. Add the missing check.Signed-off-by Kevin Wolf <[email protected]>--- block/iscsi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)block/iscsi.c +0
-0
block/iscsi.c retry: · line 759
Quoted 8 lines
block/iscsi.c +1
-1@@ -753,7 +753,7 @@ retry: } lbas =scsi_datain_unmarshall (iTask.task); -if (lbas ==NULL ) { +if (lbas ==NULL || lbas->num_descriptors ==0 ) { ret = -EIO ; goto out_unlock; }
Naive question: Does the specification allow for such a response? Is this inherently an error?
Anyway, this is better than accessing junk memory, so:
Quoted 23 lines · John Snow
Quoted 16 lines · Kevin Wolf
In
iscsi_co_block_status(), we may have receivednum_descriptors== 0 from the iscsi server. Therefore, we can't unconditionally access lbas->descriptors[0]. Add the missing check.Signed-off-by Kevin Wolf <[email protected]>---
block/iscsi.c| 2 +-1 file changed, 1 insertion(+), 1 deletion(-)block/iscsi.c +0
-0@@ -753,7 +753,7 @@ retry: }
Quoted 10 lines
block/iscsi.c retry: · line 759
Quoted 7 lines
block/iscsi.c +1
-1lbas =scsi_datain_unmarshall (iTask.task); -if (lbas ==NULL ) { +if (lbas ==NULL || lbas->num_descriptors ==0 ) { ret = -EIO ; goto out_unlock; }Naive question: Does the specification allow for such a response? Is this inherently an error?
The spec doesn't say, but libiscsi (which Qemu should trust) may return zero for num_descriptors with certain server responses (which no one should trust).
https://github.com/sahlberg/libiscsi/blob/master/lib/scsi-lowlevel.c#L845
F.
Quoted 4 lines
Anyway, this is better than accessing junk memory, so:
Reviewed-by John Snow <[email protected]>
Peter Lieven
Reviewed-byAm 23.01.2020 um 21:38 schrieb John Snow <[email protected]>:
Quoted 20 lines
Quoted 17 lines · Kevin Wolf
In
iscsi_co_block_status(), we may have receivednum_descriptors== 0 from the iscsi server. Therefore, we can't unconditionally access lbas->descriptors[0]. Add the missing check.Signed-off-by Kevin Wolf <[email protected]>---
block/iscsi.c| 2 +-1 file changed, 1 insertion(+), 1 deletion(-)block/iscsi.c +0
-0@@ -753,7 +753,7 @@ retry: }
Quoted 10 lines
block/iscsi.c retry: · line 759
Quoted 7 lines
block/iscsi.c +1
-1lbas =scsi_datain_unmarshall (iTask.task); -if (lbas ==NULL ) { +if (lbas ==NULL || lbas->num_descriptors ==0 ) { ret = -EIO ; goto out_unlock; }Naive question: Does the specification allow for such a response? Is this inherently an error?
The spec says the answer SHALL contain at least one lbasd. So I think threating zero as an error is okay
Anyway,
Peter
Am 23.01.2020 um 21:37 hat John Snow geschrieben:
Quoted 17 lines · Kevin Wolf
Quoted 16 lines
In
iscsi_co_block_status(), we may have receivednum_descriptors== 0 from the iscsi server. Therefore, we can't unconditionally access lbas->descriptors[0]. Add the missing check.Signed-off-by Kevin Wolf <[email protected]>--- block/iscsi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)block/iscsi.c +0
-0@@ -753,7 +753,7 @@ retry: }
Quoted 10 lines
block/iscsi.c retry: · line 759
Quoted 7 lines
block/iscsi.c +1
-1lbas =scsi_datain_unmarshall (iTask.task); -if (lbas ==NULL ) { +if (lbas ==NULL || lbas->num_descriptors ==0 ) { ret = -EIO ; goto out_unlock; }Naive question: Does the specification allow for such a response? Is this inherently an error?
Even if iscsi allowed it, it would be a useless response, because it means that you didn't get the block status of any block.
bdrv_co_block_status() may only return *pnum == 0 at EOF, so I don't think we have any other option than returning an error. (We could retry, but if a target returns a useless response once, why should we trust it do behave better the second time?)
Quoted 3 lines
Anyway, this is better than accessing junk memory, so:
Reviewed-by John Snow <[email protected]>
Thanks!
Kevin
Quoted 15 lines · Kevin Wolf
In
iscsi_co_block_status(), we may have receivednum_descriptors== 0 from the iscsi server. Therefore, we can't unconditionally access lbas->descriptors[0]. Add the missing check.Signed-off-by Kevin Wolf <[email protected]>--- block/iscsi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)block/iscsi.c +0
-0
block/iscsi.c retry: · line 759
Quoted 8 lines
block/iscsi.c +1
-1@@ -753,7 +753,7 @@ retry: } lbas =scsi_datain_unmarshall (iTask.task); -if (lbas ==NULL ) { +if (lbas ==NULL || lbas->num_descriptors ==0 ) { ret = -EIO ; goto out_unlock; }