Patch "x86/debug: Use UD2 for WARN()" has been added to the 4.15-stable tree
Subsystems (2)
This is a note to let you know that I've just added the patch titled
x86/debug: Use UD2 for WARN()
to the 4.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:
x86-debug-use-ud2-for-warn.patch
and it can be found in the queue-4.15 subdirectory.
If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.
Quoted 1 line
From
3b3a371cc9bc980429baabe0a8e5f307f3d1f463Mon Sep 17 00:00:00 2001
From: Peter Zijlstra <[email protected]>
Date: Fri, 9 Feb 2018 13:16:59 +0100
Subject: x86/debug: Use UD2 for WARN()
From: Peter Zijlstra <[email protected]>
commit 3b3a371cc9bc980429baabe0a8e5f307f3d1f463 upstream.
Since the Intel SDM added an ModR/M byte to UD0 and binutils followed that specification, we now cannot disassemble our kernel anymore.
This now means Intel and AMD disagree on the encoding of UD0. And instead of playing games with additional bytes that are valid ModR/M and single byte instructions (0xd6 for instance), simply use UD2 for both WARN() and BUG().
--- arch/x86/include/asm/bug.h | 15 ++++++--------- arch/x86/kernel/traps.c | 2 +- 2 files changed, 7 insertions(+), 10 deletions(-)
arch/x86/include/asm/bug.h +6 -9
@@ -5,23 +5,20 @@#include <linux/stringify.h> /* -* Since some emulators terminate on UD2, we cannot use it for WARN. -* Since various instruction decoders disagree on the length of UD1, -* we cannot use it either. So use UD0 for WARN. +* Despite that some emulators terminate on UD2, we use it for WARN(). * -* (binutils knows about "ud1" but {en,de}codes it as 2 bytes, whereas -* our kernel decoder thinks it takes a ModRM byte, which seems consistent -* with various things like the Intel SDM instruction encoding rules) +* Since various instruction decoders/specs disagree on the encoding of +* UD0/UD1. */ -#define ASM_UD0 ".byte 0x0f, 0xff" +#define ASM_UD0 ".byte 0x0f, 0xff"/* + ModRM (for Intel) */ #define ASM_UD1 ".byte 0x0f, 0xb9"/* + ModRM */ #define ASM_UD2 ".byte 0x0f, 0x0b"#define INSN_UD0 0xff0f#define INSN_UD2 0x0b0f -#define LEN_UD0 2 +#define LEN_UD2 2#ifdef CONFIG_GENERIC_BUG
@@ -79,7 +76,7 @@ do { \#define __WARN_FLAGS (flags) \ do { \ - _BUG_FLAGS(ASM_UD0, BUGFLAG_WARNING|(flags)); \ + _BUG_FLAGS(ASM_UD2, BUGFLAG_WARNING|(flags)); \ annotate_reachable(); \ } while (0)
arch/x86/kernel/traps.c +1 -1
@@ -181,7 +181,7 @@ int fixup_bug(struct pt_regs *regs, intbreak ;case BUG_TRAP_TYPE_WARN : - regs->ip +=LEN_UD0 ; + regs->ip +=LEN_UD2 ;return 1 ; }
Patches currently in stable-queue which might be from [email protected] are
queue-4.15/selftests-x86-fix-build-bug-caused-by-the-5lvl-test-which-has-been-moved-to-the-vm-directory.patch queue-4.15/x86-entry-64-interleave-xor-register-clearing-with-push-instructions.patch queue-4.15/x86-spectre-fix-an-error-message.patch queue-4.15/nospec-move-array_index_nospec-parameter-checking-into-separate-macro.patch queue-4.15/x86-entry-64-merge-the-pop_c_regs-and-pop_extra_regs-macros-into-a-single-pop_regs-macro.patch queue-4.15/x86-entry-64-remove-the-unused-icebp-macro.patch queue-4.15/kvm-nvmx-set-the-cpu_based_use_msr_bitmaps-if-we-have-a-valid-l02-msr-bitmap.patch queue-4.15/x86-nvmx-properly-set-spec_ctrl-and-pred_cmd-before-merging-msrs.patch queue-4.15/x86-speculation-add-asm-msr-index.h-dependency.patch queue-4.15/x86-entry-64-use-push_and_clean_regs-in-more-cases.patch queue-4.15/x86-cpu-rename-cpu_data.x86_mask-to-cpu_data.x86_stepping.patch queue-4.15/selftests-x86-disable-tests-requiring-32-bit-support-on-pure-64-bit-systems.patch queue-4.15/x86-debug-use-ud2-for-warn.patch queue-4.15/x86-entry-64-fix-paranoid_entry-frame-pointer-warning.patch queue-4.15/x86-cpu-change-type-of-x86_cache_size-variable-to-unsigned-int.patch queue-4.15/x86-speculation-update-speculation-control-microcode-blacklist.patch queue-4.15/x86-entry-64-clear-registers-for-exceptions-interrupts-to-reduce-speculation-attack-surface.patch queue-4.15/x86-speculation-correct-speculation-control-microcode-blacklist-again.patch queue-4.15/x86-entry-64-merge-save_c_regs-and-save_extra_regs-remove-unused-extensions.patch queue-4.15/selftests-x86-do-not-rely-on-int-0x80-in-single_step_syscall.c.patch queue-4.15/selftests-x86-mpx-fix-incorrect-bounds-with-old-_sigfault.patch queue-4.15/selftests-x86-fix-vdso-selftest-segfault-for-vsyscall-none.patch queue-4.15/x86-debug-objtool-annotate-warn-related-ud2-as-reachable.patch queue-4.15/objtool-fix-segfault-in-ignore_unreachable_insn.patch queue-4.15/x86-entry-64-indent-push_and_clear_regs-and-pop_regs-properly.patch queue-4.15/selftests-x86-pkeys-remove-unused-functions.patch queue-4.15/selftests-x86-clean-up-and-document-sscanf-usage.patch queue-4.15/x86-speculation-fix-up-array_index_nospec_mask-asm-constraint.patch queue-4.15/x86-entry-64-clear-extra-registers-beyond-syscall-arguments-to-reduce-speculation-attack-surface.patch queue-4.15/kvm-x86-reduce-retpoline-performance-impact-in-slot_handle_level_range-by-always-inlining-iterator-helper-methods.patch queue-4.15/selftests-x86-do-not-rely-on-int-0x80-in-test_mremap_vdso.c.patch queue-4.15/x86-mm-pti-fix-pti-comment-in-entry_syscall_64.patch queue-4.15/x86-entry-64-get-rid-of-the-alloc_pt_gpregs_on_stack-and-save_and_clear_regs-macros.patch queue-4.15/x86-speculation-clean-up-various-spectre-related-details.patch queue-4.15/x86-kexec-make-kexec-mostly-work-in-5-level-paging-mode.patch queue-4.15/x86-entry-64-introduce-the-push_and_clean_regs-macro.patch queue-4.15/revert-x86-speculation-simplify-indirect_branch_prediction_barrier.patch queue-4.15/x86-entry-64-compat-clear-registers-for-compat-syscalls-to-reduce-speculation-attack-surface.patch queue-4.15/x86-mm-rename-flush_tlb_single-and-flush_tlb_one-to-__flush_tlb_one_.patch queue-4.15/x86-entry-64-fix-cr3-restore-in-paranoid_exit.patch