Patch "lib: stackinit: hide never-taken branch from compiler" has been added to the 5.15-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    lib: stackinit: hide never-taken branch from compiler

to the 5.15-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     lib-stackinit-hide-never-taken-branch-from-compiler.patch
and it can be found in the queue-5.15 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit 26a524f5bd8f3ad36ca412ec745c9b541fc5aeae
Author: Kees Cook <kees@xxxxxxxxxx>
Date:   Sun Nov 17 03:38:13 2024 -0800

    lib: stackinit: hide never-taken branch from compiler
    
    [ Upstream commit 5c3793604f91123bf49bc792ce697a0bef4c173c ]
    
    The never-taken branch leads to an invalid bounds condition, which is by
    design. To avoid the unwanted warning from the compiler, hide the
    variable from the optimizer.
    
    ../lib/stackinit_kunit.c: In function 'do_nothing_u16_zero':
    ../lib/stackinit_kunit.c:51:49: error: array subscript 1 is outside array bounds of 'u16[0]' {aka 'short unsigned int[]'} [-Werror=array-bounds=]
       51 | #define DO_NOTHING_RETURN_SCALAR(ptr)           *(ptr)
          |                                                 ^~~~~~
    ../lib/stackinit_kunit.c:219:24: note: in expansion of macro 'DO_NOTHING_RETURN_SCALAR'
      219 |                 return DO_NOTHING_RETURN_ ## which(ptr + 1);    \
          |                        ^~~~~~~~~~~~~~~~~~
    
    Link: https://lkml.kernel.org/r/20241117113813.work.735-kees@xxxxxxxxxx
    Signed-off-by: Kees Cook <kees@xxxxxxxxxx>
    Cc: <stable@xxxxxxxxxxxxxxx>
    Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/lib/test_stackinit.c b/lib/test_stackinit.c
index a3c74e6a21ff..56653c6a2a61 100644
--- a/lib/test_stackinit.c
+++ b/lib/test_stackinit.c
@@ -259,6 +259,7 @@ static noinline __init int test_ ## name (void)			\
 static noinline __init DO_NOTHING_TYPE_ ## which(var_type)	\
 do_nothing_ ## name(var_type *ptr)				\
 {								\
+	OPTIMIZER_HIDE_VAR(ptr);				\
 	/* Will always be true, but compiler doesn't know. */	\
 	if ((unsigned long)ptr > 0x2)				\
 		return DO_NOTHING_RETURN_ ## which(ptr);	\




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux