Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759880AbcLPJkU (ORCPT ); Fri, 16 Dec 2016 04:40:20 -0500 Received: from s3.sipsolutions.net ([5.9.151.49]:55346 "EHLO sipsolutions.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1759638AbcLPJkP (ORCPT ); Fri, 16 Dec 2016 04:40:15 -0500 Message-ID: <1481881178.27953.16.camel@sipsolutions.net> Subject: Re: [PATCH] userns: suppress kmemleak message From: Johannes Berg To: Fubo Chen , "Eric W. Biederman" Cc: Dmitry Torokhov , Jakub Kicinski , Linux Kernel , Kees Cook , Maciej =?UTF-8?Q?=C5=BBenczykowski?= Date: Fri, 16 Dec 2016 10:39:38 +0100 In-Reply-To: (sfid-20161215_131610_038741_C2E14B11) References: <20161103053948.GA40936@dtor-ws> <87a8dgvcke.fsf@xmission.com> (sfid-20161215_131610_038741_C2E14B11) Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.22.2-1 Mime-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1015 Lines: 21 > > I can't see the using kmemleak_not_leak is possibly good form.  I > > would much rather have suggestions about constructs that won't > > confuse kmemleak and won't need ugly annotations that serve no > > purpose but to appease a tool.  Perhaps the user_header variable > > needs to be moved out of user_namespace_sysctl_init. The user_header variable is probably (rightfully so) optimised away by the compiler since it can't ever be read. Therefore, it simply doesn't exist in the resulting binary (and it really shouldn't either) and the kmemleak_not_leak() really is the only way to resolve that, I'd say. > The only alternative I see is to use WRITE_ONCE() instead of "=" to > set "user_header" such that the compiler cannot optimize that > variable away. Which of these two approaches do you prefer? That seems really wrong - forcing the linker/compiler to retain a variable in the image that can never possibly be read (by anything other than kmemleak) is just a complete waste of space. johannes