]> git.proxmox.com Git - mirror_qemu.git/commitdiff
softmmu: Assert data in bounds in iotlb_to_section
authorRichard Henderson <richard.henderson@linaro.org>
Fri, 25 Aug 2023 21:06:58 +0000 (14:06 -0700)
committerRichard Henderson <richard.henderson@linaro.org>
Tue, 29 Aug 2023 16:55:06 +0000 (09:55 -0700)
Acked-by: Alex Bennée <alex.bennee@linaro.org>
Suggested-by: Alex Bennée <alex.bennee@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
softmmu/physmem.c

index 3df73542e1fee1fa70d64ccacbe9ad27e6ab9d34..7597dc1c39a42102e207933f818ac62aefb9923d 100644 (file)
@@ -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 &sections[index & ~TARGET_PAGE_MASK];
+    return ret;
 }
 
 static void io_mem_init(void)