]> Git Repo - linux.git/commitdiff
Merge branch 'x86-pti-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git...
authorLinus Torvalds <[email protected]>
Wed, 17 Jan 2018 19:54:56 +0000 (11:54 -0800)
committerLinus Torvalds <[email protected]>
Wed, 17 Jan 2018 19:54:56 +0000 (11:54 -0800)
Pull x86 pti bits and fixes from Thomas Gleixner:
 "This last update contains:

   - An objtool fix to prevent a segfault with the gold linker by
     changing the invocation order. That's not just for gold, it's a
     general robustness improvement.

   - An improved error message for objtool which spares tearing hairs.

   - Make KASAN fail loudly if there is not enough memory instead of
     oopsing at some random place later

   - RSB fill on context switch to prevent RSB underflow and speculation
     through other units.

   - Make the retpoline/RSB functionality work reliably for both Intel
     and AMD

   - Add retpoline to the module version magic so mismatch can be
     detected

   - A small (non-fix) update for cpufeatures which prevents cpu feature
     clashing for the upcoming extra mitigation bits to ease
     backporting"

* 'x86-pti-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
  module: Add retpoline tag to VERMAGIC
  x86/cpufeature: Move processor tracing out of scattered features
  objtool: Improve error message for bad file argument
  objtool: Fix seg fault with gold linker
  x86/retpoline: Add LFENCE to the retpoline/RSB filling RSB macros
  x86/retpoline: Fill RSB on context switch for affected CPUs
  x86/kasan: Panic if there is not enough memory to boot

1  2 
arch/x86/entry/entry_64.S
scripts/Makefile.build

