From: Richard Henderson Date: Fri, 25 Aug 2023 21:06:58 +0000 (-0700) Subject: softmmu: Assert data in bounds in iotlb_to_section X-Git-Tag: v8.2.0-rc0~153^2~4 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=86e4f93d827d3c1efd00cd8a906e38a2c0f2b5bc;p=thirdparty%2Fqemu.git softmmu: Assert data in bounds in iotlb_to_section Acked-by: Alex Bennée Suggested-by: Alex Bennée Signed-off-by: Richard Henderson --- diff --git a/softmmu/physmem.c b/softmmu/physmem.c index 3df73542e1f..7597dc1c39a 100644 --- a/softmmu/physmem.c +++ b/softmmu/physmem.c @@ -2413,9 +2413,15 @@ MemoryRegionSection *iotlb_to_section(CPUState *cpu, int asidx = cpu_asidx_from_attrs(cpu, attrs); CPUAddressSpace *cpuas = &cpu->cpu_ases[asidx]; AddressSpaceDispatch *d = qatomic_rcu_read(&cpuas->memory_dispatch); - MemoryRegionSection *sections = d->map.sections; + int section_index = index & ~TARGET_PAGE_MASK; + MemoryRegionSection *ret; + + assert(section_index < d->map.sections_nb); + ret = d->map.sections + section_index; + assert(ret->mr); + assert(ret->mr->ops); - return §ions[index & ~TARGET_PAGE_MASK]; + return ret; } static void io_mem_init(void)