Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752806AbcKCFjx (ORCPT ); Thu, 3 Nov 2016 01:39:53 -0400 Received: from mail-pf0-f195.google.com ([209.85.192.195]:33116 "EHLO mail-pf0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751512AbcKCFjv (ORCPT ); Thu, 3 Nov 2016 01:39:51 -0400 Date: Wed, 2 Nov 2016 22:39:48 -0700 From: Dmitry Torokhov To: Jakub Kicinski , "Eric W. Biederman" Cc: linux-kernel@vger.kernel.org, Kees Cook , Johannes Berg , Maciej =?utf-8?Q?=C5=BBenczykowski?= Subject: [PATCH] userns: suppress kmemleak message Message-ID: <20161103053948.GA40936@dtor-ws> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1823 Lines: 58 We do not ever intend to unregister "user" sysctl table, unfortunately it leads kmemleak to believe that we are leaking memory: unreferenced object 0xffff8807383bfd48 (size 96): comm "swapper/0", pid 1, jiffies 4294894636 (age 278.320s) hex dump (first 32 bytes): a0 b4 b0 ba ff ff ff ff 00 00 00 00 01 00 00 00 ................ 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ backtrace: [] kmemleak_alloc+0x28/0x50 [] __kmalloc+0x206/0x5a0 [] __register_sysctl_table+0xb3/0x1130 [] register_sysctl+0x1b/0x20 [] user_namespace_sysctl_init+0x17/0x4c [] do_one_initcall+0xb7/0x2a0 [] kernel_init_freeable+0x597/0x636 [] kernel_init+0x13/0x140 [] ret_from_fork+0x2a/0x40t show [] 0xffffffffffffffff Let's annotate the pointer as kmemleak_not_leak() to suppress the kmemleak false positive. Reported-by: Jakub Kicinski Signed-off-by: Dmitry Torokhov --- This was only compiled; Jakub, could you give it a spin? kernel/ucount.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/kernel/ucount.c b/kernel/ucount.c index 9d20d5d..07d69b2 100644 --- a/kernel/ucount.c +++ b/kernel/ucount.c @@ -5,6 +5,7 @@ * License. */ +#include #include #include #include @@ -226,6 +227,7 @@ static __init int user_namespace_sysctl_init(void) */ user_header = register_sysctl("user", empty); BUG_ON(!user_header); + kmemleak_not_leak(user_header); BUG_ON(!setup_userns_sysctls(&init_user_ns)); #endif return 0; -- 2.8.0.rc3.226.g39d4020 -- Dmitry