From: Stefan Hajnoczi <stefanha@redhat.com>
To: Deepa Srinivasan <deepa.srinivasan@oracle.com>
Cc: kwolf@redhat.com, mreitz@redhat.com, pbonzini@redhat.com,
qemu-block@nongnu.org, qemu-devel@nongnu.org,
mark.kanda@oracle.com,
Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Subject: Re: [Qemu-devel] [PATCH v2] block: Fix qemu crash when using scsi-block
Date: Mon, 5 Mar 2018 16:38:05 +0000 [thread overview]
Message-ID: <20180305163805.GA26426@stefanha-x1.localdomain> (raw)
In-Reply-To: <1513385953-5466-1-git-send-email-deepa.srinivasan@oracle.com>
[-- Attachment #1: Type: text/plain, Size: 2450 bytes --]
On Fri, Dec 15, 2017 at 04:59:13PM -0800, Deepa Srinivasan wrote:
> Starting qemu with the following arguments causes qemu to segfault:
> ... -device lsi,id=lsi0 -drive file=iscsi:<...>,format=raw,if=none,node-name=
> iscsi1 -device scsi-block,bus=lsi0.0,id=<...>,drive=iscsi1
>
> This patch fixes blk_aio_ioctl() so it does not pass stack addresses to
> blk_aio_ioctl_entry() which may be invoked after blk_aio_ioctl() returns. More
> details about the bug follow.
>
> blk_aio_ioctl() invokes blk_aio_prwv() with blk_aio_ioctl_entry as the
> coroutine parameter. blk_aio_prwv() ultimately calls aio_co_enter().
>
> When blk_aio_ioctl() is executed from within a coroutine context (e.g.
> iscsi_bh_cb()), aio_co_enter() adds the coroutine (blk_aio_ioctl_entry) to
> the current coroutine's wakeup queue. blk_aio_ioctl() then returns.
>
> When blk_aio_ioctl_entry() executes later, it accesses an invalid pointer:
> ....
> BlkRwCo *rwco = &acb->rwco;
>
> rwco->ret = blk_co_ioctl(rwco->blk, rwco->offset,
> rwco->qiov->iov[0].iov_base); <--- qiov is
> invalid here
> ...
>
> In the case when blk_aio_ioctl() is called from a non-coroutine context,
> blk_aio_ioctl_entry() executes immediately. But if bdrv_co_ioctl() calls
> qemu_coroutine_yield(), blk_aio_ioctl() will return. When the coroutine
> execution is complete, control returns to blk_aio_ioctl_entry() after the call
> to blk_co_ioctl(). There is no invalid reference after this point, but the
> function is still holding on to invalid pointers.
>
> The fix is to change blk_aio_prwv() to accept a void pointer for the IO buffer
> rather than a QEMUIOVector. blk_aio_prwv() passes this through in BlkRwCo and the
> coroutine function casts it to QEMUIOVector or uses the void pointer directly.
>
> Signed-off-by: Deepa Srinivasan <deepa.srinivasan@oracle.com>
> Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
> Reviewed-by: Mark Kanda <mark.kanda@oracle.com>
> ---
> block/block-backend.c | 51 +++++++++++++++++++++++++--------------------------
> 1 file changed, 25 insertions(+), 26 deletions(-)
There has been no activity after pings, I'm merging this now although
technically it should go via Kevin's tree.
Thanks, applied to my block-next tree:
https://github.com/stefanha/qemu/commits/block-next
Stefan
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 455 bytes --]
prev parent reply other threads:[~2018-03-05 16:38 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-12-16 0:59 [Qemu-devel] [PATCH v2] block: Fix qemu crash when using scsi-block Deepa Srinivasan
2017-12-18 12:45 ` Paolo Bonzini
2017-12-18 13:22 ` Stefan Hajnoczi
2018-01-29 15:51 ` [Qemu-devel] [Qemu-block] " Stefan Hajnoczi
2018-02-23 20:34 ` Deepa Srinivasan
2018-03-05 16:38 ` 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=20180305163805.GA26426@stefanha-x1.localdomain \
--to=stefanha@redhat.com \
--cc=deepa.srinivasan@oracle.com \
--cc=konrad.wilk@oracle.com \
--cc=kwolf@redhat.com \
--cc=mark.kanda@oracle.com \
--cc=mreitz@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-block@nongnu.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).