Re: [PATCH] userns: suppress kmemleak message

From: Fubo Chen
Date: Thu Dec 15 2016 - 07:16:35 EST


On Thu, Nov 3, 2016 at 3:54 PM, Eric W. Biederman <ebiederm@xxxxxxxxxxxx> wrote:
> Dmitry Torokhov <dmitry.torokhov@xxxxxxxxx> writes:
>
>> We do not ever intend to unregister "user" sysctl table, unfortunately
>> it leads kmemleak to believe that we are leaking memory:
>
> Sounds like an issue with kmemleak because we do retain references.
>
> So no we don't intend to unregister the table.
>
> As for the patch.
>
> Nacked-by: "Eric W. Biederman" <ebiederm@xxxxxxxxxxxx>
>
> 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 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?

Fubo.