index 4f8e1d35a97ca7071a11f33f07e2b87c2eac7acf,d54a0ede61d1a885970d666ee101a17e00b1ec9d..aa15b4c0e3d17dd64f513ce6a1915cdd24829016
@@@ -53,19 -53,15 +53,19 @@@ ENTRY(native_usergs_sysret64
  END(native_usergs_sysret64)
  #endif /* CONFIG_PARAVIRT */
  
 -.macro TRACE_IRQS_IRETQ
 +.macro TRACE_IRQS_FLAGS flags:req
  #ifdef CONFIG_TRACE_IRQFLAGS
 -      bt      $9, EFLAGS(%rsp)                /* interrupts off? */
 +      bt      $9, \flags              /* interrupts off? */
        jnc     1f
        TRACE_IRQS_ON
  1:
  #endif
  .endm
  
 +.macro TRACE_IRQS_IRETQ
 +      TRACE_IRQS_FLAGS EFLAGS(%rsp)
 +.endm
 +
  /*
   * When dynamic function tracer is enabled it will add a breakpoint
   * to all locations that it is about to modify, sync CPUs, update
@@@ -219,6 -215,8 +219,6 @@@ ENTRY(entry_SYSCALL_64
        movq    %rsp, PER_CPU_VAR(rsp_scratch)
        movq    PER_CPU_VAR(cpu_current_top_of_stack), %rsp
  
 -      TRACE_IRQS_OFF
 -
        /* Construct struct pt_regs on stack */
        pushq   $__USER_DS                      /* pt_regs->ss */
        pushq   PER_CPU_VAR(rsp_scratch)        /* pt_regs->sp */
@@@ -239,8 -237,6 +239,8 @@@ GLOBAL(entry_SYSCALL_64_after_hwframe
        sub     $(6*8), %rsp                    /* pt_regs->bp, bx, r12-15 not saved */
        UNWIND_HINT_REGS extra=0
  
 +      TRACE_IRQS_OFF
 +
        /*
         * If we need to do entry work or if we guess we'll need to do
         * exit work, go straight to the slow path.
@@@ -491,6 -487,17 +491,17 @@@ ENTRY(__switch_to_asm
        movq    %rbx, PER_CPU_VAR(irq_stack_union)+stack_canary_offset
  #endif
  
+ #ifdef CONFIG_RETPOLINE
+       /*
+        * When switching from a shallower to a deeper call stack
+        * the RSB may either underflow or use entries populated
+        * with userspace addresses. On CPUs where those concerns
+        * exist, overwrite the RSB with entries which capture
+        * speculative execution to prevent attack.
+        */
+       FILL_RETURN_BUFFER %r12, RSB_CLEAR_LOOPS, X86_FEATURE_RSB_CTXSW
+ #endif
        /* restore callee-saved registers */
        popq    %r15
        popq    %r14
@@@ -1102,13 -1109,11 +1113,13 @@@ ENTRY(native_load_gs_index
        FRAME_BEGIN
        pushfq
        DISABLE_INTERRUPTS(CLBR_ANY & ~CLBR_RDI)
 +      TRACE_IRQS_OFF
        SWAPGS
  .Lgs_change:
        movl    %edi, %gs
  2:    ALTERNATIVE "", "mfence", X86_BUG_SWAPGS_FENCE
        SWAPGS
 +      TRACE_IRQS_FLAGS (%rsp)
        popfq
        FRAME_END
        ret
diff --combined scripts/Makefile.build
index cb8997ed01497ccebdfded3aef8ccdd401fa8482,6bed45dc2cb1bd10019ba9e14a05e1af165e987b..47cddf32aeba025f2741dbc7f48d596f4f6653fa
@@@ -65,6 -65,15 +65,6 @@@ ifneq ($(hostprogs-y)$(hostprogs-m)$(ho
  include scripts/Makefile.host
  endif
  
 -ifneq ($(KBUILD_SRC),)
 -# Create output directory if not already present
 -_dummy := $(shell [ -d $(obj) ] || mkdir -p $(obj))
 -
 -# Create directories for object files if directory does not exist
 -# Needed when obj-y := dir/file.o syntax is used
 -_dummy := $(foreach d,$(obj-dirs), $(shell [ -d $(d) ] || mkdir -p $(d)))
 -endif
 -
  ifndef obj
  $(warning kbuild: Makefile.build is included improperly)
  endif
@@@ -76,7 -85,7 +76,7 @@@ lib-target := $(obj)/lib.
  obj-y += $(obj)/lib-ksyms.o
  endif
  
 -ifneq ($(strip $(obj-y) $(obj-m) $(obj-) $(subdir-m) $(lib-target)),)
 +ifneq ($(strip $(obj-y) $(need-builtin)),)
  builtin-target := $(obj)/built-in.o
  endif
  
@@@ -100,10 -109,6 +100,10 @@@ ifneq ($(KBUILD_CHECKSRC),0
    endif
  endif
  
 +ifneq ($(KBUILD_ENABLE_EXTRA_GCC_CHECKS),)
 +  cmd_checkdoc = $(srctree)/scripts/kernel-doc -none $< ;
 +endif
 +
  # Do section mismatch analysis for each module/built-in.o
  ifdef CONFIG_DEBUG_SECTION_MISMATCH
    cmd_secanalysis = ; scripts/mod/modpost $@
@@@ -265,12 -270,18 +265,18 @@@ els
  objtool_args += $(call cc-ifversion, -lt, 0405, --no-unreachable)
  endif
  
+ ifdef CONFIG_MODVERSIONS
+ objtool_o = $(@D)/.tmp_$(@F)
+ else
+ objtool_o = $(@)
+ endif
  # 'OBJECT_FILES_NON_STANDARD := y': skip objtool checking for a directory
  # 'OBJECT_FILES_NON_STANDARD_foo.o := 'y': skip objtool checking for a file
  # 'OBJECT_FILES_NON_STANDARD_foo.o := 'n': override directory skip for a file
  cmd_objtool = $(if $(patsubst y%,, \
        $(OBJECT_FILES_NON_STANDARD_$(basetarget).o)$(OBJECT_FILES_NON_STANDARD)n), \
-       $(__objtool_obj) $(objtool_args) "$(@)";)
+       $(__objtool_obj) $(objtool_args) "$(objtool_o)";)
  objtool_obj = $(if $(patsubst y%,, \
        $(OBJECT_FILES_NON_STANDARD_$(basetarget).o)$(OBJECT_FILES_NON_STANDARD)n), \
        $(__objtool_obj))
@@@ -286,16 -297,15 +292,16 @@@ objtool_dep = $(objtool_obj)                                    
  define rule_cc_o_c
        $(call echo-cmd,checksrc) $(cmd_checksrc)                         \
        $(call cmd_and_fixdep,cc_o_c)                                     \
-       $(cmd_modversions_c)                                              \
 +      $(cmd_checkdoc)                                                   \
        $(call echo-cmd,objtool) $(cmd_objtool)                           \
+       $(cmd_modversions_c)                                              \
        $(call echo-cmd,record_mcount) $(cmd_record_mcount)
  endef
  
  define rule_as_o_S
        $(call cmd_and_fixdep,as_o_S)                                     \
-       $(cmd_modversions_S)                                              \
-       $(call echo-cmd,objtool) $(cmd_objtool)
+       $(call echo-cmd,objtool) $(cmd_objtool)                           \
+       $(cmd_modversions_S)
  endef
  
  # List module undefined symbols (or empty line if not enabled)
@@@ -559,14 -569,14 +565,14 @@@ $(multi-used-m): FORC
  $(call multi_depend, $(multi-used-m), .o, -objs -y -m)
  
  targets += $(multi-used-y) $(multi-used-m)
 -
 +targets := $(filter-out $(PHONY), $(targets))
  
  # Descending
  # ---------------------------------------------------------------------------
  
  PHONY += $(subdir-ym)
  $(subdir-ym):
 -      $(Q)$(MAKE) $(build)=$@
 +      $(Q)$(MAKE) $(build)=$@ need-builtin=$(if $(findstring $@,$(subdir-obj-y)),1)
  
  # Add FORCE to the prequisites of a target to force it to be always rebuilt.
  # ---------------------------------------------------------------------------
@@@ -580,23 -590,13 +586,23 @@@ FORCE
  # optimization, we don't need to read them if the target does not
  # exist, we will rebuild anyway in that case.
  
 -targets := $(wildcard $(sort $(targets)))
 -cmd_files := $(wildcard $(foreach f,$(targets),$(dir $(f)).$(notdir $(f)).cmd))
 +cmd_files := $(wildcard $(foreach f,$(sort $(targets)),$(dir $(f)).$(notdir $(f)).cmd))
  
  ifneq ($(cmd_files),)
    include $(cmd_files)
  endif
  
 +ifneq ($(KBUILD_SRC),)
 +# Create directories for object files if they do not exist
 +obj-dirs := $(sort $(obj) $(patsubst %/,%, $(dir $(targets))))
 +# If cmd_files exist, their directories apparently exist.  Skip mkdir.
 +exist-dirs := $(sort $(patsubst %/,%, $(dir $(cmd_files))))
 +obj-dirs := $(strip $(filter-out $(exist-dirs), $(obj-dirs)))
 +ifneq ($(obj-dirs),)
 +$(shell mkdir -p $(obj-dirs))
 +endif
 +endif
 +
  # Declare the contents of the .PHONY variable as phony.  We keep that
  # information in a variable se we can use it in if_changed and friends.
  
This page took 0.078307 seconds and 4 git commands to generate.