]> git.ipfire.org Git - thirdparty/qemu.git/commit
hw/i386/elfboot: allocate "header" in heap
authorSergio Lopez <slp@redhat.com>
Sat, 9 Nov 2024 05:37:48 +0000 (06:37 +0100)
committerPhilippe Mathieu-Daudé <philmd@linaro.org>
Mon, 18 Nov 2024 12:36:39 +0000 (13:36 +0100)
commit13cd9e6798536c35949440d9fc11f54cc052fce3
treea73a2dfe976aa6844d0bc614a1b4a481ddecaea3
parenta29a9776407e68c5560687e07828925bda710150
hw/i386/elfboot: allocate "header" in heap

In x86_load_linux(), we were using a stack-allocated array as data for
fw_cfg_add_bytes(). Since the latter just takes a reference to the
pointer instead of copying the data, it can happen that the contents
have been overridden by the time the guest attempts to access them.

Instead of using the stack-allocated array, allocate some memory from
the heap, copy the contents of the array, and use it for fw_cfg.

Signed-off-by: Sergio Lopez <slp@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-ID: <20241109053748.13183-1-slp@redhat.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
hw/i386/x86-common.c