From: Stefan Hajnoczi <stefanha@gmail.com>
To: Hannes Reinecke <hare@suse.de>
Cc: qemu-devel@nongnu.org, nab@linux-iscsi.org, kraxel@redhat.com
Subject: [Qemu-devel] Re: [PATCH] scsi-disk: add data direction checking
Date: Tue, 23 Nov 2010 10:20:56 +0000 [thread overview]
Message-ID: <AANLkTik9=q4F8CAH82qXRaBRFuvBQk_OpBZ5xxfOh4Py@mail.gmail.com> (raw)
In-Reply-To: <4CEB939E.70700@suse.de>
On Tue, Nov 23, 2010 at 10:12 AM, Hannes Reinecke <hare@suse.de> wrote:
> On 11/23/2010 11:03 AM, Stefan Hajnoczi wrote:
>> On Mon, Nov 22, 2010 at 10:15 AM, Hannes Reinecke <hare@suse.de> wrote:
>>> @@ -172,6 +170,9 @@ static void scsi_read_data(SCSIRequest *req)
>>> /* No data transfer may already be in progress */
>>> assert(r->req.aiocb == NULL);
>>>
>>> + if (r->req.cmd.mode == SCSI_XFER_TO_DEV)
>>> + BADF("Data transfer direction invalid\n");
>>> +
>>> if (r->sector_count == (uint32_t)-1) {
>>> DPRINTF("Read buf_len=%zd\n", r->iov[0].iov_len);
>>> r->sector_count = 0;
>>> @@ -284,6 +285,9 @@ static int scsi_write_data(SCSIRequest *req)
>>> /* No data transfer may already be in progress */
>>> assert(r->req.aiocb == NULL);
>>>
>>> + if (r->req.cmd.mode != SCSI_XFER_TO_DEV)
>>> + BADF("Data transfer direction invalid\n");
>>> +
>>> n = iov_size(r->iov, r->iov_num) / 512;
>>> if (n) {
>>> qemu_iovec_init_external(&r->qiov, r->iov, r->iov_num);
>>
>> If the guest can trigger this then there must be a SCSI response (an
>> error?). Right now BADF() will do fprintf(stderr) and then continue
>> executing.
>>
>> Can we abort the operation?
>>
> I've done a patch for it as per suggestion by hch.
> Right now we have
>
> if (r->req.cmd.mode == SCSI_XFER_TO_DEV) {
> DPRINTF("Data transfer direction invalid\n");
> scsi_read_complete(r, -EINVAL);
> return;
> }
>
> and -EINVAL will return the sense code 'INVALID FIELD IN CDB'.
> Will be in the next patchset.
Sounds good.
Stefan
prev parent reply other threads:[~2010-11-23 10:21 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-11-22 10:15 [Qemu-devel] [PATCH] scsi-disk: add data direction checking Hannes Reinecke
2010-11-23 10:03 ` [Qemu-devel] " Stefan Hajnoczi
2010-11-23 10:12 ` Hannes Reinecke
2010-11-23 10:20 ` Stefan Hajnoczi [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='AANLkTik9=q4F8CAH82qXRaBRFuvBQk_OpBZ5xxfOh4Py@mail.gmail.com' \
--to=stefanha@gmail.com \
--cc=hare@suse.de \
--cc=kraxel@redhat.com \
--cc=nab@linux-iscsi.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).