Patch "x86/retpoline: Make sure there are no unconverted return thunks due to KCSAN" has been added to the 6.6-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

    x86/retpoline: Make sure there are no unconverted return thunks due to KCSAN

to the 6.6-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:
     x86-retpoline-make-sure-there-are-no-unconverted-ret.patch
and it can be found in the queue-6.6 subdirectory.

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



commit 24e9ab759f87ecf3f8887392d744e74954f0cc47
Author: Josh Poimboeuf <jpoimboe@xxxxxxxxxx>
Date:   Tue Oct 17 09:59:46 2023 -0700

    x86/retpoline: Make sure there are no unconverted return thunks due to KCSAN
    
    [ Upstream commit 2d7ce49f58dc95495b3e22e45d2be7de909b2c63 ]
    
    Enabling CONFIG_KCSAN leads to unconverted, default return thunks to
    remain after patching.
    
    As David Kaplan describes in his debugging of the issue, it is caused by
    a couple of KCSAN-generated constructors which aren't processed by
    objtool:
    
      "When KCSAN is enabled, GCC generates lots of constructor functions
      named _sub_I_00099_0 which call __tsan_init and then return.  The
      returns in these are generally annotated normally by objtool and fixed
      up at runtime.  But objtool runs on vmlinux.o and vmlinux.o does not
      include a couple of object files that are in vmlinux, like
      init/version-timestamp.o and .vmlinux.export.o, both of which contain
      _sub_I_00099_0 functions.  As a result, the returns in these functions
      are not annotated, and the panic occurs when we call one of them in
      do_ctors and it uses the default return thunk.
    
      This difference can be seen by counting the number of these functions in the object files:
      $ objdump -d vmlinux.o|grep -c "<_sub_I_00099_0>:"
      2601
      $ objdump -d vmlinux|grep -c "<_sub_I_00099_0>:"
      2603
    
      If these functions are only run during kernel boot, there is no
      speculation concern."
    
    Fix it by disabling KCSAN on version-timestamp.o and .vmlinux.export.o
    so the extra functions don't get generated.  KASAN and GCOV are already
    disabled for those files.
    
      [ bp: Massage commit message. ]
    
    Closes: https://lore.kernel.org/lkml/20231016214810.GA3942238@dev-arch.thelio-3990X/
    Reported-by: Nathan Chancellor <nathan@xxxxxxxxxx>
    Signed-off-by: Josh Poimboeuf <jpoimboe@xxxxxxxxxx>
    Signed-off-by: Borislav Petkov (AMD) <bp@xxxxxxxxx>
    Reviewed-by: Nick Desaulniers <ndesaulniers@xxxxxxxxxx>
    Acked-by: Marco Elver <elver@xxxxxxxxxx>
    Tested-by: Nathan Chancellor <nathan@xxxxxxxxxx>
    Link: https://lore.kernel.org/r/20231017165946.v4i2d4exyqwqq3bx@treble
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/init/Makefile b/init/Makefile
index ec557ada3c12e..cbac576c57d63 100644
--- a/init/Makefile
+++ b/init/Makefile
@@ -60,4 +60,5 @@ include/generated/utsversion.h: FORCE
 $(obj)/version-timestamp.o: include/generated/utsversion.h
 CFLAGS_version-timestamp.o := -include include/generated/utsversion.h
 KASAN_SANITIZE_version-timestamp.o := n
+KCSAN_SANITIZE_version-timestamp.o := n
 GCOV_PROFILE_version-timestamp.o := n
diff --git a/scripts/Makefile.vmlinux b/scripts/Makefile.vmlinux
index 3cd6ca15f390d..c9f3e03124d7f 100644
--- a/scripts/Makefile.vmlinux
+++ b/scripts/Makefile.vmlinux
@@ -19,6 +19,7 @@ quiet_cmd_cc_o_c = CC      $@
 
 ifdef CONFIG_MODULES
 KASAN_SANITIZE_.vmlinux.export.o := n
+KCSAN_SANITIZE_.vmlinux.export.o := n
 GCOV_PROFILE_.vmlinux.export.o := n
 targets += .vmlinux.export.o
 vmlinux: .vmlinux.export.o



[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