From: "Philippe Mathieu-Daudé" <philmd@redhat.com>
To: qemu-devel@nongnu.org
Cc: "Fam Zheng" <fam@euphon.net>,
"Peter Maydell" <peter.maydell@linaro.org>,
"Michael S. Tsirkin" <mst@redhat.com>,
"Jason Wang" <jasowang@redhat.com>,
"Christian Schoenebeck" <qemu_oss@crudebyte.com>,
"Gerd Hoffmann" <kraxel@redhat.com>,
"Eric Blake" <eblake@redhat.com>,
qemu-block@nongnu.org, "John Snow" <jsnow@redhat.com>,
"David Hildenbrand" <david@redhat.com>,
"Markus Armbruster" <armbru@redhat.com>,
"Laurent Vivier" <lvivier@redhat.com>,
"Thomas Huth" <thuth@redhat.com>,
"Eduardo Habkost" <ehabkost@redhat.com>,
"Richard Henderson" <richard.henderson@linaro.org>,
"Alex Williamson" <alex.williamson@redhat.com>,
qemu-arm@nongnu.org, "Alex Bennée" <alex.bennee@linaro.org>,
"David Gibson" <david@gibson.dropbear.id.au>,
"Kevin Wolf" <kwolf@redhat.com>,
"Vladimir Sementsov-Ogievskiy" <vsementsov@virtuozzo.com>,
"Daniel P . Berrange" <berrange@redhat.com>,
"Hanna Reitz" <hreitz@redhat.com>,
qemu-ppc@nongnu.org, "Paolo Bonzini" <pbonzini@redhat.com>
Subject: Re: [PATCH v2 00/30] glib: Replace g_memdup() by g_memdup2()
Date: Fri, 3 Sep 2021 19:43:16 +0200 [thread overview]
Message-ID: <b9c2ff43-e663-6204-f7a9-b8c81affc222@redhat.com> (raw)
In-Reply-To: <20210903174008.749126-1-philmd@redhat.com>
On 9/3/21 7:39 PM, Philippe Mathieu-Daudé wrote:
> Per https://discourse.gnome.org/t/port-your-module-from-g-memdup-to-g-memdup2-now/5538
>
> The old API took the size of the memory to duplicate as a guint,
> whereas most memory functions take memory sizes as a gsize. This
> made it easy to accidentally pass a gsize to g_memdup(). For large
> values, that would lead to a silent truncation of the size from 64
> to 32 bits, and result in a heap area being returned which is
> significantly smaller than what the caller expects. This can likely
> be exploited in various modules to cause a heap buffer overflow.
>
> g_memdup() as been deprecated in GLib 2.68. Since QEMU defines
> GLIB_VERSION_MAX_ALLOWED to GLIB_VERSION_2_56, the deprecation
> is not displayed (on GLib >= 2.68 such available on Fedora 34).
> However the function is still unsafe, so it is better to avoid
> its use.
>
> This series provides the safely equivalent g_memdup2() wrapper,
> and replace all g_memdup() calls by it.
>
> The previous link recommend to audit the call sites. Most of the
> calls use byte_size=sizeof(STRUCT), and no STRUCT appears to be
>> 4GiB. Few calls use unsigned/size_t/uint16_t. Where code is
> doing multiplication, patches are sent as RFC. In particular:
> hw/net/virtio-net.c
> hw/virtio/virtio-crypto.c
>
> Since v1:
> - Added missing g_memdup2 -> g_memdup2_qemu compat definition (danpb)
> - Do not call g_memdup2_qemu() but directly g_memdup2() (danpb)
>
> Philippe Mathieu-Daudé (30):
> hw/hyperv/vmbus: Remove unused vmbus_load/save_req()
> glib-compat: Introduce g_memdup2() wrapper
> qapi: Replace g_memdup() by g_memdup2()
> accel/tcg: Replace g_memdup() by g_memdup2()
> block/qcow2-bitmap: Replace g_memdup() by g_memdup2()
> softmmu: Replace g_memdup() by g_memdup2()
> hw/9pfs: Replace g_memdup() by g_memdup2()
> hw/acpi: Avoid truncating acpi_data_len() to 32-bit
> hw/acpi: Replace g_memdup() by g_memdup2()
> hw/core/machine: Replace g_memdup() by g_memdup2()
> hw/hppa/machine: Replace g_memdup() by g_memdup2()
> hw/i386/multiboot: Replace g_memdup() by g_memdup2()
> hw/net/eepro100: Replace g_memdup() by g_memdup2()
> hw/nvram/fw_cfg: Replace g_memdup() by g_memdup2()
> hw/scsi/mptsas: Replace g_memdup() by g_memdup2()
> hw/ppc/spapr_pci: Replace g_memdup() by g_memdup2()
> hw/rdma: Replace g_memdup() by g_memdup2()
> hw/vfio/pci: Replace g_memdup() by g_memdup2()
> RFC hw/virtio: Replace g_memdup() by g_memdup2()
> net/colo: Replace g_memdup() by g_memdup2()
> RFC ui/clipboard: Replace g_memdup() by g_memdup2()
> RFC linux-user: Replace g_memdup() by g_memdup2()
> tests/unit: Replace g_memdup() by g_memdup2()
> tests/qtest: Replace g_memdup() by g_memdup2()
> target/arm: Replace g_memdup() by g_memdup2()
> target/ppc: Replace g_memdup() by g_memdup2()
> contrib: Replace g_memdup() by g_memdup2()
> checkpatch: Do not allow deprecated g_memdup()
> f
> test
I figured too late I was not placed in the correct commit,
please disregard this incomplete series...
prev parent reply other threads:[~2021-09-03 17:48 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-09-03 17:39 [PATCH v2 00/30] glib: Replace g_memdup() by g_memdup2() Philippe Mathieu-Daudé
2021-09-03 17:39 ` [PATCH v2 01/30] hw/hyperv/vmbus: Remove unused vmbus_load/save_req() Philippe Mathieu-Daudé
2021-09-03 17:39 ` [PATCH v2 02/30] glib-compat: Introduce g_memdup2() wrapper Philippe Mathieu-Daudé
2021-09-03 17:43 ` Philippe Mathieu-Daudé [this message]
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=b9c2ff43-e663-6204-f7a9-b8c81affc222@redhat.com \
--to=philmd@redhat.com \
--cc=alex.bennee@linaro.org \
--cc=alex.williamson@redhat.com \
--cc=armbru@redhat.com \
--cc=berrange@redhat.com \
--cc=david@gibson.dropbear.id.au \
--cc=david@redhat.com \
--cc=eblake@redhat.com \
--cc=ehabkost@redhat.com \
--cc=fam@euphon.net \
--cc=hreitz@redhat.com \
--cc=jasowang@redhat.com \
--cc=jsnow@redhat.com \
--cc=kraxel@redhat.com \
--cc=kwolf@redhat.com \
--cc=lvivier@redhat.com \
--cc=mst@redhat.com \
--cc=pbonzini@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-arm@nongnu.org \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=qemu-ppc@nongnu.org \
--cc=qemu_oss@crudebyte.com \
--cc=richard.henderson@linaro.org \
--cc=thuth@redhat.com \
--cc=vsementsov@virtuozzo.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).