Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0-or-later
0002 /*
0003  * Module kmemleak support
0004  *
0005  * Copyright (C) 2009 Catalin Marinas
0006  */
0007 
0008 #include <linux/module.h>
0009 #include <linux/kmemleak.h>
0010 #include "internal.h"
0011 
0012 void kmemleak_load_module(const struct module *mod,
0013               const struct load_info *info)
0014 {
0015     unsigned int i;
0016 
0017     /* only scan the sections containing data */
0018     kmemleak_scan_area(mod, sizeof(struct module), GFP_KERNEL);
0019 
0020     for (i = 1; i < info->hdr->e_shnum; i++) {
0021         /* Scan all writable sections that's not executable */
0022         if (!(info->sechdrs[i].sh_flags & SHF_ALLOC) ||
0023             !(info->sechdrs[i].sh_flags & SHF_WRITE) ||
0024             (info->sechdrs[i].sh_flags & SHF_EXECINSTR))
0025             continue;
0026 
0027         kmemleak_scan_area((void *)info->sechdrs[i].sh_addr,
0028                    info->sechdrs[i].sh_size, GFP_KERNEL);
0029     }
0030 }