lkml.org 
[lkml]   [2017]   [Mar]   [29]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH v2] module: check if memory leak by module.
From
Date
On 03/29/2017 09:02 AM, Maninder Singh wrote:

> diff --git a/kernel/module.c b/kernel/module.c
> index f953df9..98a8018 100644
> --- a/kernel/module.c
> +++ b/kernel/module.c
> @@ -2117,9 +2117,31 @@ void __weak module_arch_freeing_init(struct module *mod)
> {
> }
>
> +static void check_memory_leak(struct module *mod)
> +{
> + struct vmap_area *va;
> +
> + rcu_read_lock();
> + list_for_each_entry_rcu(va, &vmap_area_list, list) {

vmap_area_list is protected by spin_lock(&vmap_area_lock); not the RCU.

Also some other points:
1) kmemleak already detects leaks of that kind.

2) All this could be implemented in userspace, e.g. in rmmod tool
- Read /proc/vmalloc and find areas belonging to the module
- unload module
- read /proc/vmalloc and check if anything left from that module

3) This might produce false positives. E.g. module may defer vfree() in workqueue, so the
actual vfree() call happens after module unloaded.

\
 
 \ /
  Last update: 2017-03-29 13:06    [W:0.120 / U:0.080 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site