[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH-for-5.2 2/2] hw/core/sysbus: Assert memory region index is in
From: |
Laurent Vivier |
Subject: |
Re: [PATCH-for-5.2 2/2] hw/core/sysbus: Assert memory region index is in range |
Date: |
Tue, 1 Sep 2020 09:28:35 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.11.0 |
Le 06/08/2020 à 15:09, Philippe Mathieu-Daudé a écrit :
> 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>
> ---
> hw/core/sysbus.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/hw/core/sysbus.c b/hw/core/sysbus.c
> index 77ab351ce1..294f90b7de 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;
> }
>
>
Applied to my trivial-patches branch.
Thanks,
Laurent
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Re: [PATCH-for-5.2 2/2] hw/core/sysbus: Assert memory region index is in range,
Laurent Vivier <=