aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2013-05-18 13:21:32 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2013-05-18 13:21:32 -0400
commit8f05bde9bd6da80365495369738ab869c1f8bcac (patch)
tree926ed74048ae5554c8c959143307fa836a337db3
parentf71df63380cc9367c4a866d4cf9a2b0cfe352ad6 (diff)
parent89c837351db0b9b52fd572ec8b0445a42e59b75c (diff)
Merge tag 'kmemleak-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/cmarinas/linux-aarch64
Pull kmemleak patches from Catalin Marinas: "Kmemleak now scans all the writable and non-executable module sections to avoid false positives (previously it was only scanning specific sections and missing .ref.data)." * tag 'kmemleak-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/cmarinas/linux-aarch64: kmemleak: No need for scanning specific module sections kmemleak: Scan all allocated, writeable and not executable module sections
-rw-r--r--kernel/module.c21
1 files changed, 4 insertions, 17 deletions
diff --git a/kernel/module.c b/kernel/module.c
index b049939177f6..cab4bce49c23 100644
--- a/kernel/module.c
+++ b/kernel/module.c
@@ -2431,10 +2431,10 @@ static void kmemleak_load_module(const struct module *mod,
2431 kmemleak_scan_area(mod, sizeof(struct module), GFP_KERNEL); 2431 kmemleak_scan_area(mod, sizeof(struct module), GFP_KERNEL);
2432 2432
2433 for (i = 1; i < info->hdr->e_shnum; i++) { 2433 for (i = 1; i < info->hdr->e_shnum; i++) {
2434 const char *name = info->secstrings + info->sechdrs[i].sh_name; 2434 /* Scan all writable sections that's not executable */
2435 if (!(info->sechdrs[i].sh_flags & SHF_ALLOC)) 2435 if (!(info->sechdrs[i].sh_flags & SHF_ALLOC) ||
2436 continue; 2436 !(info->sechdrs[i].sh_flags & SHF_WRITE) ||
2437 if (!strstarts(name, ".data") && !strstarts(name, ".bss")) 2437 (info->sechdrs[i].sh_flags & SHF_EXECINSTR))
2438 continue; 2438 continue;
2439 2439
2440 kmemleak_scan_area((void *)info->sechdrs[i].sh_addr, 2440 kmemleak_scan_area((void *)info->sechdrs[i].sh_addr,
@@ -2769,24 +2769,11 @@ static void find_module_sections(struct module *mod, struct load_info *info)
2769 mod->trace_events = section_objs(info, "_ftrace_events", 2769 mod->trace_events = section_objs(info, "_ftrace_events",
2770 sizeof(*mod->trace_events), 2770 sizeof(*mod->trace_events),
2771 &mod->num_trace_events); 2771 &mod->num_trace_events);
2772 /*
2773 * This section contains pointers to allocated objects in the trace
2774 * code and not scanning it leads to false positives.
2775 */
2776 kmemleak_scan_area(mod->trace_events, sizeof(*mod->trace_events) *
2777 mod->num_trace_events, GFP_KERNEL);
2778#endif 2772#endif
2779#ifdef CONFIG_TRACING 2773#ifdef CONFIG_TRACING
2780 mod->trace_bprintk_fmt_start = section_objs(info, "__trace_printk_fmt", 2774 mod->trace_bprintk_fmt_start = section_objs(info, "__trace_printk_fmt",
2781 sizeof(*mod->trace_bprintk_fmt_start), 2775 sizeof(*mod->trace_bprintk_fmt_start),
2782 &mod->num_trace_bprintk_fmt); 2776 &mod->num_trace_bprintk_fmt);
2783 /*
2784 * This section contains pointers to allocated objects in the trace
2785 * code and not scanning it leads to false positives.
2786 */
2787 kmemleak_scan_area(mod->trace_bprintk_fmt_start,
2788 sizeof(*mod->trace_bprintk_fmt_start) *
2789 mod->num_trace_bprintk_fmt, GFP_KERNEL);
2790#endif 2777#endif
2791#ifdef CONFIG_FTRACE_MCOUNT_RECORD 2778#ifdef CONFIG_FTRACE_MCOUNT_RECORD
2792 /* sechdrs[0].sh_size is always zero */ 2779 /* sechdrs[0].sh_size is always zero */