Skip to contentSkip to conversation

scsi-bus: Fix transfer length for VERIFY with BYTCHK=11b

PATCH Applied Markus Armbruster 2 participants 4 messages Jan 29, 2014 – Feb 24, 2014

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 scsi-bus: Fix transfer length for VERIFY with BYTCHK=11b

The transfer length depends on field BYTCHK, which is encoded in byte 1, bits 1..2. However, the guard for for case BYTCHK=11b doesn't work, and we get case 01b instead. Fix it.

Note that since emulated scsi-hd fails the command outright, it takes SCSI passthrough of a device that actually implements VERIFY with BYTCHK=11b to make the bug bite.

Screwed up in commit d12ad44. Spotted by Coverity.

---
 hw/scsi/scsi-bus.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/scsi/scsi-bus.c +1 -1
index 50b89ad..285a58b 100644
@@ -909,7 +909,7 @@ static int scsi_req_length(SCSICommand *cmd, SCSIDevice *dev, uint8_t *buf)
     case VERIFY_16:
         if ((buf[1] & 2) == 0) {
             cmd->xfer = 0;
-        } else if ((buf[1] & 4) == 1) {
+        } else if ((buf[1] & 4) != 0) {
             cmd->xfer = 1;
         }
         cmd->xfer *= dev->blocksize;
Signature · 1 line
1.8.1.4
#1 lore raw

Il 29/01/2014 18:47, Markus Armbruster ha scritto:

Quoted 21 lines

The transfer length depends on field BYTCHK, which is encoded in byte 1, bits 1..2. However, the guard for for case BYTCHK=11b doesn't work, and we get case 01b instead. Fix it.

Note that since emulated scsi-hd fails the command outright, it takes SCSI passthrough of a device that actually implements VERIFY with BYTCHK=11b to make the bug bite.

Screwed up in commit d12ad44. Spotted by Coverity.

---
 hw/scsi/scsi-bus.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/scsi/scsi-bus.c +0 -0
index 50b89ad..285a58b 100644

hw/scsi/scsi-bus.c static int scsi_req_length(SCSICommand *cmd, SCSIDevice *dev, uint8_t *buf) · line 915

Quoted 8 lines
hw/scsi/scsi-bus.c +1 -1
@@ -909,7 +909,7 @@ static int scsi_req_length(SCSICommand *cmd, SCSIDevice *dev, uint8_t *buf)
     case VERIFY_16:
         if ((buf[1] & 2) == 0) {
             cmd->xfer = 0;
-        } else if ((buf[1] & 4) == 1) {
+        } else if ((buf[1] & 4) != 0) {
             cmd->xfer = 1;
         }
         cmd->xfer *= dev->blocksize;

Applied to scsi-next, thanks.

Paolo

#2 lore raw
In reply to Markus Armbruster

Ping?

Quoted 28 lines · Markus Armbruster

The transfer length depends on field BYTCHK, which is encoded in byte 1, bits 1..2. However, the guard for for case BYTCHK=11b doesn't work, and we get case 01b instead. Fix it.

Note that since emulated scsi-hd fails the command outright, it takes SCSI passthrough of a device that actually implements VERIFY with BYTCHK=11b to make the bug bite.

Screwed up in commit d12ad44. Spotted by Coverity.

---
 hw/scsi/scsi-bus.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/scsi/scsi-bus.c +1 -1
index 50b89ad..285a58b 100644
@@ -909,7 +909,7 @@ static int scsi_req_length(SCSICommand *cmd, SCSIDevice *dev, uint8_t *buf)
     case VERIFY_16:
         if ((buf[1] & 2) == 0) {
             cmd->xfer = 0;
-        } else if ((buf[1] & 4) == 1) {
+        } else if ((buf[1] & 4) != 0) {
             cmd->xfer = 1;
         }
         cmd->xfer *= dev->blocksize;
#3 lore raw

Il 24/02/2014 14:07, Markus Armbruster ha scritto:

Quoted 1 line

Ping?

The pull request depends on Kevin's block patches, so I need to wait for that one to get in.

Paolo