Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1760888AbcLPNxG (ORCPT ); Fri, 16 Dec 2016 08:53:06 -0500 Received: from mail-yb0-f193.google.com ([209.85.213.193]:35694 "EHLO mail-yb0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755619AbcLPNw7 (ORCPT ); Fri, 16 Dec 2016 08:52:59 -0500 MIME-Version: 1.0 In-Reply-To: <1481881178.27953.16.camel@sipsolutions.net> References: <20161103053948.GA40936@dtor-ws> <87a8dgvcke.fsf@xmission.com> <1481881178.27953.16.camel@sipsolutions.net> From: Fubo Chen Date: Fri, 16 Dec 2016 14:52:58 +0100 Message-ID: Subject: Re: [PATCH] userns: suppress kmemleak message To: Johannes Berg Cc: "Eric W. Biederman" , Dmitry Torokhov , Jakub Kicinski , Linux Kernel , Kees Cook , =?UTF-8?Q?Maciej_=C5=BBenczykowski?= Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1181 Lines: 25 On Fri, Dec 16, 2016 at 10:39 AM, Johannes Berg wrote: > >> > 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. Does this reply count as a Reviewed-by for the original patch? Fubo.