|
|
9ae3a8 |
From bcf0f4b1f226bcb27e154cc14850f67229b22d90 Mon Sep 17 00:00:00 2001
|
|
|
9ae3a8 |
Message-Id: <bcf0f4b1f226bcb27e154cc14850f67229b22d90.1389014116.git.minovotn@redhat.com>
|
|
|
9ae3a8 |
In-Reply-To: <c8cc35838d42aa286242772d97e3a9be7bb786ba.1389014116.git.minovotn@redhat.com>
|
|
|
9ae3a8 |
References: <c8cc35838d42aa286242772d97e3a9be7bb786ba.1389014116.git.minovotn@redhat.com>
|
|
|
9ae3a8 |
From: Paolo Bonzini <pbonzini@redhat.com>
|
|
|
9ae3a8 |
Date: Mon, 9 Dec 2013 14:09:24 +0100
|
|
|
9ae3a8 |
Subject: [PATCH 36/50] scsi-disk: reject ANCHOR=1 for UNMAP and WRITE SAME
|
|
|
9ae3a8 |
commands
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
RH-Author: Paolo Bonzini <pbonzini@redhat.com>
|
|
|
9ae3a8 |
Message-id: <1386598178-11845-39-git-send-email-pbonzini@redhat.com>
|
|
|
9ae3a8 |
Patchwork-id: 56075
|
|
|
9ae3a8 |
O-Subject: [RHEL 7.0 qemu-kvm PATCH 38/52] scsi-disk: reject ANCHOR=1 for UNMAP and WRITE SAME commands
|
|
|
9ae3a8 |
Bugzilla: 1007815
|
|
|
9ae3a8 |
RH-Acked-by: Jeffrey Cody <jcody@redhat.com>
|
|
|
9ae3a8 |
RH-Acked-by: Fam Zheng <famz@redhat.com>
|
|
|
9ae3a8 |
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Since we report ANC_SUP==0 in VPD page B2h, we need to return
|
|
|
9ae3a8 |
an error (ILLEGAL REQUEST/INVALID FIELD IN CDB) for all WRITE SAME
|
|
|
9ae3a8 |
requests with ANCHOR==1.
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Inspired by a similar patch to the LIO in-kernel target.
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
|
|
|
9ae3a8 |
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
|
|
|
9ae3a8 |
(cherry picked from commit 823bd7391c96ba675f20fd6d952d1cb6e1ffb851)
|
|
|
9ae3a8 |
---
|
|
|
9ae3a8 |
hw/scsi/scsi-disk.c | 12 +++++++++++-
|
|
|
9ae3a8 |
1 file changed, 11 insertions(+), 1 deletion(-)
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Signed-off-by: Michal Novotny <minovotn@redhat.com>
|
|
|
9ae3a8 |
---
|
|
|
9ae3a8 |
hw/scsi/scsi-disk.c | 12 +++++++++++-
|
|
|
9ae3a8 |
1 file changed, 11 insertions(+), 1 deletion(-)
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
diff --git a/hw/scsi/scsi-disk.c b/hw/scsi/scsi-disk.c
|
|
|
9ae3a8 |
index 4138268..0640bb0 100644
|
|
|
9ae3a8 |
--- a/hw/scsi/scsi-disk.c
|
|
|
9ae3a8 |
+++ b/hw/scsi/scsi-disk.c
|
|
|
9ae3a8 |
@@ -1548,6 +1548,11 @@ static void scsi_disk_emulate_unmap(SCSIDiskReq *r, uint8_t *inbuf)
|
|
|
9ae3a8 |
int len = r->req.cmd.xfer;
|
|
|
9ae3a8 |
UnmapCBData *data;
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
+ /* Reject ANCHOR=1. */
|
|
|
9ae3a8 |
+ if (r->req.cmd.buf[1] & 0x1) {
|
|
|
9ae3a8 |
+ goto invalid_field;
|
|
|
9ae3a8 |
+ }
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
if (len < 8) {
|
|
|
9ae3a8 |
goto invalid_param_len;
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
@@ -1578,6 +1583,10 @@ static void scsi_disk_emulate_unmap(SCSIDiskReq *r, uint8_t *inbuf)
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
invalid_param_len:
|
|
|
9ae3a8 |
scsi_check_condition(r, SENSE_CODE(INVALID_PARAM_LEN));
|
|
|
9ae3a8 |
+ return;
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
+invalid_field:
|
|
|
9ae3a8 |
+ scsi_check_condition(r, SENSE_CODE(INVALID_FIELD));
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
static void scsi_disk_emulate_write_data(SCSIRequest *req)
|
|
|
9ae3a8 |
@@ -1856,8 +1865,9 @@ static int32_t scsi_disk_emulate_command(SCSIRequest *req, uint8_t *buf)
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
/*
|
|
|
9ae3a8 |
* We only support WRITE SAME with the unmap bit set for now.
|
|
|
9ae3a8 |
+ * Reject UNMAP=0 or ANCHOR=1.
|
|
|
9ae3a8 |
*/
|
|
|
9ae3a8 |
- if (!(req->cmd.buf[1] & 0x8)) {
|
|
|
9ae3a8 |
+ if (!(req->cmd.buf[1] & 0x8) || (req->cmd.buf[1] & 0x10)) {
|
|
|
9ae3a8 |
goto illegal_request;
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
--
|
|
|
9ae3a8 |
1.7.11.7
|
|
|
9ae3a8 |
|