Commit | Line | Data |
---|---|---|
473c84d1 AT |
1 | // SPDX-License-Identifier: GPL-2.0-or-later |
2 | /* | |
3 | * Module kmemleak support | |
4 | * | |
5 | * Copyright (C) 2009 Catalin Marinas | |
6 | */ | |
7 | ||
8 | #include <linux/module.h> | |
9 | #include <linux/kmemleak.h> | |
10 | #include "internal.h" | |
11 | ||
12 | void kmemleak_load_module(const struct module *mod, | |
13 | const struct load_info *info) | |
14 | { | |
15 | unsigned int i; | |
16 | ||
17 | /* only scan the sections containing data */ | |
18 | kmemleak_scan_area(mod, sizeof(struct module), GFP_KERNEL); | |
19 | ||
20 | for (i = 1; i < info->hdr->e_shnum; i++) { | |
21 | /* Scan all writable sections that's not executable */ | |
22 | if (!(info->sechdrs[i].sh_flags & SHF_ALLOC) || | |
23 | !(info->sechdrs[i].sh_flags & SHF_WRITE) || | |
24 | (info->sechdrs[i].sh_flags & SHF_EXECINSTR)) | |
25 | continue; | |
26 | ||
27 | kmemleak_scan_area((void *)info->sechdrs[i].sh_addr, | |
28 | info->sechdrs[i].sh_size, GFP_KERNEL); | |
29 | } | |
30 | } |