[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 13/25] arm: avoid heap-buffer-overflow in load_aarch6
From: |
Peter Maydell |
Subject: |
[Qemu-devel] [PULL 13/25] arm: avoid heap-buffer-overflow in load_aarch64_image |
Date: |
Fri, 9 Mar 2018 17:26:10 +0000 |
From: Marc-André Lureau <address@hidden>
Spotted by ASAN:
address@hidden:~/src/qemu/build (master *%)$
QTEST_QEMU_BINARY=aarch64-softmmu/qemu-system-aarch64 tests/boot-serial-test
/aarch64/boot-serial/virt: ** (process:19740): DEBUG: 18:39:30.275: foo
/tmp/qtest-boot-serial-cXaS94D
=================================================================
==19740==ERROR: AddressSanitizer: heap-buffer-overflow on address
0x603000069648 at pc 0x7f1d2201cc54 bp 0x7fff331f6a40 sp 0x7fff331f61e8
READ of size 4 at 0x603000069648 thread T0
#0 0x7f1d2201cc53 (/lib64/libasan.so.4+0xafc53)
#1 0x55bc86685ee3 in load_aarch64_image
/home/elmarco/src/qemu/hw/arm/boot.c:894
#2 0x55bc86687217 in arm_load_kernel_notify
/home/elmarco/src/qemu/hw/arm/boot.c:1047
#3 0x55bc877363b5 in notifier_list_notify
/home/elmarco/src/qemu/util/notify.c:40
#4 0x55bc869331ea in qemu_run_machine_init_done_notifiers
/home/elmarco/src/qemu/vl.c:2716
#5 0x55bc8693bc39 in main /home/elmarco/src/qemu/vl.c:4679
#6 0x7f1d1652c009 in __libc_start_main (/lib64/libc.so.6+0x21009)
#7 0x55bc86255cc9 in _start
(/home/elmarco/src/qemu/build/aarch64-softmmu/qemu-system-aarch64+0x1ae5cc9)
Signed-off-by: Marc-André Lureau <address@hidden>
Reviewed-by: Peter Maydell <address@hidden>
Signed-off-by: Peter Maydell <address@hidden>
---
hw/arm/boot.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/hw/arm/boot.c b/hw/arm/boot.c
index 784d301683..196c7fb242 100644
--- a/hw/arm/boot.c
+++ b/hw/arm/boot.c
@@ -891,7 +891,8 @@ static uint64_t load_aarch64_image(const char *filename,
hwaddr mem_base,
}
/* check the arm64 magic header value -- very old kernels may not have it
*/
- if (memcmp(buffer + ARM64_MAGIC_OFFSET, "ARM\x64", 4) == 0) {
+ if (size > ARM64_MAGIC_OFFSET + 4 &&
+ memcmp(buffer + ARM64_MAGIC_OFFSET, "ARM\x64", 4) == 0) {
uint64_t hdrvals[2];
/* The arm64 Image header has text_offset and image_size fields at 8
and
--
2.16.2
- [Qemu-devel] [PULL 00/25] target-arm queue, Peter Maydell, 2018/03/09
- [Qemu-devel] [PULL 11/25] hw/arm: Use more CONFIG switches for the object files, Peter Maydell, 2018/03/09
- [Qemu-devel] [PULL 12/25] arm: fix load ELF error leak, Peter Maydell, 2018/03/09
- [Qemu-devel] [PULL 13/25] arm: avoid heap-buffer-overflow in load_aarch64_image,
Peter Maydell <=
- [Qemu-devel] [PULL 10/25] aarch64-linux-user: Add support for SVE signal frame records, Peter Maydell, 2018/03/09
- [Qemu-devel] [PULL 15/25] target/arm: Move definition of 'host' cpu type into cpu.c, Peter Maydell, 2018/03/09
- [Qemu-devel] [PULL 09/25] aarch64-linux-user: Add support for EXTRA signal frame records, Peter Maydell, 2018/03/09
- [Qemu-devel] [PULL 19/25] hw/arm/virt: Support -machine gic-version=max, Peter Maydell, 2018/03/09
- [Qemu-devel] [PULL 16/25] target/arm: Add "-cpu max" support, Peter Maydell, 2018/03/09
- [Qemu-devel] [PULL 08/25] aarch64-linux-user: Remove struct target_aux_context, Peter Maydell, 2018/03/09
- [Qemu-devel] [PULL 06/25] linux-user: Implement aarch64 PR_SVE_SET/GET_VL, Peter Maydell, 2018/03/09
- [Qemu-devel] [PULL 07/25] aarch64-linux-user: Split out helpers for guest signal handling, Peter Maydell, 2018/03/09
- [Qemu-devel] [PULL 02/25] hw/arm: Set the core count for Xilinx's ZynqMP, Peter Maydell, 2018/03/09
- [Qemu-devel] [PULL 22/25] sdcard: Display which protocol is used when tracing (SD or SPI), Peter Maydell, 2018/03/09