qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Kevin Wolf <kwolf@redhat.com>
To: qemu-block@nongnu.org
Cc: kwolf@redhat.com, peter.maydell@linaro.org, qemu-devel@nongnu.org
Subject: [Qemu-devel] [PULL 2/9] fdc: fix segfault in fdctrl_stop_transfer() when DMA is disabled
Date: Mon, 19 Nov 2018 15:29:37 +0100	[thread overview]
Message-ID: <20181119142944.29061-3-kwolf@redhat.com> (raw)
In-Reply-To: <20181119142944.29061-1-kwolf@redhat.com>

From: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>

Commit c8a35f1cf0f "fdc: use IsaDma interface instead of global DMA_*
functions" accidentally introduced a segfault in fdctrl_stop_transfer() for
non-DMA transfers.

If fdctrl->dma_chann has not been configured then the fdctrl->dma interface
reference isn't initialised during isabus_fdc_realize(). Unfortunately
fdctrl_stop_transfer() unconditionally references the DMA interface when
finishing the transfer causing a NULL pointer dereference.

Fix the issue by adding a check in fdctrl_stop_transfer() so that the DMA
interface reference and release method is only invoked if fdctrl->dma_chann
has been set.

(This issue was discovered by Martin testing a recent change in the NetBSD
installer under qemu-system-sparc)

Cc: qemu-stable@nongnu.org
Reported-by: Martin Husemann <martin@duskware.de>
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Hervé Poussineau <hpoussin@reactos.org>
Reviewed-by: John Snow <jsnow@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
 hw/block/fdc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/hw/block/fdc.c b/hw/block/fdc.c
index 2e9c1e1e2f..6f19f127a5 100644
--- a/hw/block/fdc.c
+++ b/hw/block/fdc.c
@@ -1617,7 +1617,7 @@ static void fdctrl_stop_transfer(FDCtrl *fdctrl, uint8_t status0,
     fdctrl->fifo[5] = cur_drv->sect;
     fdctrl->fifo[6] = FD_SECTOR_SC;
     fdctrl->data_dir = FD_DIR_READ;
-    if (!(fdctrl->msr & FD_MSR_NONDMA)) {
+    if (fdctrl->dma_chann != -1 && !(fdctrl->msr & FD_MSR_NONDMA)) {
         IsaDmaClass *k = ISADMA_GET_CLASS(fdctrl->dma);
         k->release_DREQ(fdctrl->dma, fdctrl->dma_chann);
     }
-- 
2.19.1

  parent reply	other threads:[~2018-11-19 14:30 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-19 14:29 [Qemu-devel] [PULL 0/9] Block layer patches Kevin Wolf
2018-11-19 14:29 ` [Qemu-devel] [PULL 1/9] nvme: fix oob access issue(CVE-2018-16847) Kevin Wolf
2018-11-19 14:29 ` Kevin Wolf [this message]
2018-11-19 14:29 ` [Qemu-devel] [PULL 3/9] vvfat: Fix memory leak Kevin Wolf
2018-11-19 14:29 ` [Qemu-devel] [PULL 4/9] qcow2: Document some maximum size constraints Kevin Wolf
2018-11-19 14:29 ` [Qemu-devel] [PULL 5/9] qcow2: Don't allow overflow during cluster allocation Kevin Wolf
2018-11-19 14:29 ` [Qemu-devel] [PULL 6/9] iotests: Add new test 220 for max compressed cluster offset Kevin Wolf
2018-11-19 14:29 ` [Qemu-devel] [PULL 7/9] block: Always abort reopen after prepare succeeded Kevin Wolf
2018-11-19 14:29 ` [Qemu-devel] [PULL 8/9] file-posix: Fix shared locks on reopen commit Kevin Wolf
2018-11-19 14:29 ` [Qemu-devel] [PULL 9/9] iotests: Test file-posix locking and reopen Kevin Wolf
2018-11-19 15:03 ` [Qemu-devel] [PULL 0/9] Block layer patches Peter Maydell

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=20181119142944.29061-3-kwolf@redhat.com \
    --to=kwolf@redhat.com \
    --cc=peter.maydell@linaro.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).