Re: [PATCH] lkdtm: fix maybe-uninitialized warning

From: Arnd Bergmann
Date: Tue Jul 26 2016 - 16:58:42 EST


On Tuesday, July 26, 2016 8:21:37 AM CEST Kees Cook wrote:
> On Tue, Jul 26, 2016 at 5:28 AM, Arnd Bergmann <arnd@xxxxxxxx> wrote:
> > The do_usercopy_stack() function uses uninitialized stack data to initialize
> > more of the stack, which causes a warning in some configurations (ARM allmodconfig):
> >
> > drivers/misc/lkdtm_usercopy.c:52:15: warning: 'bad_stack' may be used uninitialized in this function [-Wmaybe-uninitialized]
> >
> > The warning gets reports by Mark Brown's build bot and looks correct (we are trying
> > to trick the compiler here, and sometimes the compiler notices), and I could reproduce
> > it with gcc-4.7 through gcc-5.3 but not gcc-6.1 for some reason.
> >
> > This changes the code to use the low byte of the address of the stack to initialize
> > the stack data, instead of using data from the stack itself, to avoid the warning.
> >
> > Signed-off-by: Arnd Bergmann <arnd@xxxxxxxx>
> > Fixes: a3dff71c1c88 ("lkdtm: split usercopy tests to separate file")
>
> Acked-by: Kees Cook <keescook@xxxxxxxxxxxx>
>
> I thought I already sent this fix to Greg?

Possible. I mentioned the problem to you when it first showed up,
but noticed today that I didn't have a patch for it in my testing
tree (since I test with gcc-6.1, which doesn't show the bug).

> Maybe it got lost...

More likely that it's still in his backlog then.

Arnd