qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: P J P <ppandit@redhat.com>
To: John Snow <jsnow@redhat.com>
Cc: Ruhr-University <bugs-syssec@rub.de>,
	QEMU Developers <qemu-devel@nongnu.org>,
	qemu-block@nongnu.org, Prasad J Pandit <pjp@fedoraproject.org>
Subject: [PATCH] hw/ide: check null block pointer before blk_drain
Date: Thu, 27 Aug 2020 17:14:28 +0530	[thread overview]
Message-ID: <20200827114428.1850912-1-ppandit@redhat.com> (raw)

From: Prasad J Pandit <pjp@fedoraproject.org>

While cancelling an i/o operation via ide_cancel_dma_sync(),
check for null block pointer before calling blk_drain(). Avoid
null pointer dereference.

 -> https://ruhr-uni-bochum.sciebo.de/s/NNWP2GfwzYKeKwE?path=%2Fide_nullptr1
    ==1803100==Hint: address points to the zero page.
    #0 blk_bs ../block/block-backend.c:714
    #1 blk_drain ../block/block-backend.c:1715
    #2 ide_cancel_dma_sync ../hw/ide/core.c:723
    #3 bmdma_cmd_writeb ../hw/ide/pci.c:298
    #4 bmdma_write ../hw/ide/piix.c:75
    #5 memory_region_write_accessor ../softmmu/memory.c:483
    #6 access_with_adjusted_size ../softmmu/memory.c:544
    #7 memory_region_dispatch_write ../softmmu/memory.c:1465
    #8 flatview_write_continue ../exec.c:3176
    ...

Reported-by: Ruhr-University <bugs-syssec@rub.de>
Signed-off-by: Prasad J Pandit <pjp@fedoraproject.org>
---
 hw/ide/core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/hw/ide/core.c b/hw/ide/core.c
index d997a78e47..038af1cd6b 100644
--- a/hw/ide/core.c
+++ b/hw/ide/core.c
@@ -718,7 +718,7 @@ void ide_cancel_dma_sync(IDEState *s)
      * whole DMA operation will be submitted to disk with a single
      * aio operation with preadv/pwritev.
      */
-    if (s->bus->dma->aiocb) {
+    if (s->blk && s->bus->dma->aiocb) {
         trace_ide_cancel_dma_sync_remaining();
         blk_drain(s->blk);
         assert(s->bus->dma->aiocb == NULL);
-- 
2.26.2



             reply	other threads:[~2020-08-27 11:47 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-27 11:44 P J P [this message]
2020-08-31 20:27 ` [PATCH] hw/ide: check null block pointer before blk_drain Philippe Mathieu-Daudé
2020-09-03 11:05   ` P J P
2020-09-03 13:09     ` Philippe Mathieu-Daudé
2020-09-03 13:39       ` P J P

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=20200827114428.1850912-1-ppandit@redhat.com \
    --to=ppandit@redhat.com \
    --cc=bugs-syssec@rub.de \
    --cc=jsnow@redhat.com \
    --cc=pjp@fedoraproject.org \
    --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).