[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <460c5798-1f4d-6fd0-cf32-349fbd605862@virtuozzo.com>
Date: Wed, 29 Mar 2017 14:05:39 +0300
From: Andrey Ryabinin <aryabinin@...tuozzo.com>
To: Maninder Singh <maninder1.s@...sung.com>, <jeyu@...hat.com>,
<rusty@...tcorp.com.au>, <akpm@...ux-foundation.org>,
<chris@...is-wilson.co.uk>, <joonas.lahtinen@...ux.intel.com>,
<mhocko@...e.com>, <keescook@...omium.org>, <pavel@....cz>,
<jinb.park7@...il.com>, <anisse@...ier.eu>,
<rafael.j.wysocki@...el.com>, <zijun_hu@....com>,
<mingo@...nel.org>, <mawilcox@...rosoft.com>,
<thgarnie@...gle.com>, <joelaf@...gle.com>,
<kirill.shutemov@...ux.intel.com>, <linux-mm@...ck.org>,
<linux-kernel@...r.kernel.org>
CC: <pankaj.m@...sung.com>, <ajeet.y@...sung.com>,
<hakbong5.lee@...sung.com>, <a.sahrawat@...sung.com>,
<lalit.mohan@...sung.com>, <cpgs@...sung.com>,
Vaneet Narang <v.narang@...sung.com>
Subject: Re: [PATCH v2] module: check if memory leak by module.
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.
Powered by blists - more mailing lists