qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Li Qiang <liq3ea@gmail.com>
To: P J P <ppandit@redhat.com>
Cc: Ruhr-University <bugs-syssec@rub.de>,
	John Snow <jsnow@redhat.com>,
	QEMU Developers <qemu-devel@nongnu.org>,
	qemu-block@nongnu.org, Prasad J Pandit <pjp@fedoraproject.org>
Subject: Re: [PATCH] fdc: check null block pointer before blk_pwrite
Date: Fri, 18 Sep 2020 18:52:18 +0800	[thread overview]
Message-ID: <CAKXe6SK2MQS-ntCpo2-TkAh57PcuGRaCBRMur91sxiB1Z-k62g@mail.gmail.com> (raw)
In-Reply-To: <20200827113806.1850687-1-ppandit@redhat.com>

P J P <ppandit@redhat.com> 于2020年8月27日周四 下午7:41写道:
>
> From: Prasad J Pandit <pjp@fedoraproject.org>
>
> While transferring data via fdctrl_write_data(), check that
> current drive does not have a null block pointer. Avoid
> null pointer dereference.
>
>  -> https://ruhr-uni-bochum.sciebo.de/s/NNWP2GfwzYKeKwE?path=%2Ffdc_nullptr1
>     ==1658854==Hint: address points to the zero page.
>     #0 blk_inc_in_flight block/block-backend.c:1327
>     #1 blk_prw block/block-backend.c:1299
>     #2 blk_pwrite block/block-backend.c:1464
>     #3 fdctrl_write_data hw/block/fdc.c:2418
>     #4 fdctrl_write hw/block/fdc.c:962
>     #5 portio_write ioport.c:205
>     #6 memory_region_write_accessor memory.c:483
>     #7 access_with_adjusted_size memory.c:544
>     #8 memory_region_dispatch_write memory.c:1476
>
> Reported-by: Ruhr-University <bugs-syssec@rub.de>
> Signed-off-by: Prasad J Pandit <pjp@fedoraproject.org>
> ---
>  hw/block/fdc.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/hw/block/fdc.c b/hw/block/fdc.c
> index e9ed3eef45..dedadac68a 100644
> --- a/hw/block/fdc.c
> +++ b/hw/block/fdc.c
> @@ -2419,7 +2419,8 @@ static void fdctrl_write_data(FDCtrl *fdctrl, uint32_t value)
>          if (pos == FD_SECTOR_LEN - 1 ||
>              fdctrl->data_pos == fdctrl->data_len) {
>              cur_drv = get_cur_drv(fdctrl);
> -            if (blk_pwrite(cur_drv->blk, fd_offset(cur_drv), fdctrl->fifo,
> +            if (cur_drv->blk
> +                && blk_pwrite(cur_drv->blk, fd_offset(cur_drv), fdctrl->fifo,
>                             BDRV_SECTOR_SIZE, 0) < 0) {
>                  FLOPPY_DPRINTF("error writing sector %d\n",
>                                 fd_sector(cur_drv));
> --

Hello Prasad,

There are several pattern to address this NULL check in fdc.c.
I think it is better to consider this as an error. Just like the check
in 'fdctrl_format_sector':

if (cur_drv->blk == NULL ||
    blk_pwrite(cur_drv->blk, fd_offset(cur_drv), fdctrl->fifo,
    BDRV_SECTOR_SIZE, 0) < 0) {
    FLOPPY_DPRINTF("error formatting sector %d\n", fd_sector(cur_drv));
    fdctrl_stop_transfer(fdctrl, FD_SR0_ABNTERM | FD_SR0_SEEK, 0x00, 0x00);
} else {

Also there seems exists the same issue in  'fdctrl_read_data'

Thanks,
Li Qiang

> 2.26.2
>
>


  parent reply	other threads:[~2020-09-18 10:54 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-27 11:38 [PATCH] fdc: check null block pointer before blk_pwrite P J P
2020-09-15 12:47 ` P J P
2020-09-18 10:52 ` Li Qiang [this message]
2021-03-19  5:09 ` [PATCH 1/2] floppy: add a regression test for CVE-2020-25741 Alexander Bulekov
2021-03-19  5:09   ` [PATCH 2/2] floppy: add a regression test for CVE-2021-20196 Alexander Bulekov
2021-03-19  5:53   ` [PATCH 1/2] floppy: add a regression test for CVE-2020-25741 Markus Armbruster
2021-03-19  9:26     ` Paolo Bonzini
2021-03-19  9:54       ` Markus Armbruster
2021-03-19 10:17         ` Paolo Bonzini
2021-03-19 14:51         ` Alexander Bulekov
2021-03-19 14:52       ` Alexander Bulekov
2021-05-18 17:30 ` [PATCH] fdc: check null block pointer before blk_pwrite John Snow

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=CAKXe6SK2MQS-ntCpo2-TkAh57PcuGRaCBRMur91sxiB1Z-k62g@mail.gmail.com \
    --to=liq3ea@gmail.com \
    --cc=bugs-syssec@rub.de \
    --cc=jsnow@redhat.com \
    --cc=pjp@fedoraproject.org \
    --cc=ppandit@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).