From: Laurent Vivier <laurent@vivier.eu>
To: qemu-devel@nongnu.org
Cc: qemu-trivial@nongnu.org,
"Richard Henderson" <richard.henderson@linaro.org>,
"Laurent Vivier" <laurent@vivier.eu>,
"Philippe Mathieu-Daudé" <f4bug@amsat.org>
Subject: [PULL 16/44] hw/core/sysbus: Assert memory region index is in range
Date: Tue, 1 Sep 2020 16:09:26 +0200 [thread overview]
Message-ID: <20200901140954.889743-17-laurent@vivier.eu> (raw)
In-Reply-To: <20200901140954.889743-1-laurent@vivier.eu>
From: Philippe Mathieu-Daudé <f4bug@amsat.org>
Devices incorrectly modelled might use invalid index while
calling sysbus_mmio_get_region(), leading to OOB access.
Help developers by asserting the index is in range.
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-Id: <20200806130945.21629-3-f4bug@amsat.org>
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
---
hw/core/sysbus.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/hw/core/sysbus.c b/hw/core/sysbus.c
index 77ab351ce1a8..294f90b7deef 100644
--- a/hw/core/sysbus.c
+++ b/hw/core/sysbus.c
@@ -199,6 +199,7 @@ void sysbus_init_mmio(SysBusDevice *dev, MemoryRegion *memory)
MemoryRegion *sysbus_mmio_get_region(SysBusDevice *dev, int n)
{
+ assert(n >= 0 && n < QDEV_MAX_MMIO);
return dev->mmio[n].memory;
}
--
2.26.2
next prev parent reply other threads:[~2020-09-01 14:16 UTC|newest]
Thread overview: 45+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-01 14:09 [PULL 00/44] Trivial branch for 5.2 patches Laurent Vivier
2020-09-01 14:09 ` [PULL 01/44] hw/register: Document register_init_block @memory_size Laurent Vivier
2020-09-01 14:09 ` [PULL 02/44] target/arm/kvm: Remove superfluous break Laurent Vivier
2020-09-01 14:09 ` [PULL 03/44] target/ppc: Remove superfluous breaks Laurent Vivier
2020-09-01 14:09 ` [PULL 04/44] scsi: " Laurent Vivier
2020-09-01 14:09 ` [PULL 05/44] vnc: Remove the superfluous break Laurent Vivier
2020-09-01 14:09 ` [PULL 06/44] block/vmdk: Remove superfluous breaks Laurent Vivier
2020-09-01 14:09 ` [PULL 07/44] hw: " Laurent Vivier
2020-09-01 14:09 ` [PULL 08/44] target/sh4: " Laurent Vivier
2020-09-01 14:09 ` [PULL 09/44] target/cris: " Laurent Vivier
2020-09-01 14:09 ` [PULL 10/44] hw/net/can: Add missing fallthrough statements Laurent Vivier
2020-09-01 14:09 ` [PULL 11/44] hw/i386/kvm/ioapic.c: fix typo in error message Laurent Vivier
2020-09-01 14:09 ` [PULL 12/44] hw/isa/isa-superio: Fix IDE controller realization Laurent Vivier
2020-09-01 14:09 ` [PULL 13/44] stubs/cmos: Use correct include Laurent Vivier
2020-09-01 14:09 ` [PULL 14/44] qemu-options.hx: Fix typo for netdev documentation Laurent Vivier
2020-09-01 14:09 ` [PULL 15/44] hw/core/sysbus: Fix a typo Laurent Vivier
2020-09-01 14:09 ` Laurent Vivier [this message]
2020-09-01 14:09 ` [PULL 17/44] Revert "mailmap: Update philmd email address" Laurent Vivier
2020-09-01 14:09 ` [PULL 18/44] docs: Fix broken links Laurent Vivier
2020-09-01 14:09 ` [PULL 19/44] .mailmap: Update Paul Burton email address Laurent Vivier
2020-09-01 14:09 ` [PULL 20/44] hw/i2c: Fix typo in description Laurent Vivier
2020-09-01 14:09 ` [PULL 21/44] util/qemu-timer: " Laurent Vivier
2020-09-01 14:09 ` [PULL 22/44] util/vfio-helpers: " Laurent Vivier
2020-09-01 14:09 ` [PULL 23/44] mailmap: Add entry for Greg Kurz Laurent Vivier
2020-09-01 14:09 ` [PULL 24/44] docs/system/target-avr: Improve the AVR docs and add to MAINTAINERS Laurent Vivier
2020-09-01 14:09 ` [PULL 25/44] hw/ide/core: Trivial typo fix Laurent Vivier
2020-09-01 14:09 ` [PULL 26/44] hw/ide/ahci: Replace magic '512' value by BDRV_SECTOR_SIZE Laurent Vivier
2020-09-01 14:09 ` [PULL 27/44] hw/ide/atapi: " Laurent Vivier
2020-09-01 14:09 ` [PULL 28/44] hw/ide/pci: " Laurent Vivier
2020-09-01 14:09 ` [PULL 29/44] hw/scsi/scsi-disk: " Laurent Vivier
2020-09-01 14:09 ` [PULL 30/44] hw/net/xilinx_axienet: Remove unused code Laurent Vivier
2020-09-01 14:09 ` [PULL 31/44] util/vfio-helpers: Unify trace-events size format Laurent Vivier
2020-09-01 14:09 ` [PULL 32/44] linux-user: Add strace support for printing OFD fcntl operations Laurent Vivier
2020-09-01 14:09 ` [PULL 33/44] hw/arm/virt-acpi-build:Remove dead assignment in build_madt() Laurent Vivier
2020-09-01 14:09 ` [PULL 34/44] hw/arm/omap1:Remove redundant statement in omap_clkdsp_read() Laurent Vivier
2020-09-01 14:09 ` [PULL 35/44] target/arm/translate-a64:Remove dead assignment in handle_scalar_simd_shli() Laurent Vivier
2020-09-01 14:09 ` [PULL 36/44] target/arm/translate-a64:Remove redundant statement in disas_simd_two_reg_misc_fp16() Laurent Vivier
2020-09-01 14:09 ` [PULL 37/44] hw/virtio/vhost-user:Remove dead assignment in scrub_shadow_regions() Laurent Vivier
2020-09-01 14:09 ` [PULL 38/44] hw/net/virtio-net:Remove redundant statement in virtio_net_rsc_tcp_ctrl_check() Laurent Vivier
2020-09-01 14:09 ` [PULL 39/44] vfio/platform: Remove dead assignment in vfio_intp_interrupt() Laurent Vivier
2020-09-01 14:09 ` [PULL 40/44] usb/bus: Remove dead assignment in usb_get_fw_dev_path() Laurent Vivier
2020-09-01 14:09 ` [PULL 41/44] hw/intc: fix default registers value in exynos4210_combiner_read() Laurent Vivier
2020-09-01 14:09 ` [PULL 42/44] hw/display/vga:Remove redundant statement in vga_draw_graphic() Laurent Vivier
2020-09-01 14:09 ` [PULL 43/44] main-loop: Fix comment Laurent Vivier
2020-09-01 14:09 ` [PULL 44/44] docs/system: Fix grammar in documentation Laurent Vivier
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=20200901140954.889743-17-laurent@vivier.eu \
--to=laurent@vivier.eu \
--cc=f4bug@amsat.org \
--cc=qemu-devel@nongnu.org \
--cc=qemu-trivial@nongnu.org \
--cc=richard.henderson@linaro.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 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).