Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932587AbdC2LFp (ORCPT ); Wed, 29 Mar 2017 07:05:45 -0400 Received: from mail-ve1eur01on0118.outbound.protection.outlook.com ([104.47.1.118]:64263 "EHLO EUR01-VE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1754184AbdC2LEs (ORCPT ); Wed, 29 Mar 2017 07:04:48 -0400 Authentication-Results: samsung.com; dkim=none (message not signed) header.d=none;samsung.com; dmarc=none action=none header.from=virtuozzo.com; Subject: Re: [PATCH v2] module: check if memory leak by module. To: Maninder Singh , , , , , , , , , , , , , , , , , , , References: <1490767322-9914-1-git-send-email-maninder1.s@samsung.com> CC: , , , , , , Vaneet Narang From: Andrey Ryabinin Message-ID: <460c5798-1f4d-6fd0-cf32-349fbd605862@virtuozzo.com> Date: Wed, 29 Mar 2017 14:05:39 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.7.0 MIME-Version: 1.0 In-Reply-To: <1490767322-9914-1-git-send-email-maninder1.s@samsung.com> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Originating-IP: [195.214.232.6] X-ClientProxiedBy: DB6PR1001CA0026.EURPRD10.PROD.OUTLOOK.COM (10.168.69.140) To HE1PR0801MB2058.eurprd08.prod.outlook.com (10.168.95.23) X-MS-Office365-Filtering-Correlation-Id: 2f7848b2-e6a0-4750-eac2-08d476935a72 X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001)(201703131423075)(201703031133081);SRVR:HE1PR0801MB2058; X-Microsoft-Exchange-Diagnostics: 1;HE1PR0801MB2058;3:V8U56n2bageS50BQ8A9W0phMZKTFYluNOVXCHVu3k26l5LpKI+cq7IRvyWtcn3KlN+FH23xKUWnnVEnPY3xrT20aNbKgSshWFLCopM9jqOnBaxargtbtZA84gUZ1SA/tvxLcHNFqaZTM70rxaCY3E8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Hpfn5vnWFGtVTHKyy5Xk0Kwc9jtrSTXPvX/zNK3iLto+/RsXoPy3hbSH4cOoPpPqX/FWY8odovMzuWV+4mM+7vx6AdFbaq/1+tsQ+RQ9e7D2IpfSVHc+IMiTfgQc854zpkeve6N0oCIy1RPna15abMwNIhvWGSMVBOB/x/IJGASTBe1D6Op84V0QC5PJfTRFsjRe6FjaTWWzKKnJR65B7c35OiW1x/ZSd9mCIf9fSbkXraOA+YV4Zf3zwCilbi8eEFabtGEj3tAhDkeN6cTzkFXwPpdn3hTEcCatBO2blWaGVCfZ+ix2GtLU4kw09YhQlqOlvYMqJVo8yDiw54WKAh4= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(6040450)(601004)(2401047)(5005006)(8121501046)(3002001)(10201501046)(6041248)(20161123564025)(20161123558025)(20161123555025)(20161123560025)(201703131423075)(201702281528075)(201703061421075)(201703061406075)(20161123562025)(6072148);SRVR:HE1PR0801MB2058;BCL:0;PCL:0;RULEID:;SRVR:HE1PR0801MB2058; X-Microsoft-Exchange-Diagnostics: 1;HE1PR0801MB2058;4:0RODWCIhilkSGHNXzrUEGB4f3uiOomkwKVJEEWHVrhGxntkw7aRpALtI9pJlWFL5VEt66WXCsLGnaNSemwlsnvVroPw2aszhTN4jMW2xeDxmpPTpKEOeTjkV4+NGIeWAXBsUglDdJCHeFwbPGt3Cpz+LwNzqzd5K94l6wkI2mzgKNQpzg6fXKYmt/23Rk4jNr6tuxT1fJNSpwnuMDWbBDOqZCYJJRcpsZgyXfAOURb9Qjg2PpnCi9VmjNliiuMacXpoTO6Iu6kRuro751h3M0l13biuyB+TQ08/wt7BsoGdS1hLGzTCXBLYV4r1vSopUXnEH10Cl7CHiGGXHajR3kVFIZUDiIN38hkUUPd4K7tN+CMsMSFu06PbT5xArS2UcViaVtrWy/O2CbOonOo3OVin80nnSgA/5gBFeQpJ/oL0MFGRK+fZFNfL39nur5Ka0D9WK+9dMHad118sGSmReuZ8EK0yv4UKh2lm6i04KQA3BZ/uyWzubkJ/njrDQJPY0eDPO1yWLS3WkueMHVUgLQXRyNTFirx5OLpSYIsHSjHq9xk+icJ2tpAG3Vwyk63vU0Rtu+MY6H2+QV3Nw0bY8kKnrB52zjR8pK5tGpCdrThdbnDHg6xRMyLJ4ezkJrmY6vJFm+q/bd5laGB3iKhqcs2BH7vXp5i5CBvtcNIkyFeDBRZadlvBUsLidH197mVGyR9FY9OCEN+4tv5zsAxiE8zSSwEspXDnmwfhz3yBn263YWxWoHU3wz2HW4drg15vv X-Forefront-PRVS: 0261CCEEDF X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10019020)(4630300001)(6009001)(6049001)(39830400002)(39410400002)(39450400003)(39400400002)(377454003)(24454002)(305945005)(2201001)(7736002)(90366009)(50466002)(36756003)(86362001)(38730400002)(230700001)(6486002)(77096006)(6246003)(31696002)(189998001)(54906002)(4001350100001)(81166006)(42186005)(229853002)(2950100002)(8676002)(6666003)(23676002)(53936002)(7416002)(53546009)(66066001)(5660300001)(83506001)(54356999)(76176999)(50986999)(1511001)(8666007)(33646002)(65956001)(4326008)(6116002)(2421001)(3846002)(25786009)(2906002)(47776003)(921003)(2101003)(1121003);DIR:OUT;SFP:1102;SCL:1;SRVR:HE1PR0801MB2058;H:[172.16.25.12];FPR:;SPF:None;MLV:sfv;LANG:en; X-Microsoft-Exchange-Diagnostics: =?utf-8?B?MTtIRTFQUjA4MDFNQjIwNTg7MjM6UWxndlpDcjRMcmNOa3VyUnA3Ynd5RjlQ?= =?utf-8?B?d2gvdEpyL04xOXdsVzd4ajFUbFNKWDBjWFIzWU9ZZUgrVlRzMnRZWHZqTE4r?= =?utf-8?B?dVAwZktneEwrYVZCRzBJV0Ixd1BGUUJObjhWcFFpMHplUGFISC9ybXIyOVNq?= =?utf-8?B?aXIrYStVczFkV0l3bDNVZzlaMFpvOEZqMml2dTY1cHJXMUhkOUZUMHIveHU3?= =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pSQtMIg7S1L3jnzYMOhNL3r+anAqQd12aOWZsrYjYxNbOJXgK8HSVKnZx2JqTMEyNTVZzBFsKYjzAj+wi2sVa2e0FycNUhaJ0/MNogjCHjaM7OV5QW6fbnwN6KsRkjy6zaO3xf5Gge2VZDnu8oQ==;5:NnUaka+WR8Yw8JH8/WOasT8rzwi58aYEGeBNwNzSecEtCsq+ZeaS2T50YhbR0vMdBcuDUTRwD+0VB2A8jVB3MOS7iEzDuSpn7FbXHzeEiI9lfAGZ1t+zdQSuTpfYoOuL1MqDCI3VGsvRRSxd5j3RHA==;24:SQ/SjjlE/k5gQTCU33PzJ3Ufhfo2HHYKK6py77RXxMhWOuYMj1ryWf1qh4IZdKnJ8lDQzA2YdVq/dxJs+jNgPWkz6JZA4nehAtuS7QPgfeU= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;HE1PR0801MB2058;7:5vS6GYPORd6s4NpNFNhGP1RXD8Os1ZXZcVkS6qz1gtyVwgk2SnwGl9Djldk45KaY0sp88uQsi7vlZtQd0HAgXwMEtc6gXrEjki4TryAQD6Q9W8NU5kuqBxQjPkLncCau2OAckd61gqW41s9k3jkgItGQVH9hampQAOwn3KOiN6i4fjaL6umjSLlw/5aSwhP6hCKoHvCyn3oYBCXTwWjOSn0qgplCNwZY4sUZeOfLe0En5apfZ7ieFPhUTxyDP1UhW1Y3kCRdt28ptRN32D/krJfJPwiUTMrud4Ik9IwF7rLpT5YToasHJ9SasEFQyipSEbRCNusYU+DUl4OG7Ic6Cg==;20:JmC8M4mno3HrEQM0XkFZObgjVqLzPx8HMp2qAaLHHdUpKrpfReLJojlHZftGiTWOx4WZ4y1VdMVIOqN0wPsC0asVzG1mgdltzfSW4XUTx/mHn5R7pSMey0R85F/XtpG/w1tXJ8rPj7QKmMjVdzNTZHX01d5lK9WurG49fPtiPBY= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Mar 2017 11:04:18.3185 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: HE1PR0801MB2058 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 961 Lines: 29 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.