From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:41053) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RKruX-00052C-7U for qemu-devel@nongnu.org; Mon, 31 Oct 2011 09:28:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RKruW-0004Np-6l for qemu-devel@nongnu.org; Mon, 31 Oct 2011 09:28:21 -0400 Received: from mx1.redhat.com ([209.132.183.28]:47830) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RKruV-0004NX-KE for qemu-devel@nongnu.org; Mon, 31 Oct 2011 09:28:20 -0400 From: Kevin Wolf Date: Mon, 31 Oct 2011 14:30:12 +0100 Message-Id: <1320067830-12093-38-git-send-email-kwolf@redhat.com> In-Reply-To: <1320067830-12093-1-git-send-email-kwolf@redhat.com> References: <1320067830-12093-1-git-send-email-kwolf@redhat.com> Subject: [Qemu-devel] [PATCH 37/55] scsi-disk: fail READ CAPACITY if LBA != 0 but PMI == 0 List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: anthony@codemonkey.ws Cc: kwolf@redhat.com, qemu-devel@nongnu.org From: Paolo Bonzini Tested by the Windows Logo Kit SCSI Compliance test. From SBC-3, paragraph 5.25: "The LOGICAL BLOCK ADDRESS field shall be set to zero if the PMI bit is set to zero. If the PMI bit is set to zero and the LOGICAL BLOCK ADDRESS field is not set to zero, then the device server shall terminate the command with CHECK CONDITION status with the sense key set to ILLEGAL REQUEST and the additional sense code set to INVALID FIELD IN CDB". Signed-off-by: Paolo Bonzini Signed-off-by: Kevin Wolf --- hw/scsi-disk.c | 6 ++++++ 1 files changed, 6 insertions(+), 0 deletions(-) diff --git a/hw/scsi-disk.c b/hw/scsi-disk.c index 50fc3d6..6b139ac 100644 --- a/hw/scsi-disk.c +++ b/hw/scsi-disk.c @@ -1180,6 +1180,9 @@ static int scsi_disk_emulate_command(SCSIDiskReq *r) if (!nb_sectors) { goto not_ready; } + if ((req->cmd.buf[8] & 1) == 0 && req->cmd.lba) { + goto illegal_request; + } nb_sectors /= s->cluster_size; /* Returned value is the address of the last sector. */ nb_sectors--; @@ -1232,6 +1235,9 @@ static int scsi_disk_emulate_command(SCSIDiskReq *r) if (!nb_sectors) { goto not_ready; } + if ((req->cmd.buf[14] & 1) == 0 && req->cmd.lba) { + goto illegal_request; + } nb_sectors /= s->cluster_size; /* Returned value is the address of the last sector. */ nb_sectors--; -- 1.7.6.4