lkdtm: fix maybe-uninitialized warning
Arnd Bergmann
maintainerPATCH 1/1 lkdtm: fix maybe-uninitialized warning
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.
--- drivers/misc/lkdtm_usercopy.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/misc/lkdtm_usercopy.c +1 -1
@@ -49,7 +49,7 @@ static noinline void do_usercopy_stack(bool to_user, bool bad_frame)/* This is a pointer to outside our current stack frame. */ if (bad_frame) { - bad_stack =do_usercopy_stack_callee ((uintptr_t )bad_stack); + bad_stack =do_usercopy_stack_callee ((uintptr_t )&bad_stack); }else {/* Put start address just inside stack. */ bad_stack =task_stack_page (current) +THREAD_SIZE ;
Signature · 1 line
2.9.0
Quoted 9 lines · Arnd Bergmann
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.
Quoted 5 lines
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 <[email protected]>Fixes a3dff71c1c88 ("lkdtm: split usercopy tests to separate file")
I thought I already sent this fix to Greg? Maybe it got lost...
-Kees
Quoted 20 lines
--- drivers/misc/lkdtm_usercopy.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/misc/lkdtm_usercopy.c +1
-2@@ -49,7 +49,7 @@ static noinline void do_usercopy_stack(bool to_user, bool bad_frame)/* This is a pointer to outside our current stack frame. */ if (bad_frame) { - bad_stack =do_usercopy_stack_callee ((uintptr_t )bad_stack); + bad_stack =do_usercopy_stack_callee ((uintptr_t )&bad_stack); }else {/* Put start address just inside stack. */ bad_stack =task_stack_page (current) +THREAD_SIZE ; --2.9.0
Signature · 2 lines
Kees Cook Chrome OS & Brillo Security
Arnd Bergmann
maintainerQuoted 13 lines · CEST Kees Cook
Quoted 12 lines · Arnd Bergmann
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.
Quoted 6 lines
Quoted 2 lines
Signed-off-by Arnd Bergmann <[email protected]>Fixes a3dff71c1c88 ("lkdtm: split usercopy tests to separate file")Acked-by Kees Cook <[email protected]>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).
Quoted 1 line
Maybe it got lost...
More likely that it's still in his backlog then.
Arnd