qemu/include
Alex Bennée 260d49d8e2 hw/elf_ops: defend against weird elf headers
According to the ELF spec:

  PT_LOAD

  The array element specifies a loadable segment, described by
  p_filesz and p_memsz. The bytes from the file are mapped to the
  beginning of the memory segment. If the segment's memory
  size (p_memsz) is larger than the file size (p_filesz), the
  ``extra'' bytes are defined to hold the value 0 and to follow the
  segment's initialized area. The file size may not be larger than the
  memory size. Loadable segment entries in the program header table
  appear in ascending order, sorted on the p_vaddr member.

which implies while both p_filesz and p_memsz can be zero we should
never see a case where p_filesz is greater than the in memory size.
Indeed it has been reported such a hand crafted ELF can blow up, for
example during rom_reset():

  address_space_set(rom->as, rom->addr + rom->datasize, 0,
                    rom->romsize - rom->datasize,
                    MEMTXATTRS_UNSPECIFIED);

which could trigger and underflow leaving QEMU slowly filling a very
large buffer.

Cc: qemu-stable@nongnu.org
Fixes: https://gitlab.com/qemu-project/qemu/-/work_items/4056
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
Message-ID: <20260812081405.3811787-1-alex.bennee@linaro.org>
Signed-off-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
2026-08-16 16:35:27 +02:00
..
accel accel/tcg: Improve docstrings around TCGCPUOps::*watchpoint* handlers 2026-07-06 15:42:18 +02:00
authz
block block/qapi: take stats->lock when reading BlockAcctStats for query-blockstats 2026-08-03 10:42:29 +02:00
chardev ui/console: default vc encoding to cp437 for machine < 11.1 2026-05-09 10:24:33 +04:00
crypto crypto/cipher: Add setaad/gettag for AEAD modes 2026-08-11 18:25:58 +02:00
disas disas: Make disassemble_info::target_info field const 2026-02-03 14:57:34 +01:00
exec accel/tcg: Use TLB_FORCE_SLOW not TLB_MMIO for user-only plugins 2026-07-07 09:48:42 -07:00
fpu fpu: Export floatN_minmax 2026-05-22 11:21:37 -07:00
gdbstub gdbstub: Introduce GdbBreakpointType enumerator 2026-07-06 15:42:18 +02:00
hw hw/elf_ops: defend against weird elf headers 2026-08-16 16:35:27 +02:00
io io: add missing coroutine annotation 2026-07-27 15:51:03 +04:00
libdecnumber include/libdecnumber: replace FSF postal address with licenses URL 2025-06-26 00:42:37 +02:00
migration migration: Make switchover-ack re-usable 2026-07-07 07:12:46 +02:00
monitor monitor: Rename MonitorHMP @mon -> @hmp 2026-08-16 16:34:03 +02:00
net net: Correct padding check in qemu_receive_packet() 2026-07-21 12:18:36 +02:00
plugins plugins: use int64_t for the syscall filter return value 2026-06-18 16:47:12 -07:00
qapi qapi/qmp-registry: Remove unnecessary 'monitor/monitor.h' header 2026-08-16 16:32:42 +02:00
qemu host-utils: fix ssub32/64_saturate return type and clamp direction 2026-08-11 23:20:45 -07:00
qobject json-parser: add location to JSON parsing errors 2026-07-02 13:56:35 +02:00
qom qom/object.c: rename object_class_property_uint*_ptr() to object_class_static_property_uint*_ptr() 2026-08-14 11:31:18 +01:00
scsi scsi: always send valid PREEMPT TYPE field 2026-05-08 16:40:03 +02:00
semihosting semihosting/uaccess: Use the cpu_internal_tswap() functions 2026-03-12 19:24:24 +00:00
standard-headers linux-headers: Update to Linux v7.2-rc1 with KVM_S390_VM_CPU_FEAT_ASTFLEIE2 2026-07-06 13:37:54 +02:00
system system/memory: Make ram device region directly accessible 2026-08-11 15:34:38 -04:00
tcg tcg: Include missing 'qemu/bitops.h' header in tcg-gvec-desc.h 2026-06-18 14:27:04 +02:00
ui ui/gtk: handle console hotplug/unplug events 2026-06-24 15:41:15 +04:00
user user/guest-host: Include exec/abi_ptr.h 2026-07-21 12:18:36 +02:00
elf.h elf: Add EF_MIPS_ARCH_ASE definitions 2025-09-02 17:57:05 +02:00
glib-compat.h glib-compat: add fallback for g_clear_fd/g_autofd 2026-06-24 15:41:14 +04:00
qemu-io.h
qemu-main.h ui & main loop: Redesign of system-specific main thread event handling 2024-12-31 21:21:34 +01:00