mirror of
https://github.com/nxp-imx/linux-imx.git
synced 2025-07-06 17:35:20 +02:00
ANDROID: KVM: arm64: Fix kmemleak for pKVM modules
The kernel module loader allocates a vmalloc region per type of memory
where hypervisor sections are copied, according to their ELF type. This
means those sections can be distributed over several vmalloc regions and
by definition over several kmemleak objects.
kmemleak_free_part() can only access a single kmemleak object even
though the size is bigger than that object. Also, this function is
intended to be used solely in early boot for memblocks.
Ideally we would just remove the pKVM sections from kmemleak objects,
but we have no way to remove those sections from the list of scanned
areas (or to even know if areas have been created). So it is safer to
disable kmemleak scan completely.
Bug: 278749606
Bug: 244543039
Bug: 244373730
Bug: 359429030
Fixes: be027b1920
("ANDROID: KVM: arm64: Allow loading modules to the pKVM hypervisor")
Change-Id: I0c25bf6211c5e653f52777917025c64bab778abe
Signed-off-by: Vincent Donnefort <vdonnefort@google.com>
This commit is contained in:
parent
73613a1daf
commit
f67656b74b
|
@ -972,18 +972,23 @@ int __pkvm_load_el2_module(struct module *this, unsigned long *token)
|
|||
endrel = (void *)mod->relocs + mod->nr_relocs * sizeof(*endrel);
|
||||
kvm_apply_hyp_module_relocations(start, hyp_va, mod->relocs, endrel);
|
||||
|
||||
/*
|
||||
* Exclude EL2 module sections from kmemleak before making them
|
||||
* inaccessible.
|
||||
*/
|
||||
kmemleak_free_part(start, size);
|
||||
|
||||
ret = hyp_trace_init_mod_events(mod->hyp_events,
|
||||
mod->event_ids.start,
|
||||
mod->nr_hyp_events);
|
||||
if (ret)
|
||||
kvm_err("Failed to init module events: %d\n", ret);
|
||||
|
||||
/*
|
||||
* Sadly we have also to disable kmemleak for EL1 sections: we can't
|
||||
* reset created scan area and therefore we can't create a finer grain
|
||||
* scan excluding only EL2 sections.
|
||||
*/
|
||||
if (this) {
|
||||
kmemleak_no_scan(this->mem[MOD_TEXT].base);
|
||||
kmemleak_no_scan(this->mem[MOD_DATA].base);
|
||||
kmemleak_no_scan(this->mem[MOD_RODATA].base);
|
||||
}
|
||||
|
||||
ret = pkvm_map_module_sections(secs_map + secs_first, hyp_va,
|
||||
ARRAY_SIZE(secs_map) - secs_first);
|
||||
if (ret) {
|
||||
|
|
Loading…
Reference in New Issue
Block a user