Linux 4.9.306
Greg Kroah-Hartman
maintainerI'm announcing the release of the 4.9.306 kernel.
All users of the 4.9 kernel series must upgrade.
The updated 4.9.y git tree can be found at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git linux-4.9.y
and can be browsed at the normal kernel.org git web browser:
https://git.kernel.org/?p=linux/kernel/git/stable/linux-stable.git;a=summary
thanks,
greg k-h
------------
Documentation/hw-vuln/index.rst | 1 Documentation/hw-vuln/spectre.rst | 785 +++++++++++++++++++++++++++++++ Documentation/kernel-parameters.txt | 8 Makefile | 2 arch/arm/include/asm/assembler.h | 10 arch/arm/include/asm/spectre.h | 32 + arch/arm/kernel/Makefile | 2 arch/arm/kernel/entry-armv.S | 79 ++- arch/arm/kernel/entry-common.S | 24 arch/arm/kernel/spectre.c | 71 ++ arch/arm/kernel/traps.c | 65 ++ arch/arm/kernel/vmlinux-xip.lds.S | 45 + arch/arm/kernel/vmlinux.lds.S | 45 + arch/arm/mm/Kconfig | 11 arch/arm/mm/proc-v7-bugs.c | 199 ++++++- arch/x86/Kconfig | 4 arch/x86/Makefile | 11 arch/x86/include/asm/cpufeatures.h | 2 arch/x86/include/asm/nospec-branch.h | 41 + arch/x86/kernel/cpu/bugs.c | 225 ++++++-- drivers/block/xen-blkfront.c | 67 +- drivers/firmware/psci.c | 15 drivers/net/xen-netfront.c | 54 +- drivers/scsi/xen-scsifront.c | 3 drivers/xen/gntalloc.c | 25 drivers/xen/grant-table.c | 59 +- drivers/xen/xenbus/xenbus_client.c | 24 include/linux/arm-smccc.h | 74 ++ include/linux/bpf.h | 11 include/linux/compiler-gcc.h | 2 include/linux/module.h | 2 include/xen/grant_table.h | 19 kernel/sysctl.c | 8 scripts/mod/modpost.c | 2 tools/arch/x86/include/asm/cpufeatures.h | 2 35 files changed, 1762 insertions(+), 267 deletions(-)
Borislav Petkov (1):
x86/speculation: Merge one test in spectre_v2_user_select_mitigation()
Emmanuel Gil Peyrot (1):
ARM: fix build error when BPF_SYSCALL is disabled
Greg Kroah-Hartman (1):
Linux 4.9.306
Josh Poimboeuf (4):
Documentation: Add swapgs description to the Spectre v1 documentation x86/speculation: Include unprivileged eBPF status in Spectre v2 mitigation reporting x86/speculation: Warn about Spectre v2 LFENCE mitigation x86/speculation: Warn about eIBRS + LFENCE + Unprivileged eBPF + SMT
Juergen Gross (9):
xen/xenbus: don't let xenbus_grant_ring() remove grants in error case xen/grant-table: add gnttab_try_end_foreign_access() xen/blkfront: don't use gnttab_query_foreign_access() for mapped status xen/netfront: don't use gnttab_query_foreign_access() for mapped status xen/scsifront: don't use gnttab_query_foreign_access() for mapped status xen/gntalloc: don't use gnttab_query_foreign_access()
xen: remove gnttab_query_foreign_access()
xen/gnttab: fix gnttab_end_foreign_access() without page specified xen/netfront: react properly to failing gnttab_end_foreign_access_ref()
Kim Phillips (2):
x86/speculation: Use generic retpoline by default on AMD x86/speculation: Update link to AMD speculation whitepaper
Lukas Bulwahn (1):
Documentation: refer to config RANDOMIZE_BASE for kernel address-space randomization
Mark Rutland (1):
arm/arm64: smccc/psci: add arm_smccc_1_1_get_conduit()
Masahiro Yamada (1):
x86/build: Fix compiler support check for CONFIG_RETPOLINE
Nathan Chancellor (1):
ARM: Do not use NOCROSSREFS directive with ld.lld
Peter Zijlstra (3):
x86,bugs: Unconditionally allow spectre_v2=retpoline,amd x86/speculation: Add eIBRS + Retpoline options Documentation/hw-vuln: Update spectre doc
Peter Zijlstra (Intel) (1):
x86/speculation: Rename RETPOLINE_AMD to RETPOLINE_LFENCE
Russell King (Oracle) (7):
ARM: report Spectre v2 status through sysfs
ARM: early traps initialisation
ARM: use LOADADDR() to get load address of sections
ARM: Spectre-BHB workaround
ARM: include unprivileged BPF status in Spectre V2 reporting
ARM: fix co-processor register typo
ARM: fix build warning in proc-v7-bugs.c
Steven Price (1):
arm/arm64: Provide a wrapper for SMCCC 1.1 calls
Tim Chen (1):
Documentation: Add section about CPU vulnerabilities for Spectre
WANG Chao (1):
x86, modpost: Replace last remnants of RETPOLINE with CONFIG_RETPOLINE
Zhenzhong Duan (3):
x86/speculation: Add RETPOLINE_AMD support to the inline asm CALL_NOSPEC variant x86/retpoline: Make CONFIG_RETPOLINE depend on compiler support x86/retpoline: Remove minimal retpoline support
Greg Kroah-Hartman
maintainerDocumentation/hw-vuln/index.rst +1 -0
@@ -9,6 +9,7 @@ are configurable at compile, boot or run time. .. toctree:: :maxdepth: 1 + spectre l1tf mds tsx_async_abort
Documentation/hw-vuln/spectre.rst new file +785 -0
785 lines not on this page · raw message
Documentation/kernel-parameters.txt +6 -2
@@ -4174,8 +4174,12 @@ bytes respectively. Such letter suffixes can also be entirely omitted. Specific mitigations can also be selected manually: retpoline - replace indirect branches - retpoline,generic - google's original retpoline - retpoline,amd - AMD-specific minimal thunk + retpoline,generic - Retpolines + retpoline,lfence - LFENCE; indirect branch + retpoline,amd - alias for retpoline,lfence + eibrs - enhanced IBRS + eibrs,retpoline - enhanced IBRS + Retpolines + eibrs,lfence - enhanced IBRS + LFENCE Not specifying this option is equivalent to spectre_v2=auto.
Makefile +1 -1
@@ -1,6 +1,6 @@ VERSION = 4 PATCHLEVEL = 9 -SUBLEVEL = 305 +SUBLEVEL = 306 EXTRAVERSION = NAME = Roaring Lionus
arch/arm/include/asm/assembler.h +10 -0
@@ -108,6 +108,16 @@ .endm#endif +#if __LINUX_ARM_ARCH__ <7 + .macro dsb, args + mcr p15, 0, r0, c7, c10, 4 + .endm + + .macro isb, args + mcr p15, 0, r0, c7, c5, 4 + .endm +#endif + .macro asm_trace_hardirqs_off, save=1#if defined(CONFIG_TRACE_IRQFLAGS ) .if \save
arch/arm/include/asm/spectre.h new file +32 -0
@@ -0,0 +1,32 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ + +#ifndef __ASM_SPECTRE_H +#define __ASM_SPECTRE_H + +enum { +SPECTRE_UNAFFECTED , +SPECTRE_MITIGATED , +SPECTRE_VULNERABLE , +}; + +enum { + __SPECTRE_V2_METHOD_BPIALL, + __SPECTRE_V2_METHOD_ICIALLU, + __SPECTRE_V2_METHOD_SMC, + __SPECTRE_V2_METHOD_HVC, + __SPECTRE_V2_METHOD_LOOP8, +}; + +enum { +SPECTRE_V2_METHOD_BPIALL =BIT (__SPECTRE_V2_METHOD_BPIALL), +SPECTRE_V2_METHOD_ICIALLU =BIT (__SPECTRE_V2_METHOD_ICIALLU), +SPECTRE_V2_METHOD_SMC =BIT (__SPECTRE_V2_METHOD_SMC), +SPECTRE_V2_METHOD_HVC =BIT (__SPECTRE_V2_METHOD_HVC), +SPECTRE_V2_METHOD_LOOP8 =BIT (__SPECTRE_V2_METHOD_LOOP8), +}; + +void spectre_v2_update_state (unsigned int state,unsigned int methods); + +int spectre_bhb_update_vectors (unsigned int method); + +#endif
arch/arm/kernel/Makefile +2 -0
@@ -100,4 +100,6 @@ endif obj-$(CONFIG_HAVE_ARM_SMCCC) += smccc-call.o +obj-$(CONFIG_GENERIC_CPU_VULNERABILITIES) += spectre.o + extra-y := $(head-y) vmlinux.lds
arch/arm/kernel/entry-armv.S +73 -6
111 lines not on this page · raw message
arch/arm/kernel/entry-common.S +24 -0
@@ -142,6 +142,29 @@ ENDPROC(ret_from_fork) *----------------------------------------------------------------------------- */ + .align 5 +#ifdef CONFIG_HARDEN_BRANCH_HISTORY +ENTRY(vector_bhb_loop8_swi) + sub sp, sp, #PT_REGS_SIZE + stmia sp, {r0 - r12} + mov r8, #8 +1: b 2f +2: subs r8, r8, #1 + bne 1b + dsb + isb + b 3f +ENDPROC(vector_bhb_loop8_swi) + + .align 5 +ENTRY(vector_bhb_bpiall_swi) + sub sp, sp, #PT_REGS_SIZE + stmia sp, {r0 - r12} + mcr p15, 0, r8, c7, c5, 6 @ BPIALL + isb + b 3f +ENDPROC(vector_bhb_bpiall_swi) +#endif .align 5 ENTRY(vector_swi) #ifdef CONFIG_CPU_V7M
@@ -149,6 +172,7 @@ ENTRY(vector_swi) #else sub sp, sp, #PT_REGS_SIZE stmia sp, {r0 - r12} @ Calling r0 - r12 +3: ARM( add r8, sp, #S_PC ) ARM( stmdb r8, {sp, lr}^ ) @ Calling sp, lr THUMB( mov r8, sp )
arch/arm/kernel/spectre.c new file +71 -0
71 lines not on this page · raw message
arch/arm/kernel/traps.c +59 -6
92 lines not on this page · raw message
arch/arm/kernel/vmlinux-xip.lds.S +35 -10
60 lines not on this page · raw message
arch/arm/kernel/vmlinux.lds.S +35 -10
60 lines not on this page · raw message
arch/arm/mm/Kconfig +11 -0
@@ -803,6 +803,7 @@ config CPU_BPREDICT_DISABLE config CPU_SPECTRE bool + select GENERIC_CPU_VULNERABILITIES config HARDEN_BRANCH_PREDICTOR bool "Harden the branch predictor against aliasing attacks" if EXPERT
@@ -823,6 +824,16 @@ config HARDEN_BRANCH_PREDICTOR If unsure, say Y. +config HARDEN_BRANCH_HISTORY + bool "Harden Spectre style attacks against branch history" if EXPERT + depends on CPU_SPECTRE + default y + help + Speculation attacks against some high-performance processors can + make use of branch history to influence future speculation. When + taking an exception, a sequence of branches overwrites the branch + history, or branch history is invalidated. + config TLS_REG_EMUL bool select NEED_KUSER_HELPERS
arch/arm/mm/proc-v7-bugs.c +172 -27
277 lines not on this page · raw message
arch/x86/Kconfig +0 -4
@@ -418,10 +418,6 @@ config RETPOLINE branches. Requires a compiler with -mindirect-branch=thunk-extern support for full protection. The kernel may run slower. - Without compiler support, at least indirect branches in assembler - code are eliminated. Since this includes the syscall entry path, - it is not entirely pointless. - if X86_32 config X86_EXTENDED_PLATFORM bool "Support for extended (non-PC) x86 platforms"
arch/x86/Makefile +8 -3
@@ -221,9 +221,7 @@ ifdef CONFIG_RETPOLINE RETPOLINE_CFLAGS_CLANG := -mretpoline-external-thunk RETPOLINE_CFLAGS += $(call cc-option,$(RETPOLINE_CFLAGS_GCC),$(call cc-option,$(RETPOLINE_CFLAGS_CLANG))) - ifneq ($(RETPOLINE_CFLAGS),) - KBUILD_CFLAGS += $(RETPOLINE_CFLAGS) -DRETPOLINE - endif + KBUILD_CFLAGS += $(RETPOLINE_CFLAGS) endif archscripts: scripts_basic
@@ -239,6 +237,13 @@ archprepare: ifeq ($(CONFIG_KEXEC_FILE),y) $(Q)$(MAKE) $(build)=arch/x86/purgatory arch/x86/purgatory/kexec-purgatory.c endif +ifdef CONFIG_RETPOLINE +ifeq ($(RETPOLINE_CFLAGS),) + @echo "You are building kernel with non-retpoline compiler." >&2 + @echo "Please update your compiler." >&2 + @false +endif +endif ### # Kernel objects
arch/x86/include/asm/cpufeatures.h +1 -1
@@ -195,7 +195,7 @@#define X86_FEATURE_FENCE_SWAPGS_USER ( 7*32+10)/* "" LFENCE in user entry SWAPGS path */ #define X86_FEATURE_FENCE_SWAPGS_KERNEL ( 7*32+11)/* "" LFENCE in kernel entry SWAPGS path */ #define X86_FEATURE_RETPOLINE ( 7*32+12)/* "" Generic Retpoline mitigation for Spectre variant 2 */ -#define X86_FEATURE_RETPOLINE_AMD ( 7*32+13)/* "" AMD Retpoline mitigation for Spectre variant 2 */ +#define X86_FEATURE_RETPOLINE_LFENCE ( 7*32+13)/* "" Use LFENCE for Spectre variant 2 */ #define X86_FEATURE_MSR_SPEC_CTRL ( 7*32+16)/* "" MSR SPEC_CTRL is implemented */ #define X86_FEATURE_SSBD ( 7*32+17)/* Speculative Store Bypass Disable */
arch/x86/include/asm/nospec-branch.h +26 -15
89 lines not on this page · raw message
arch/x86/kernel/cpu/bugs.c +157 -68
358 lines not on this page · raw message
drivers/block/xen-blkfront.c +39 -28
141 lines not on this page · raw message
drivers/firmware/psci.c +15 -0
@@ -64,6 +64,21 @@ struct psci_operations psci_ops = { .smccc_version = SMCCC_VERSION_1_0, }; +enum arm_smccc_conduit arm_smccc_1_1_get_conduit (void ) +{ +if (psci_ops.smccc_version <SMCCC_VERSION_1_1 ) +return SMCCC_CONDUIT_NONE ; + +switch (psci_ops.conduit) { +case PSCI_CONDUIT_SMC : +return SMCCC_CONDUIT_SMC ; +case PSCI_CONDUIT_HVC : +return SMCCC_CONDUIT_HVC ; +default : +return SMCCC_CONDUIT_NONE ; + } +} +typedef unsigned long (psci_fn )(unsigned long ,unsigned long ,unsigned long ,unsigned long );static psci_fn *invoke_psci_fn;
drivers/net/xen-netfront.c +33 -21
118 lines not on this page · raw message
drivers/scsi/xen-scsifront.c +1 -2
@@ -210,12 +210,11 @@ static void scsifront_gnttab_done(struct vscsifrnt_info *info, uint32_t id)return ;for (i =0 ; i < s->nr_grants; i++) { -if (unlikely (gnttab_query_foreign_access (s->gref[i]) !=0 )) { +if (unlikely (!gnttab_try_end_foreign_access (s->gref[i]))) {shost_printk (KERN_ALERT , info->host,KBUILD_MODNAME "grant still in use by backend\n" );BUG (); } -gnttab_end_foreign_access (s->gref[i],0 ,0UL ); }kfree (s->sg);
drivers/xen/gntalloc.c +7 -18
@@ -166,20 +166,14 @@ static int add_grefs(struct ioctl_gntalloc_alloc_gref *op,__del_gref (gref); } -/* It's possible for the target domain to map the just-allocated grant -* references by blindly guessing their IDs; if this is done, then -* __del_gref will leave them in the queue_gref list. They need to be -* added to the global list so that we can free them when they are no -* longer referenced. -*/ -if (unlikely (!list_empty (&queue_gref))) -list_splice_tail (&queue_gref, &gref_list);mutex_unlock (&gref_mutex);return rc; }static void __del_gref (struct gntalloc_gref *gref) { +unsigned long addr; +if (gref->notify.flags &UNMAP_NOTIFY_CLEAR_BYTE ) {uint8_t *tmp =kmap (gref->page); tmp[gref->notify.pgoff] =0 ;
@@ -193,21 +187,16 @@ static void __del_gref(struct gntalloc_gref *gref) gref->notify.flags =0 ;if (gref->gref_id) { -if (gnttab_query_foreign_access (gref->gref_id)) -return ; - -if (!gnttab_end_foreign_access_ref (gref->gref_id,0 )) -return ; - -gnttab_free_grant_reference (gref->gref_id); +if (gref->page) { + addr = (unsigned long )page_to_virt (gref->page); +gnttab_end_foreign_access (gref->gref_id,0 , addr); + }else +gnttab_free_grant_reference (gref->gref_id); } gref_size--;list_del (&gref->next_gref); -if (gref->page) -__free_page (gref->page); -kfree (gref); }
drivers/xen/grant-table.c +33 -26
107 lines not on this page · raw message
drivers/xen/xenbus/xenbus_client.c +11 -13
@@ -387,7 +387,14 @@ int xenbus_grant_ring(struct xenbus_device *dev, void *vaddr, unsigned int nr_pages, grant_ref_t *grefs) { int err; -int i, j; +unsigned int i; +grant_ref_t gref_head; + + err =gnttab_alloc_grant_references (nr_pages, &gref_head); +if (err) { +xenbus_dev_fatal (dev, err,"granting access to ring page" ); +return err; + }for (i =0 ; i < nr_pages; i++) {unsigned long gfn;
@@ -397,23 +404,14 @@ int xenbus_grant_ring(struct xenbus_device *dev, void *vaddr,else gfn =virt_to_gfn (vaddr); - err =gnttab_grant_foreign_access (dev->otherend_id, gfn,0 ); -if (err <0 ) { -xenbus_dev_fatal (dev, err, -"granting access to ring page" ); - goto fail; - } - grefs[i] = err; + grefs[i] =gnttab_claim_grant_reference (&gref_head); +gnttab_grant_foreign_access_ref (grefs[i], dev->otherend_id, + gfn,0 ); vaddr = vaddr +XEN_PAGE_SIZE ; }return 0 ; - -fail: -for (j =0 ; j < i; j++) -gnttab_end_foreign_access_ref (grefs[j],0 ); -return err; }EXPORT_SYMBOL_GPL (xenbus_grant_ring);
include/linux/arm-smccc.h +74 -0
85 lines not on this page · raw message
include/linux/bpf.h +11 -0
@@ -295,6 +295,11 @@ static inline void bpf_long_memcpy(void *dst, const void *src, u32 size)/* verify correctness of eBPF program */ int bpf_check (struct bpf_prog **fp,union bpf_attr *attr); + +static inline bool unprivileged_ebpf_enabled (void ) +{ +return !sysctl_unprivileged_bpf_disabled; +}#else static inline void bpf_register_prog_type (struct bpf_prog_type_list *tl) {
@@ -322,6 +327,12 @@ static inline struct bpf_prog *bpf_prog_inc(struct bpf_prog *prog) {return ERR_PTR (-EOPNOTSUPP ); } + +static inline bool unprivileged_ebpf_enabled (void ) +{ +return false; +} +#endif /* CONFIG_BPF_SYSCALL */ /* verifier prototypes for helper functions called from eBPF programs */
include/linux/compiler-gcc.h +1 -1
@@ -107,7 +107,7 @@#define __weak __attribute__((weak))#define __alias (symbol) __attribute__((alias(#symbol))) -#ifdef RETPOLINE +#ifdef CONFIG_RETPOLINE #define __noretpoline __attribute__((indirect_branch("keep")))#endif
include/linux/module.h +1 -1
@@ -791,7 +791,7 @@ static inline void module_bug_finalize(const Elf_Ehdr *hdr,static inline void module_bug_cleanup (struct module *mod) {}#endif /* CONFIG_GENERIC_BUG */ -#ifdef RETPOLINE +#ifdef CONFIG_RETPOLINE extern bool retpoline_module_ok (bool has_retpoline);#else static inline bool retpoline_module_ok (bool has_retpoline)
include/xen/grant_table.h +17 -2
@@ -97,17 +97,32 @@ int gnttab_end_foreign_access_ref(grant_ref_t ref, int readonly);* access has been ended, free the given page too. Access will be ended * immediately iff the grant entry is not in use, otherwise it will happen * some time later. page may be 0, in which case no freeing will occur. +* Note that the granted page might still be accessed (read or write) by the +* other side after gnttab_end_foreign_access() returns, so even if page was +* specified as 0 it is not allowed to just reuse the page for other +* purposes immediately. gnttab_end_foreign_access() will take an additional +* reference to the granted page in this case, which is dropped only after +* the grant is no longer in use. +* This requires that multi page allocations for areas subject to +* gnttab_end_foreign_access() are done via alloc_pages_exact() (and freeing +* via free_pages_exact()) in order to avoid high order pages. */ void gnttab_end_foreign_access (grant_ref_t ref,int readonly,unsigned long page); +/* +* End access through the given grant reference, iff the grant entry is +* no longer in use. In case of success ending foreign access, the +* grant reference is deallocated. +* Return 1 if the grant entry was freed, 0 if it is still in use. +*/ +int gnttab_try_end_foreign_access (grant_ref_t ref); +int gnttab_grant_foreign_transfer (domid_t domid,unsigned long pfn);unsigned long gnttab_end_foreign_transfer_ref (grant_ref_t ref);unsigned long gnttab_end_foreign_transfer (grant_ref_t ref); -int gnttab_query_foreign_access (grant_ref_t ref); -/* * operations on reserved batches of grant references */
kernel/sysctl.c +8 -0
@@ -222,6 +222,11 @@ static int sysrq_sysctl_handler(struct ctl_table *table, int write,#endif #ifdef CONFIG_BPF_SYSCALL + +void __weak unpriv_ebpf_notify (int new_state) +{ +} +static int bpf_unpriv_handler (struct ctl_table *table,int write,void *buffer,size_t *lenp,loff_t *ppos) {
@@ -239,6 +244,9 @@ static int bpf_unpriv_handler(struct ctl_table *table, int write,return -EPERM ; *(int *)table->data = unpriv_enable; } + +unpriv_ebpf_notify (unpriv_enable); +return ret; }#endif
scripts/mod/modpost.c +1 -1
@@ -2147,7 +2147,7 @@ static void add_intree_flag(struct buffer *b, int is_intree)/* Cannot check for assembler */ static void add_retpoline (struct buffer *b) { -buf_printf (b,"\n#ifdef RETPOLINE\n" ); +buf_printf (b,"\n#ifdef CONFIG_RETPOLINE\n" );buf_printf (b,"MODULE_INFO(retpoline, \"Y\");\n" );buf_printf (b,"#endif\n" ); }
tools/arch/x86/include/asm/cpufeatures.h +1 -1
@@ -194,7 +194,7 @@#define X86_FEATURE_PROC_FEEDBACK ( 7*32+ 9)/* AMD ProcFeedbackInterface */ #define X86_FEATURE_RETPOLINE ( 7*32+12)/* "" Generic Retpoline mitigation for Spectre variant 2 */ -#define X86_FEATURE_RETPOLINE_AMD ( 7*32+13)/* "" AMD Retpoline mitigation for Spectre variant 2 */ +#define X86_FEATURE_RETPOLINE_LFENCE ( 7*32+13)/* "" Use LFENCEs for Spectre variant 2 */ #define X86_FEATURE_MSR_SPEC_CTRL ( 7*32+16)/* "" MSR SPEC_CTRL is implemented */ #define X86_FEATURE_SSBD ( 7*32+17)/* Speculative Store Bypass Disable */