kmemleak: Scan all allocated, writeable and not executable module sections
Instead of just picking data sections by name (names that start with .data, .bss or .ref.data), use the section flags and scan all sections that are allocated, writable and not executable. Which should cover all sections of a module that might reference data. Signed-off-by: Steven Rostedt <rostedt@goodmis.org> [catalin.marinas@arm.com: removed unused 'name' variable] [catalin.marinas@arm.com: collapsed 'if' blocks] Signed-off-by: Catalin Marinas <catalin.marinas@arm.com> Acked-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
parent
f722406faa
commit
06c9494c0e
|
@ -2431,10 +2431,10 @@ static void kmemleak_load_module(const struct module *mod,
|
||||||
kmemleak_scan_area(mod, sizeof(struct module), GFP_KERNEL);
|
kmemleak_scan_area(mod, sizeof(struct module), GFP_KERNEL);
|
||||||
|
|
||||||
for (i = 1; i < info->hdr->e_shnum; i++) {
|
for (i = 1; i < info->hdr->e_shnum; i++) {
|
||||||
const char *name = info->secstrings + info->sechdrs[i].sh_name;
|
/* Scan all writable sections that's not executable */
|
||||||
if (!(info->sechdrs[i].sh_flags & SHF_ALLOC))
|
if (!(info->sechdrs[i].sh_flags & SHF_ALLOC) ||
|
||||||
continue;
|
!(info->sechdrs[i].sh_flags & SHF_WRITE) ||
|
||||||
if (!strstarts(name, ".data") && !strstarts(name, ".bss"))
|
(info->sechdrs[i].sh_flags & SHF_EXECINSTR))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
kmemleak_scan_area((void *)info->sechdrs[i].sh_addr,
|
kmemleak_scan_area((void *)info->sechdrs[i].sh_addr,
|
||||||
|
|
Loading…
Reference in New Issue