Skip to content

Commit

Permalink
softmmu: Assert data in bounds in iotlb_to_section
Browse files Browse the repository at this point in the history
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>
(cherry picked from commit 86e4f93)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
  • Loading branch information
rth7680 authored and Michael Tokarev committed Aug 30, 2023
1 parent 441106e commit 5691fbf
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions softmmu/physmem.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 5691fbf

Please sign in to comment.