Patch "x86/traps: move kmsan check after instrumentation_begin" has been added to the 6.11-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/traps: move kmsan check after instrumentation_begin

to the 6.11-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-traps-move-kmsan-check-after-instrumentation_beg.patch
and it can be found in the queue-6.11 subdirectory.

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



commit 2831a9462bb651fdd49c33fc8be9e64c2dc7212a
Author: Sabyrzhan Tasbolatov <snovitoll@xxxxxxxxx>
Date:   Wed Oct 16 20:24:07 2024 +0500

    x86/traps: move kmsan check after instrumentation_begin
    
    [ Upstream commit 1db272864ff250b5e607283eaec819e1186c8e26 ]
    
    During x86_64 kernel build with CONFIG_KMSAN, the objtool warns following:
    
      AR      built-in.a
      AR      vmlinux.a
      LD      vmlinux.o
    vmlinux.o: warning: objtool: handle_bug+0x4: call to
        kmsan_unpoison_entry_regs() leaves .noinstr.text section
      OBJCOPY modules.builtin.modinfo
      GEN     modules.builtin
      MODPOST Module.symvers
      CC      .vmlinux.export.o
    
    Moving kmsan_unpoison_entry_regs() _after_ instrumentation_begin() fixes
    the warning.
    
    There is decode_bug(regs->ip, &imm) is left before KMSAN unpoisoining, but
    it has the return condition and if we include it after
    instrumentation_begin() it results the warning "return with
    instrumentation enabled", hence, I'm concerned that regs will not be KMSAN
    unpoisoned if `ud_type == BUG_NONE` is true.
    
    Link: https://lkml.kernel.org/r/20241016152407.3149001-1-snovitoll@xxxxxxxxx
    Fixes: ba54d194f8da ("x86/traps: avoid KMSAN bugs originating from handle_bug()")
    Signed-off-by: Sabyrzhan Tasbolatov <snovitoll@xxxxxxxxx>
    Reviewed-by: Alexander Potapenko <glider@xxxxxxxxxx>
    Cc: Borislav Petkov (AMD) <bp@xxxxxxxxx>
    Cc: Dave Hansen <dave.hansen@xxxxxxxxxxxxxxx>
    Cc: Ingo Molnar <mingo@xxxxxxxxxx>
    Cc: Thomas Gleixner <tglx@xxxxxxxxxxxxx>
    Cc: <stable@xxxxxxxxxxxxxxx>
    Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/arch/x86/kernel/traps.c b/arch/x86/kernel/traps.c
index 415881607c5df..29ec49209ae01 100644
--- a/arch/x86/kernel/traps.c
+++ b/arch/x86/kernel/traps.c
@@ -261,12 +261,6 @@ static noinstr bool handle_bug(struct pt_regs *regs)
 	int ud_type;
 	u32 imm;
 
-	/*
-	 * Normally @regs are unpoisoned by irqentry_enter(), but handle_bug()
-	 * is a rare case that uses @regs without passing them to
-	 * irqentry_enter().
-	 */
-	kmsan_unpoison_entry_regs(regs);
 	ud_type = decode_bug(regs->ip, &imm);
 	if (ud_type == BUG_NONE)
 		return handled;
@@ -275,6 +269,12 @@ static noinstr bool handle_bug(struct pt_regs *regs)
 	 * All lies, just get the WARN/BUG out.
 	 */
 	instrumentation_begin();
+	/*
+	 * Normally @regs are unpoisoned by irqentry_enter(), but handle_bug()
+	 * is a rare case that uses @regs without passing them to
+	 * irqentry_enter().
+	 */
+	kmsan_unpoison_entry_regs(regs);
 	/*
 	 * Since we're emulating a CALL with exceptions, restore the interrupt
 	 * state to what it was at the exception site.




[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