qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Philippe Mathieu-Daudé" <philmd@redhat.com>
To: P J P <ppandit@redhat.com>
Cc: Alexander Bulekov <alxndr@bu.edu>,
	QEMU Developers <qemu-devel@nongnu.org>,
	Stefan Hajnoczi <stefanha@redhat.com>,
	Prasad J Pandit <pjp@fedoraproject.org>
Subject: Re: [PATCH 1/2] sd: check bit number before setting card_status flag
Date: Wed, 20 May 2020 18:40:40 +0200	[thread overview]
Message-ID: <1da5a868-5ad4-28ee-143e-46b3f2e8da6d@redhat.com> (raw)
In-Reply-To: <20200520152450.200362-2-ppandit@redhat.com>

Hi Prasad,

On 5/20/20 5:24 PM, P J P wrote:
> From: Prasad J Pandit <pjp@fedoraproject.org>
> 
> SD card emulator sets 'sd->card_status' while performing block
> write commands. While doing so, it tests the corresponding bit
> derived from 's->data_start' address. This may lead to OOB access.
> Add check to avoid it.

Ah, this is different that the one reported recently:
https://bugs.launchpad.net/qemu/+bug/1878054

Do you have a reproducer?

Is this a CVE?

> 
> Reported-by: Alex <alxndr@bu.edu>

This is not Alexander complete name.

> Signed-off-by: Prasad J Pandit <pjp@fedoraproject.org>
> ---
>   hw/sd/sd.c | 7 ++++++-
>   1 file changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/hw/sd/sd.c b/hw/sd/sd.c
> index 71a9af09ab..916e9fff58 100644
> --- a/hw/sd/sd.c
> +++ b/hw/sd/sd.c
> @@ -802,7 +802,12 @@ static void sd_function_switch(SDState *sd, uint32_t arg)
>   
>   static inline bool sd_wp_addr(SDState *sd, uint64_t addr)
>   {
> -    return test_bit(sd_addr_to_wpnum(addr), sd->wp_groups);
> +    uint64_t bit = sd_addr_to_wpnum(addr);
> +
> +    if (bit < sd->wpgrps_size) {

This should never be called with a such address, so I'd simply use an 
assertion here.

The problem is earlier where the address should be validated and a 
protocol error returned.

> +        return test_bit(bit, sd->wp_groups);
> +    }
> +    return true;
>   }
>   
>   static void sd_lock_command(SDState *sd)
> 



  reply	other threads:[~2020-05-20 16:42 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-20 15:24 [PATCH 0/2] avoid OOB access in SD card emulator P J P
2020-05-20 15:24 ` [PATCH 1/2] sd: check bit number before setting card_status flag P J P
2020-05-20 16:40   ` Philippe Mathieu-Daudé [this message]
2020-05-20 15:24 ` [PATCH 2/2] sd: disable sdhci-pci device by default P J P
2020-05-20 15:39   ` Peter Maydell
2020-05-20 16:33     ` Philippe Mathieu-Daudé
2020-05-21 10:08       ` P J P
2020-05-20 16:38     ` Daniel P. Berrangé

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=1da5a868-5ad4-28ee-143e-46b3f2e8da6d@redhat.com \
    --to=philmd@redhat.com \
    --cc=alxndr@bu.edu \
    --cc=pjp@fedoraproject.org \
    --cc=ppandit@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.com \
    /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).