Skip to contentSkip to conversation

vhost/scsi: Check LUN structure byte 0 is set to 1, per spec

PATCH Applied Venkatesh Srinivas 3 participants 3 messages Feb 24, 2014 – Feb 25, 2014

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 vhost/scsi: Check LUN structure byte 0 is set to 1, per spec

The virtio spec requires byte 0 of the virtio-scsi LUN structure to be '1'.

---
 drivers/vhost/scsi.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/vhost/scsi.c +6 -0
index 0a025b8..e48d4a6 100644
@@ -1001,6 +1001,12 @@ vhost_scsi_handle_vq(struct vhost_scsi *vs, struct vhost_virtqueue *vq)
 			break;
 		}
 
+		/* virtio-scsi spec requires byte 0 of the lun to be 1 */
+		if (unlikely(v_req.lun[0] != 1)) {
+			vhost_scsi_send_bad_target(vs, vq, head, out);
+			continue;
+		}
+
 		/* Extract the tpgt */
 		target = v_req.lun[1];
 		tpg = ACCESS_ONCE(vs_tpg[target]);
Signature · 1 line
1.8.5.3
reviewer Reviewed-by on v1 1/1
#1 lore raw
Quoted 25 lines

The virtio spec requires byte 0 of the virtio-scsi LUN structure to be '1'.

---
  drivers/vhost/scsi.c | 6 ++++++
  1 file changed, 6 insertions(+)
drivers/vhost/scsi.c +6 -0
index 0a025b8..e48d4a6 100644
@@ -1001,6 +1001,12 @@ vhost_scsi_handle_vq(struct vhost_scsi *vs, struct
 vhost_virtqueue *vq)
  			break;
  		}
 
+		/* virtio-scsi spec requires byte 0 of the lun to be 1 */
+		if (unlikely(v_req.lun[0] != 1)) {
+			vhost_scsi_send_bad_target(vs, vq, head, out);
+			continue;
+		}
+
  		/* Extract the tpgt */
  		target = v_req.lun[1];
Quoted 4 lines

tpg = ACCESS_ONCE(vs_tpg[target]);
--
1.8.5.3

#2 lore raw
In reply to Venkatesh Srinivas

Hi Venkatesh,

Quoted 15 lines · Venkatesh Srinivas

The virtio spec requires byte 0 of the virtio-scsi LUN structure to be '1'.

---
  drivers/vhost/scsi.c | 6 ++++++
  1 file changed, 6 insertions(+)
drivers/vhost/scsi.c +0 -0
index 0a025b8..e48d4a6 100644
@@ -1001,6 +1001,12 @@ vhost_scsi_handle_vq(struct vhost_scsi *vs, struct vhost_virtqueue *vq)
  			break;
  		}

drivers/vhost/scsi.c vhost_scsi_handle_vq(struct vhost_scsi *vs, struct vhost_virtqueue *vq) · line 1012

Quoted 10 lines
drivers/vhost/scsi.c +6 -0
 
+		/* virtio-scsi spec requires byte 0 of the lun to be 1 */
+		if (unlikely(v_req.lun[0] != 1)) {
+			vhost_scsi_send_bad_target(vs, vq, head, out);
+			continue;
+		}
+
  		/* Extract the tpgt */
  		target = v_req.lun[1];
  		tpg = ACCESS_ONCE(vs_tpg[target]);

Applied to target-pending/master, and including in the next v3.14-rc PULL request.

Thanks!

--nab