qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: David Gibson <david@gibson.dropbear.id.au>
To: Igor Mammedov <imammedo@redhat.com>
Cc: qemu-devel@nongnu.org, mst@redhat.com
Subject: Re: [Qemu-devel] [PATCH] pc-dimm: fix crash when invalid slot number is used
Date: Wed, 24 Jul 2019 13:18:45 +1000	[thread overview]
Message-ID: <20190724031845.GU25073@umbus.fritz.box> (raw)
In-Reply-To: <20190723160859.27250-1-imammedo@redhat.com>

[-- Attachment #1: Type: text/plain, Size: 1611 bytes --]

On Tue, Jul 23, 2019 at 12:08:59PM -0400, Igor Mammedov wrote:
> QEMU will crash with:
>   Segmentation fault (core dumped)
> when negative slot number is used, ex:
>   qemu-system-x86_64 -m 1G,maxmem=20G,slots=256 \
>       -object memory-backend-ram,id=mem1,size=1G \
>       -device pc-dimm,id=dimm1,memdev=mem1,slot=-2
> 
> fix it by checking that slot number is within valid range.
> 
> Signed-off-by: Igor Mammedov <imammedo@redhat.com>

Reviewed-by: David Gibson <david@gibson.dropbear.id.au>

> ---
>  hw/mem/pc-dimm.c | 7 +++++++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/hw/mem/pc-dimm.c b/hw/mem/pc-dimm.c
> index b1239fd0d3..29c785799c 100644
> --- a/hw/mem/pc-dimm.c
> +++ b/hw/mem/pc-dimm.c
> @@ -38,6 +38,13 @@ void pc_dimm_pre_plug(PCDIMMDevice *dimm, MachineState *machine,
>  
>      slot = object_property_get_int(OBJECT(dimm), PC_DIMM_SLOT_PROP,
>                                     &error_abort);
> +    if ((slot < 0 || slot >= machine->ram_slots) &&
> +         slot != PC_DIMM_UNASSIGNED_SLOT) {
> +        error_setg(&local_err, "invalid slot number, valid range is [0-%"
> +                   PRIu64 "]", machine->ram_slots - 1);
> +        goto out;
> +    }
> +
>      slot = pc_dimm_get_free_slot(slot == PC_DIMM_UNASSIGNED_SLOT ? NULL : &slot,
>                                   machine->ram_slots, &local_err);
>      if (local_err) {

-- 
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

  reply	other threads:[~2019-07-24  3:29 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-29 21:15 [Qemu-devel] [PULL 0/3] virtio, pc: fixes Michael S. Tsirkin
2019-07-23 16:08 ` [Qemu-devel] [PATCH] pc-dimm: fix crash when invalid slot number is used Igor Mammedov
2019-07-24  3:18   ` David Gibson [this message]
2019-07-24  6:13   ` Li Qiang
2019-07-24  6:39   ` Pankaj Gupta
2019-07-29 21:16   ` [Qemu-devel] [PULL 3/3] " Michael S. Tsirkin
2019-07-30 12:36   ` Igor Mammedov
2019-07-30 15:50     ` Michael S. Tsirkin
2019-07-30  9:44 ` [Qemu-devel] [PULL 0/3] virtio, pc: fixes Peter Maydell
  -- strict thread matches above, loose matches on Subject: below --
2019-07-29 16:29 [Qemu-devel] [For 4.1 PATCH v2 0/2] Reversions to fix PCIe in virtio Dr. David Alan Gilbert (git)
2019-07-29 16:29 ` [Qemu-devel] [PATCH v2 1/2] Revert "Revert "globals: Allow global properties to be optional"" Dr. David Alan Gilbert (git)
2019-07-29 16:30   ` Daniel P. Berrangé
2019-07-29 16:46   ` Cornelia Huck
2019-07-29 21:16   ` [Qemu-devel] [PULL 1/3] " Michael S. Tsirkin
2019-07-29 16:29 ` [Qemu-devel] [PATCH v2 2/2] Revert "hw: report invalid disable-legacy|modern usage for virtio-1-only devs" Dr. David Alan Gilbert (git)
2019-07-29 16:31   ` Daniel P. Berrangé
2019-07-29 16:46   ` Cornelia Huck
2019-07-29 21:16   ` [Qemu-devel] [PULL 2/3] " Michael S. Tsirkin
2019-07-29 16:32 ` [Qemu-devel] [For 4.1 PATCH v2 0/2] Reversions to fix PCIe in virtio Cornelia Huck
2019-07-29 16:35   ` Dr. David Alan Gilbert
2019-07-29 16:43     ` Peter Maydell
2019-07-29 16:45       ` 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=20190724031845.GU25073@umbus.fritz.box \
    --to=david@gibson.dropbear.id.au \
    --cc=imammedo@redhat.com \
    --cc=mst@redhat.com \
    --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).