From: Pankaj Gupta <pagupta@redhat.com>
To: Igor Mammedov <imammedo@redhat.com>
Cc: mst@redhat.com, qemu-devel@nongnu.org, david@gibson.dropbear.id.au
Subject: Re: [Qemu-devel] [PATCH] pc-dimm: fix crash when invalid slot number is used
Date: Wed, 24 Jul 2019 02:39:31 -0400 (EDT) [thread overview]
Message-ID: <1163453389.4034945.1563950371742.JavaMail.zimbra@redhat.com> (raw)
In-Reply-To: <20190723160859.27250-1-imammedo@redhat.com>
> 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>
> ---
> 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) {
> --
Reviewed-by: Pankaj Gupta <pagupta@redhat.com>
> 2.18.1
>
>
>
next prev parent reply other threads:[~2019-07-24 6:39 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-29 21:16 ` [Qemu-devel] [PULL 3/3] " Michael S. Tsirkin
2019-07-24 3:18 ` [Qemu-devel] [PATCH] " David Gibson
2019-07-24 6:13 ` Li Qiang
2019-07-24 6:39 ` Pankaj Gupta [this message]
2019-07-30 12:36 ` [Qemu-devel] [PULL 3/3] " 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 21:16 ` [Qemu-devel] [PULL 1/3] " Michael S. Tsirkin
2019-07-29 16:30 ` [Qemu-devel] [PATCH v2 1/2] " Daniel P. Berrangé
2019-07-29 16:46 ` Cornelia Huck
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 21:16 ` [Qemu-devel] [PULL 2/3] " Michael S. Tsirkin
2019-07-29 16:31 ` [Qemu-devel] [PATCH v2 2/2] " Daniel P. Berrangé
2019-07-29 16:46 ` Cornelia Huck
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=1163453389.4034945.1563950371742.JavaMail.zimbra@redhat.com \
--to=pagupta@redhat.com \
--cc=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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.