4.14.14-stable review
Subsystems (6)
Greg Kroah-Hartman
maintainercover 4.14.14-stable review
This is the start of the stable review cycle for the 4.14.14 release. There are 118 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Wed Jan 17 12:33:32 UTC 2018. Anything received after that time might be too late.
The whole patch series can be found in one patch at:
kernel.org/pub/linux/kernel/v4.x/stable-review/patch-4.14.14-rc1.gz
or in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git linux-4.14.y
and the diffstat can be found below.
thanks,
greg k-h
-------------
Pseudo-Shortlog of commits:
Greg Kroah-Hartman <[email protected]>
Linux 4.14.14-rc1
Thomas Gleixner <[email protected]>
x86/retpoline: Remove compile time warning
Peter Zijlstra <[email protected]>
x86,perf: Disable intel_bts when PTI
W. Trevor King <[email protected]>
security/Kconfig: Correct the Documentation reference for PTI
Thomas Gleixner <[email protected]>
x86/pti: Fix !PCID and sanitize defines
Andy Lutomirski <[email protected]>
selftests/x86: Add test_vsyscall
David Woodhouse <[email protected]>
x86/retpoline: Fill return stack buffer on vmexit
Andi Kleen <[email protected]>
x86/retpoline/irq32: Convert assembler indirect jumps
David Woodhouse <[email protected]>
x86/retpoline/checksum32: Convert assembler indirect jumps
David Woodhouse <[email protected]>
x86/retpoline/xen: Convert Xen hypercall indirect jumps
David Woodhouse <[email protected]>
x86/retpoline/hyperv: Convert assembler indirect jumps
David Woodhouse <[email protected]>
x86/retpoline/ftrace: Convert ftrace assembler indirect jumps
David Woodhouse <[email protected]>
x86/retpoline/entry: Convert entry assembler indirect jumps
David Woodhouse <[email protected]>
x86/retpoline/crypto: Convert crypto assembler indirect jumps
David Woodhouse <[email protected]>
x86/spectre: Add boot time option to select Spectre v2 mitigation
David Woodhouse <[email protected]>
x86/retpoline: Add initial retpoline support
Josh Poimboeuf <[email protected]>
objtool: Allow alternatives to be ignored
Josh Poimboeuf <[email protected]>
objtool: Detect jumps to retpoline thunks
Dave Hansen <[email protected]>
x86/pti: Make unpoison of pgd for trusted boot work for real
Borislav Petkov <[email protected]>
x86/alternatives: Fix optimize_nops() checking
David Woodhouse <[email protected]>
sysfs/cpu: Fix typos in vulnerability documentation
Tom Lendacky <[email protected]>
x86/cpu/AMD: Use LFENCE_RDTSC in preference to MFENCE_RDTSC
Tom Lendacky <[email protected]>
x86/cpu/AMD: Make LFENCE a serializing instruction
Jike Song <[email protected]>
x86/mm/pti: Remove dead logic in pti_user_pagetable_walk*()
Dave Hansen <[email protected]>
x86/tboot: Unbreak tboot with PTI enabled
Thomas Gleixner <[email protected]>
x86/cpu: Implement CPU vulnerabilites sysfs functions
Thomas Gleixner <[email protected]>
sysfs/cpu: Add vulnerability folder
David Woodhouse <[email protected]>
x86/cpufeatures: Add X86_BUG_SPECTRE_V[12]
Dave Hansen <[email protected]>
x86/Documentation: Add PTI description
Jiri Kosina <[email protected]>
x86/pti: Unbreak EFI old_memmap
Benjamin Poirier <[email protected]>
e1000e: Fix e1000_check_for_copper_link_ich8lan return value.
John Johansen <[email protected]>
apparmor: fix ptrace label match when matching stacked labels
Kirill A. Shutemov <[email protected]>
kdump: write correct address of mem_section into vmcoreinfo
Hans de Goede <[email protected]>
mux: core: fix double get_device()
Icenowy Zheng <[email protected]>
uas: ignore UAS for Norelsys NS1068(X) chips
Ben Seri <[email protected]>
Bluetooth: Prevent stack info leak from the EFS element.
Viktor Slavkovic <[email protected]>
staging: android: ashmem: fix a race condition in ASHMEM_SET_SIZE ioctl
Shuah Khan <[email protected]>
usbip: vudc_tx: fix v_send_ret_submit() vulnerability to null xfer buffer
Shuah Khan <[email protected]>
usbip: fix vudc_rx: harden CMD_SUBMIT path to handle malicious input
Shuah Khan <[email protected]>
usbip: remove kernel addresses from usb device and urb debug msgs
Alan Stern <[email protected]>
USB: UDC core: fix double-free in usb_add_gadget_udc_release
Pete Zaitcev <[email protected]>
USB: fix usbmon BUG trigger
Stefan Agner <[email protected]>
usb: misc: usb3503: make sure reset is low for at least 100us
Christian Holl <[email protected]>
USB: serial: cp210x: add new device ID ELV ALC 8xxx
Diego Elio Pettenò <[email protected]>
USB: serial: cp210x: add IDs for LifeScan OneTouch Verio IQ
Daniel Borkmann <[email protected]>
bpf: arsh is not supported in 32 bit alu thus reject it
Daniel Borkmann <[email protected]>
bpf, array: fix overflow in max_entries and undefined behavior in index_mask
Alexei Starovoitov <[email protected]>
bpf: prevent out-of-bounds speculation
Ville Syrjälä <[email protected]>
drm/i915: Fix init_clock_gating for resume
Ville Syrjälä <[email protected]>
drm/i915: Move init_clock_gating() back to where it was
Kenneth Graunke <[email protected]>
drm/i915: Whitelist SLICE_COMMON_ECO_CHICKEN1 on Geminilake.
Zhi Wang <[email protected]>
drm/i915/gvt: Clear the shadow page table entry after post-sync
Dan Carpenter <[email protected]>
drm/vmwgfx: Potential off by one in vmw_view_add()
Thomas Hellstrom <[email protected]>
drm/vmwgfx: Don't cache framebuffer maps
David Gibson <[email protected]>
KVM: PPC: Book3S HV: Always flush TLB in kvmppc_alloc_reset_hpt()
Serhii Popovych <[email protected]>
KVM: PPC: Book3S HV: Fix use after free in case of multiple resize requests
Serhii Popovych <[email protected]>
KVM: PPC: Book3S HV: Drop prepare_done from struct kvm_resize_hpt
Alexey Kardashevskiy <[email protected]>
KVM: PPC: Book3S PR: Fix WIMG handling under pHyp
Andrew Honig <[email protected]>
KVM: x86: Add memory barrier on vmcs field lookup
Jia Zhang <[email protected]>
x86/microcode/intel: Extend BDW late-loading with a revision check
Emmanuel Grumbach <[email protected]>
iwlwifi: pcie: fix DMA memory mapping / unmapping
Ilya Dryomov <[email protected]>
rbd: set max_segments to USHRT_MAX
Florian Margaine <[email protected]>
rbd: reacquire lock should update lock owner client id
Masaharu Hayakawa <[email protected]>
mmc: renesas_sdhi: Add MODULE_LICENSE
Eric Biggers <[email protected]>
crypto: algapi - fix NULL dereference in crypto_remove_spawns()
Mathieu Desnoyers <[email protected]>
membarrier: Disable preemption when calling smp_call_function_many()
David S. Miller <[email protected]>
Revert "Revert "xfrm: Fix stack-out-of-bounds read in xfrm_state_find.""
Russell King <[email protected]>
sfp: fix sfp-bus oops when removing socket/upstream
Ido Schimmel <[email protected]>
mlxsw: spectrum: Relax sanity checks during enslavement
Mathieu Xhonneux <[email protected]>
ipv6: sr: fix TLVs not being copied using setsockopt
Roi Dayan <[email protected]>
net/sched: Fix update of lastuse in act modules implementing stats_update
Ido Schimmel <[email protected]>
mlxsw: spectrum_router: Fix NULL pointer deref
Stephen Hemminger <[email protected]>
ethtool: do not print warning for applications using legacy API
Eric Dumazet <[email protected]>
ipv6: fix possible mem leaks in ipv6_make_skb()
Sergei Shtylyov <[email protected]>
sh_eth: fix SH7757 GEther initialization
Jerome Brunet <[email protected]>
net: stmmac: enable EEE in MII, GMII or RGMII only
Sergei Shtylyov <[email protected]>
sh_eth: fix TSU resource handling
Marcelo Ricardo Leitner <[email protected]>
sctp: fix the handling of ICMP Frag Needed for too small MTUs
Marcelo Ricardo Leitner <[email protected]>
sctp: do not retransmit upon FragNeeded if PMTU discovery is disabled
Fugang Duan <[email protected]>
net: fec: free/restore resource in related probe error pathes
Fugang Duan <[email protected]>
net: fec: defer probe if regulator is not ready
Fugang Duan <[email protected]>
net: fec: restore dev_id in the cases of probe error
Mohamed Ghannam <[email protected]>
RDS: null pointer dereference in rds_atomic_free_op
Mohamed Ghannam <[email protected]>
RDS: Heap OOB write in rds_message_alloc_sgs()
Russell King <[email protected]>
phylink: ensure we report link down when LOS asserted
Andrii Vladyka <[email protected]>
net: core: fix module type in sock_diag_bind
Eli Cooper <[email protected]>
ip6_tunnel: disable dst caching if tunnel is dual-stack
Cong Wang <[email protected]>
8021q: fix a memory leak for VLAN 0 device
Vikas C Sajjan <[email protected]>
x86/acpi: Reduce code duplication in mp_override_legacy_irq()
Takashi Iwai <[email protected]>
ALSA: aloop: Fix racy hw constraints adjustment
Takashi Iwai <[email protected]>
ALSA: aloop: Fix inconsistent format due to incomplete rule
Takashi Iwai <[email protected]>
ALSA: aloop: Release cable upon open error path
Takashi Iwai <[email protected]>
ALSA: pcm: Allow aborting mutex lock at OSS read/write loops
Takashi Iwai <[email protected]>
ALSA: pcm: Abort properly at pending signal in OSS read/write loops
Takashi Iwai <[email protected]>
ALSA: pcm: Add missing error checks in OSS emulation plugin builder
Takashi Iwai <[email protected]>
ALSA: pcm: Workaround for weird PulseAudio behavior on rewind error
Takashi Iwai <[email protected]>
ALSA: pcm: Remove incorrect snd_BUG_ON() usages
Vikas C Sajjan <[email protected]>
x86/acpi: Handle SCI interrupts above legacy space gracefully
Steve Wise <[email protected]>
iw_cxgb4: when flushing, complete all wrs in a chain
Steve Wise <[email protected]>
iw_cxgb4: reflect the original WR opcode in drain cqes
Steve Wise <[email protected]>
iw_cxgb4: only clear the ARMED bit if a notification is needed
Steve Wise <[email protected]>
iw_cxgb4: atomically flush the qp
Steve Wise <[email protected]>
iw_cxgb4: only call the cq comp_handler when the cq is armed
Rafael J. Wysocki <[email protected]>
platform/x86: wmi: Call acpi_wmi_init() later
Jim Mattson <[email protected]>
kvm: vmx: Scrub hardware GPRs at VM-exit
Tejun Heo <[email protected]>
cgroup: fix css_task_iter crash on CSS_TASK_ITER_PROC
Maciej W. Rozycki <[email protected]>
MIPS: Disallow outsized PTRACE_SETREGSET NT_PRFPREG regset accesses
Maciej W. Rozycki <[email protected]>
MIPS: Also verify sizeof `elf_fpreg_t' with PTRACE_SETREGSET
Maciej W. Rozycki <[email protected]>
MIPS: Fix an FCSR access API regression with NT_PRFPREG and MSA
Maciej W. Rozycki <[email protected]>
MIPS: Consistently handle buffer counter with PTRACE_SETREGSET
Maciej W. Rozycki <[email protected]>
MIPS: Guard against any partial write attempt with PTRACE_SETREGSET
Maciej W. Rozycki <[email protected]>
MIPS: Factor out NT_PRFPREG regset access helpers
Maciej W. Rozycki <[email protected]>
MIPS: Validate PR_SET_FP_MODE prctl(2) requests against the ABI of the task
Bart Van Assche <[email protected]>
IB/srpt: Fix ACL lookup during login
Bart Van Assche <[email protected]>
IB/srpt: Disable RDMA access by the initiator
Wolfgang Grandegger <[email protected]>
can: gs_usb: fix return value of the "set_bittiming" callback
Oliver Hartkopp <[email protected]>
can: vxcan: improve handling of missing peer name attribute
Wanpeng Li <[email protected]>
KVM: Fix stack-out-of-bounds read in write_mmio
Suren Baghdasaryan <[email protected]>
dm bufio: fix shrinker scans when (nr_to_scan < retain_target)
-------------
Diffstat:
Documentation/ABI/testing/sysfs-devices-system-cpu | 16 + Documentation/admin-guide/kernel-parameters.txt | 49 +- Documentation/x86/pti.txt | 186 ++++++++ Makefile | 4 +- arch/mips/kernel/process.c | 12 + arch/mips/kernel/ptrace.c | 147 ++++-- arch/powerpc/kvm/book3s_64_mmu.c | 1 + arch/powerpc/kvm/book3s_64_mmu_hv.c | 90 ++-- arch/powerpc/kvm/book3s_pr.c | 2 + arch/x86/Kconfig | 14 + arch/x86/Makefile | 8 + arch/x86/crypto/aesni-intel_asm.S | 5 +- arch/x86/crypto/camellia-aesni-avx-asm_64.S | 3 +- arch/x86/crypto/camellia-aesni-avx2-asm_64.S | 3 +- arch/x86/crypto/crc32c-pcl-intel-asm_64.S | 3 +- arch/x86/entry/calling.h | 36 +- arch/x86/entry/entry_32.S | 5 +- arch/x86/entry/entry_64.S | 12 +- arch/x86/events/intel/bts.c | 18 + arch/x86/include/asm/asm-prototypes.h | 25 ++ arch/x86/include/asm/cpufeatures.h | 4 + arch/x86/include/asm/mshyperv.h | 18 +- arch/x86/include/asm/msr-index.h | 3 + arch/x86/include/asm/nospec-branch.h | 214 +++++++++ arch/x86/include/asm/processor-flags.h | 2 +- arch/x86/include/asm/tlbflush.h | 6 +- arch/x86/include/asm/xen/hypercall.h | 5 +- arch/x86/kernel/acpi/boot.c | 61 ++- arch/x86/kernel/alternative.c | 7 +- arch/x86/kernel/cpu/amd.c | 28 +- arch/x86/kernel/cpu/bugs.c | 185 ++++++++ arch/x86/kernel/cpu/common.c | 3 + arch/x86/kernel/cpu/microcode/intel.c | 13 +- arch/x86/kernel/ftrace_32.S | 6 +- arch/x86/kernel/ftrace_64.S | 8 +- arch/x86/kernel/irq_32.c | 9 +- arch/x86/kernel/tboot.c | 11 + arch/x86/kvm/svm.c | 23 + arch/x86/kvm/vmx.c | 30 +- arch/x86/kvm/x86.c | 8 +- arch/x86/lib/Makefile | 1 + arch/x86/lib/checksum_32.S | 7 +- arch/x86/lib/retpoline.S | 48 ++ arch/x86/mm/pti.c | 32 +- arch/x86/platform/efi/efi_64.c | 2 + crypto/algapi.c | 12 + drivers/base/Kconfig | 3 + drivers/base/cpu.c | 48 ++ drivers/block/rbd.c | 18 +- drivers/gpu/drm/i915/gvt/gtt.c | 5 +- drivers/gpu/drm/i915/i915_drv.c | 1 + drivers/gpu/drm/i915/i915_reg.h | 2 + drivers/gpu/drm/i915/intel_display.c | 14 +- drivers/gpu/drm/i915/intel_engine_cs.c | 5 + drivers/gpu/drm/i915/intel_pm.c | 44 +- drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c | 2 + drivers/gpu/drm/vmwgfx/vmwgfx_kms.c | 6 - drivers/gpu/drm/vmwgfx/vmwgfx_kms.h | 2 +- drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c | 41 +- drivers/infiniband/hw/cxgb4/cq.c | 7 +- drivers/infiniband/hw/cxgb4/ev.c | 8 +- drivers/infiniband/hw/cxgb4/iw_cxgb4.h | 2 - drivers/infiniband/hw/cxgb4/qp.c | 119 +++-- drivers/infiniband/hw/cxgb4/t4.h | 6 + drivers/infiniband/ulp/srpt/ib_srpt.c | 5 +- drivers/md/dm-bufio.c | 8 +- drivers/mmc/host/renesas_sdhi_core.c | 3 + drivers/mux/core.c | 4 +- drivers/net/can/usb/gs_usb.c | 2 +- drivers/net/can/vxcan.c | 2 +- drivers/net/ethernet/freescale/fec_main.c | 7 +- drivers/net/ethernet/intel/e1000e/ich8lan.c | 11 +- drivers/net/ethernet/mellanox/mlxsw/spectrum.c | 11 +- drivers/net/ethernet/mellanox/mlxsw/spectrum.h | 2 + .../net/ethernet/mellanox/mlxsw/spectrum_router.c | 2 +- .../ethernet/mellanox/mlxsw/spectrum_switchdev.c | 6 + drivers/net/ethernet/renesas/sh_eth.c | 29 +- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 6 + drivers/net/phy/phylink.c | 3 +- drivers/net/phy/sfp-bus.c | 6 +- drivers/net/wireless/intel/iwlwifi/pcie/internal.h | 10 +- drivers/net/wireless/intel/iwlwifi/pcie/tx-gen2.c | 11 +- drivers/net/wireless/intel/iwlwifi/pcie/tx.c | 8 +- drivers/platform/x86/wmi.c | 2 +- drivers/staging/android/ashmem.c | 2 + drivers/usb/gadget/udc/core.c | 28 +- drivers/usb/misc/usb3503.c | 2 + drivers/usb/mon/mon_bin.c | 8 +- drivers/usb/serial/cp210x.c | 2 + drivers/usb/storage/unusual_uas.h | 7 + drivers/usb/usbip/usbip_common.c | 17 +- drivers/usb/usbip/vudc_rx.c | 19 + drivers/usb/usbip/vudc_tx.c | 11 +- include/linux/bpf.h | 2 + include/linux/cpu.h | 7 + include/linux/crash_core.h | 2 + include/linux/sh_eth.h | 1 - include/net/sctp/structs.h | 2 +- include/trace/events/kvm.h | 7 +- kernel/bpf/arraymap.c | 61 ++- kernel/bpf/verifier.c | 41 ++ kernel/cgroup/cgroup.c | 14 +- kernel/crash_core.c | 2 +- kernel/sched/membarrier.c | 2 + net/8021q/vlan.c | 7 +- net/bluetooth/l2cap_core.c | 20 +- net/core/ethtool.c | 15 +- net/core/sock_diag.c | 2 +- net/ipv6/exthdrs.c | 9 + net/ipv6/ip6_output.c | 5 +- net/ipv6/ip6_tunnel.c | 9 +- net/rds/rdma.c | 4 + net/sched/act_gact.c | 2 +- net/sched/act_mirred.c | 2 +- net/sctp/input.c | 28 +- net/sctp/transport.c | 29 +- net/xfrm/xfrm_policy.c | 29 +- security/Kconfig | 2 +- security/apparmor/include/perms.h | 3 + security/apparmor/ipc.c | 53 ++- sound/core/oss/pcm_oss.c | 41 +- sound/core/oss/pcm_plugin.c | 14 +- sound/core/pcm_lib.c | 4 +- sound/core/pcm_native.c | 9 +- sound/drivers/aloop.c | 98 ++-- tools/objtool/check.c | 69 ++- tools/objtool/check.h | 2 +- tools/testing/selftests/bpf/test_verifier.c | 40 ++ tools/testing/selftests/x86/Makefile | 2 +- tools/testing/selftests/x86/test_vsyscall.c | 500 +++++++++++++++++++++ virt/kvm/arm/mmio.c | 6 +- 131 files changed, 2536 insertions(+), 561 deletions(-)
Greg Kroah-Hartman
maintainerPATCH 1/118 dm bufio: fix shrinker scans when (nr_to_scan < retain_target)
4.14-stable review patch. If anyone has any objections, please let me know.
------------------
From: Suren Baghdasaryan <[email protected]>
commit fbc7c07ec23c040179384a1f16b62b6030eb6bdd upstream.
When system is under memory pressure it is observed that dm bufio shrinker often reclaims only one buffer per scan. This change fixes the following two issues in dm bufio shrinker that cause this behavior:
1. ((nr_to_scan - freed) <= retain_target) condition is used to terminate slab scan process. This assumes that nr_to_scan is equal to the LRU size, which might not be correct because do_shrink_slab() in vmscan.c calculates nr_to_scan using multiple inputs.
As a result when nr_to_scan is less than retain_target (64) the scan will terminate after the first iteration, effectively reclaiming one buffer per scan and making scans very inefficient. This hurts vmscan performance especially because mutex is acquired/released every time dm_bufio_shrink_scan() is called.
New implementation uses ((LRU size - freed) <= retain_target) condition for scan termination. LRU size can be safely determined inside __scan() because this function is called after dm_bufio_lock().
2. do_shrink_slab() uses value returned by dm_bufio_shrink_count() to determine number of freeable objects in the slab. However dm_bufio always retains retain_target buffers in its LRU and will terminate a scan when this mark is reached. Therefore returning the entire LRU size from dm_bufio_shrink_count() is misleading because that does not represent the number of freeable objects that slab will reclaim during a scan. Returning (LRU size - retain_target) better represents the number of freeable objects in the slab. This way do_shrink_slab() returns 0 when (LRU size < retain_target) and vmscan will not try to scan this shrinker avoiding scans that will not reclaim any memory.
Test: tested using Android device running <AOSP>/system/extras/alloc-stress that generates memory pressure and causes intensive shrinker scans
--- drivers/md/dm-bufio.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/md/dm-bufio.c +6 -2
@@ -1611,7 +1611,8 @@ static unsigned long __scan(struct dm_buint l;struct dm_buffer *b, *tmp;unsigned long freed =0 ; -unsigned long count = nr_to_scan; +unsigned long count = c->n_buffers[LIST_CLEAN ] + + c->n_buffers[LIST_DIRTY ];unsigned long retain_target =get_retain_buffers (c);for (l =0 ; l <LIST_SIZE ; l++) {
@@ -1647,8 +1648,11 @@ static unsigned long dm_bufio_shrink_count(struct shrinker *shrink, struct shrink_control *sc) { struct dm_bufio_client *c = container_of(shrink, struct dm_bufio_client, shrinker); +unsigned long count =ACCESS_ONCE (c->n_buffers[LIST_CLEAN ]) + +ACCESS_ONCE (c->n_buffers[LIST_DIRTY ]); +unsigned long retain_target =get_retain_buffers (c); -return ACCESS_ONCE (c->n_buffers[LIST_CLEAN ]) +ACCESS_ONCE (c->n_buffers[LIST_DIRTY ]); +return (count < retain_target) ?0 : (count - retain_target); }/*
Greg Kroah-Hartman
maintainerPATCH 2/118 KVM: Fix stack-out-of-bounds read in write_mmio
In reply to Greg Kroah-Hartman4.14-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wanpeng Li <[email protected]>
commit e39d200fa5bf5b94a0948db0dae44c1b73b84a56 upstream.
Reported by syzkaller:
BUG: KASAN: stack-out-of-bounds in write_mmio+0x11e/0x270 [kvm] Read of size 8 at addr ffff8803259df7f8 by task syz-executor/32298 CPU: 6 PID: 32298 Comm: syz-executor Tainted: G OE 4.15.0-rc2+ #18 Hardware name: LENOVO ThinkCentre M8500t-N000/SHARKBAY, BIOS FBKTC1AUS 02/16/2016 Call Trace: dump_stack+0xab/0xe1 print_address_description+0x6b/0x290 kasan_report+0x28a/0x370 write_mmio+0x11e/0x270 [kvm] emulator_read_write_onepage+0x311/0x600 [kvm] emulator_read_write+0xef/0x240 [kvm] emulator_fix_hypercall+0x105/0x150 [kvm] em_hypercall+0x2b/0x80 [kvm] x86_emulate_insn+0x2b1/0x1640 [kvm] x86_emulate_instruction+0x39a/0xb90 [kvm] handle_exception+0x1b4/0x4d0 [kvm_intel] vcpu_enter_guest+0x15a0/0x2640 [kvm] kvm_arch_vcpu_ioctl_run+0x549/0x7d0 [kvm] kvm_vcpu_ioctl+0x479/0x880 [kvm] do_vfs_ioctl+0x142/0x9a0 SyS_ioctl+0x74/0x80 entry_SYSCALL_64_fastpath+0x23/0x9a
The path of patched vmmcall will patch 3 bytes opcode 0F 01 C1(vmcall) to the guest memory, however, write_mmio tracepoint always prints 8 bytes through *(u64 *)val since kvm splits the mmio access into 8 bytes. This leaks 5 bytes from the kernel stack (CVE-2017-17741). This patch fixes it by just accessing the bytes which we operate on.
Before patch:
syz-executor-5567 [007] .... 51370.561696: kvm_mmio: mmio write len 3 gpa 0x10 val 0x1ffff10077c1010f
After patch:
syz-executor-13416 [002] .... 51302.299573: kvm_mmio: mmio write len 3 gpa 0x10 val 0xc1010f
--- arch/x86/kvm/x86.c | 8 ++++---- include/trace/events/kvm.h | 7 +++++-- virt/kvm/arm/mmio.c | 6 +++--- 3 files changed, 12 insertions(+), 9 deletions(-)
arch/x86/kvm/x86.c +4 -4
@@ -4362,7 +4362,7 @@ static int vcpu_mmio_read(struct kvm_vcp addr, n, v)) && kvm_io_bus_read(vcpu, KVM_MMIO_BUS, addr, n, v))break ; -trace_kvm_mmio (KVM_TRACE_MMIO_READ , n, addr, *(u64 *)v); +trace_kvm_mmio (KVM_TRACE_MMIO_READ , n, addr, v); handled += n; addr += n; len -= n;
@@ -4621,7 +4621,7 @@ static int read_prepare(struct kvm_vcpu {if (vcpu->mmio_read_completed) {trace_kvm_mmio (KVM_TRACE_MMIO_READ , bytes, - vcpu->mmio_fragments[0 ].gpa, *(u64 *)val); + vcpu->mmio_fragments[0 ].gpa, val); vcpu->mmio_read_completed =0 ;return 1 ; }
@@ -4643,14 +4643,14 @@ static int write_emulate(struct kvm_vcpustatic int write_mmio (struct kvm_vcpu *vcpu,gpa_t gpa,int bytes,void *val) { -trace_kvm_mmio (KVM_TRACE_MMIO_WRITE , bytes, gpa, *(u64 *)val); +trace_kvm_mmio (KVM_TRACE_MMIO_WRITE , bytes, gpa, val);return vcpu_mmio_write (vcpu, gpa, bytes, val); }static int read_exit_mmio (struct kvm_vcpu *vcpu,gpa_t gpa,void *val,int bytes) { -trace_kvm_mmio (KVM_TRACE_MMIO_READ_UNSATISFIED , bytes, gpa,0 ); +trace_kvm_mmio (KVM_TRACE_MMIO_READ_UNSATISFIED , bytes, gpa,NULL );return X86EMUL_IO_NEEDED ; }
include/trace/events/kvm.h +5 -2
@@ -211,7 +211,7 @@ TRACE_EVENT(kvm_ack_irq, { KVM_TRACE_MMIO_WRITE, "write" } TRACE_EVENT(kvm_mmio, - TP_PROTO(int type, int len, u64 gpa, u64 val), + TP_PROTO(int type, int len, u64 gpa, void *val), TP_ARGS(type, len, gpa, val), TP_STRUCT__entry(
@@ -225,7 +225,10 @@ TRACE_EVENT(kvm_mmio, __entry->type = type; __entry->len = len; __entry->gpa = gpa; - __entry->val = val; + __entry->val =0 ; +if (val) +memcpy (&__entry->val, val, +min_t (u32,sizeof (__entry->val), len)); ), TP_printk("mmio %s len %u gpa 0x%llx val 0x%llx",
virt/kvm/arm/mmio.c +3 -3
@@ -112,7 +112,7 @@ int kvm_handle_mmio_return(struct kvm_vc }trace_kvm_mmio (KVM_TRACE_MMIO_READ , len, run->mmio.phys_addr, - data); + &data); data =vcpu_data_host_to_guest (vcpu, data, len);vcpu_set_reg (vcpu, vcpu->arch.mmio_decode.rt, data); }
@@ -182,14 +182,14 @@ int io_mem_abort(struct kvm_vcpu *vcpu, data =vcpu_data_guest_to_host (vcpu,vcpu_get_reg (vcpu, rt), len); -trace_kvm_mmio (KVM_TRACE_MMIO_WRITE , len, fault_ipa, data); +trace_kvm_mmio (KVM_TRACE_MMIO_WRITE , len, fault_ipa, &data);kvm_mmio_write_buf (data_buf, len, data); ret =kvm_io_bus_write (vcpu,KVM_MMIO_BUS , fault_ipa, len, data_buf); }else {trace_kvm_mmio (KVM_TRACE_MMIO_READ_UNSATISFIED , len, - fault_ipa,0 ); + fault_ipa,NULL ); ret =kvm_io_bus_read (vcpu,KVM_MMIO_BUS , fault_ipa, len, data_buf);
Greg Kroah-Hartman
maintainerPATCH 3/118 can: vxcan: improve handling of missing peer name attribute
In reply to Greg Kroah-Hartman4.14-stable review patch. If anyone has any objections, please let me know.
------------------
From: Oliver Hartkopp <[email protected]>
commit b4c2951a4833e66f1bbfe65ddcd4fdcdfafe5e8f upstream.
Picking up the patch from Serhey Popovych (commit 191cdb3822e5df6b3c8, "veth: Be more robust on network device creation when no attributes").
When the peer name attribute is not provided the former implementation tries to register the given device name twice ... which leads to -EEXIST. If only one device name is given apply an automatic generated and valid name for the peer.
--- drivers/net/can/vxcan.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/can/vxcan.c +1 -1
@@ -194,7 +194,7 @@ static int vxcan_newlink(struct net *net tbp = peer_tb; } -if (tbp[IFLA_IFNAME ]) { +if (ifmp && tbp[IFLA_IFNAME ]) {nla_strlcpy (ifname, tbp[IFLA_IFNAME ],IFNAMSIZ ); name_assign_type =NET_NAME_USER ; }else {
Greg Kroah-Hartman
maintainerPATCH 4/118 can: gs_usb: fix return value of the "set_bittiming" callback
In reply to Greg Kroah-Hartman4.14-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wolfgang Grandegger <[email protected]>
commit d5b42e6607661b198d8b26a0c30969605b1bf5c7 upstream.
The "set_bittiming" callback treats a positive return value as error! For that reason "can_changelink()" will quit silently after setting the bittiming values without processing ctrlmode, restart-ms, etc.
--- drivers/net/can/usb/gs_usb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/can/usb/gs_usb.c +1 -1
@@ -449,7 +449,7 @@ static int gs_usb_set_bittiming(struct ndev_err (netdev->dev.parent,"Couldn't set bittimings (err=%d)" , rc); -return rc; +return (rc >0 ) ?0 : rc; }static void gs_usb_xmit_callback (struct urb *urb)
Greg Kroah-Hartman
maintainerPATCH 5/118 IB/srpt: Disable RDMA access by the initiator
In reply to Greg Kroah-Hartman4.14-stable review patch. If anyone has any objections, please let me know.
------------------
From: Bart Van Assche <[email protected]>
commit bec40c26041de61162f7be9d2ce548c756ce0f65 upstream.
With the SRP protocol all RDMA operations are initiated by the target. Since no RDMA operations are initiated by the initiator, do not grant the initiator permission to submit RDMA reads or writes to the target.
--- drivers/infiniband/ulp/srpt/ib_srpt.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/infiniband/ulp/srpt/ib_srpt.c +1 -2
@@ -1000,8 +1000,7 @@ static int srpt_init_ch_qp(struct srpt_rreturn -ENOMEM ; attr->qp_state =IB_QPS_INIT ; - attr->qp_access_flags =IB_ACCESS_LOCAL_WRITE |IB_ACCESS_REMOTE_READ | -IB_ACCESS_REMOTE_WRITE ; + attr->qp_access_flags =IB_ACCESS_LOCAL_WRITE ; attr->port_num = ch->sport->port; attr->pkey_index =0 ;
Greg Kroah-Hartman
maintainerPATCH 6/118 IB/srpt: Fix ACL lookup during login
In reply to Greg Kroah-Hartman4.14-stable review patch. If anyone has any objections, please let me know.
------------------
From: Bart Van Assche <[email protected]>
commit a1ffa4670cb97ae3a4b3e8535d88be5f643f7c3b upstream.
Make sure that the initiator port GUID is stored in ch->ini_guid.
Note: when initiating a connection sgid and dgid members in struct sa_path_rec represent the source and destination GIDs. When accepting a connection however sgid represents the destination GID and dgid the source GID.
--- drivers/infiniband/ulp/srpt/ib_srpt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/infiniband/ulp/srpt/ib_srpt.c +1 -1
@@ -1991,7 +1991,7 @@ static int srpt_cm_req_recv(struct ib_cm goto destroy_ib; } - guid = (__be16 *)¶m->primary_path->sgid.global.interface_id; + guid = (__be16 *)¶m->primary_path->dgid.global.interface_id;snprintf (ch->ini_guid,sizeof (ch->ini_guid),"%04x:%04x:%04x:%04x" ,be16_to_cpu (guid[0 ]),be16_to_cpu (guid[1 ]),be16_to_cpu (guid[2 ]),be16_to_cpu (guid[3 ]));
Greg Kroah-Hartman
maintainerPATCH 7/118 MIPS: Validate PR_SET_FP_MODE prctl(2) requests against the ABI of the task
In reply to Greg Kroah-Hartman4.14-stable review patch. If anyone has any objections, please let me know.
------------------
From: Maciej W. Rozycki <[email protected]>
commit b67336eee3fcb8ecedc6c13e2bf88aacfa3151e2 upstream.
Fix an API loophole introduced with commit 9791554b45a2 ("MIPS,prctl:
add PR_[GS]ET_FP_MODE prctl options for MIPS"), where the caller of prctl(2) is incorrectly allowed to make a change to CP0.Status.FR or CP0.Config5.FRE register bits even if CONFIG_MIPS_O32_FP64_SUPPORT has not been enabled, despite that an executable requesting the mode requested via ELF file annotation would not be allowed to run in the first place, or for n64 and n64 ABI tasks which do not have non-default modes defined at all. Add suitable checks to `mips_set_process_fp_mode' and bail out if an invalid mode change has been requested for the ABI in effect, even if the FPU hardware or emulation would otherwise allow it.
Always succeed however without taking any further action if the mode requested is the same as one already in effect, regardless of whether any mode change, should it be requested, would actually be allowed for the task concerned.
Patchwork: https://patchwork.linux-mips.org/patch/17800/
--- arch/mips/kernel/process.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
arch/mips/kernel/process.c +12 -0
@@ -705,6 +705,18 @@ int mips_set_process_fp_mode(struct taskstruct task_struct *t;int max_users; +/* If nothing to change, return right away, successfully. */ +if (value ==mips_get_process_fp_mode (task)) +return 0 ; + +/* Only accept a mode change if 64-bit FP enabled for o32. */ +if (!IS_ENABLED (CONFIG_MIPS_O32_FP64_SUPPORT )) +return -EOPNOTSUPP ; + +/* And only for o32 tasks. */ +if (IS_ENABLED (CONFIG_64BIT ) && !test_thread_flag (TIF_32BIT_REGS )) +return -EOPNOTSUPP ; +/* Check the value is valid */ if (value & ~known_bits)return -EOPNOTSUPP ;
Greg Kroah-Hartman
maintainerPATCH 8/118 MIPS: Factor out NT_PRFPREG regset access helpers
In reply to Greg Kroah-Hartman4.14-stable review patch. If anyone has any objections, please let me know.
------------------
From: Maciej W. Rozycki <[email protected]>
commit a03fe72572c12e98f4173f8a535f32468e48b6ec upstream.
In preparation to fix a commit 72b22bbad1e7 ("MIPS: Don't assume 64-bit FP registers for FP regset") FCSR access regression factor out NT_PRFPREG regset access helpers for the non-MSA and the MSA variants respectively, to avoid having to deal with excessive indentation in the actual fix.
No functional change, however use target->thread.fpu.fpr[0]' rather than target->thread.fpu.fpr[i]' for FGR holding type size determination as there's no i' variable to refer to anymore, and for the factored out i' variable declaration use unsigned int' rather than unsigned' as its type, following the common style.
Patchwork: https://patchwork.linux-mips.org/patch/17925/
--- arch/mips/kernel/ptrace.c | 108 +++++++++++++++++++++++++++++++++++----------- 1 file changed, 83 insertions(+), 25 deletions(-)
arch/mips/kernel/ptrace.c +83 -25
@@ -410,25 +410,36 @@ static int gpr64_set(struct task_struct#endif /* CONFIG_64BIT */ -static int fpr_get (struct task_struct *target, -const struct user_regset *regset, -unsigned int pos,unsigned int count, -void *kbuf,void __user *ubuf) +/* +* Copy the floating-point context to the supplied NT_PRFPREG buffer, +* !CONFIG_CPU_HAS_MSA variant. FP context's general register slots +* correspond 1:1 to buffer slots. +*/ +static int fpr_get_fpa (struct task_struct *target, +unsigned int *pos,unsigned int *count, +void **kbuf,void __user **ubuf) { -unsigned i; -int err; -u64 fpr_val; - -/* XXX fcr31 */ +return user_regset_copyout (pos, count, kbuf, ubuf, + &target->thread.fpu, +0 ,sizeof (elf_fpregset_t)); +} -if (sizeof (target->thread.fpu.fpr[i]) ==sizeof (elf_fpreg_t)) -return user_regset_copyout (&pos, &count, &kbuf, &ubuf, - &target->thread.fpu, -0 ,sizeof (elf_fpregset_t)); +/* +* Copy the floating-point context to the supplied NT_PRFPREG buffer, +* CONFIG_CPU_HAS_MSA variant. Only lower 64 bits of FP context's +* general register slots are copied to buffer slots. +*/ +static int fpr_get_msa (struct task_struct *target, +unsigned int *pos,unsigned int *count, +void **kbuf,void __user **ubuf) +{ +unsigned int i; +u64 fpr_val; +int err;for (i =0 ; i <NUM_FPU_REGS ; i++) { fpr_val =get_fpr64 (&target->thread.fpu.fpr[i],0 ); - err =user_regset_copyout (&pos, &count, &kbuf, &ubuf, + err =user_regset_copyout (pos, count, kbuf, ubuf, &fpr_val, i *sizeof (elf_fpreg_t), (i +1 ) *sizeof (elf_fpreg_t));if (err)
@@ -438,27 +449,54 @@ static int fpr_get(struct task_struct *treturn 0 ; } -static int fpr_set (struct task_struct *target, +/* Copy the floating-point context to the supplied NT_PRFPREG buffer. */ +static int fpr_get (struct task_struct *target,const struct user_regset *regset,unsigned int pos,unsigned int count, -const void *kbuf,const void __user *ubuf) +void *kbuf,void __user *ubuf) { -unsigned i;int err; -u64 fpr_val;/* XXX fcr31 */ -init_fp_ctx (target); +if (sizeof (target->thread.fpu.fpr[0 ]) ==sizeof (elf_fpreg_t)) + err =fpr_get_fpa (target, &pos, &count, &kbuf, &ubuf); +else + err =fpr_get_msa (target, &pos, &count, &kbuf, &ubuf); + +return err; +} -if (sizeof (target->thread.fpu.fpr[i]) ==sizeof (elf_fpreg_t)) -return user_regset_copyin (&pos, &count, &kbuf, &ubuf, - &target->thread.fpu, -0 ,sizeof (elf_fpregset_t)); +/* +* Copy the supplied NT_PRFPREG buffer to the floating-point context, +* !CONFIG_CPU_HAS_MSA variant. Buffer slots correspond 1:1 to FP +* context's general register slots. +*/ +static int fpr_set_fpa (struct task_struct *target, +unsigned int *pos,unsigned int *count, +const void **kbuf,const void __user **ubuf) +{ +return user_regset_copyin (pos, count, kbuf, ubuf, + &target->thread.fpu, +0 ,sizeof (elf_fpregset_t)); +} + +/* +* Copy the supplied NT_PRFPREG buffer to the floating-point context, +* CONFIG_CPU_HAS_MSA variant. Buffer slots are copied to lower 64 +* bits only of FP context's general register slots. +*/ +static int fpr_set_msa (struct task_struct *target, +unsigned int *pos,unsigned int *count, +const void **kbuf,const void __user **ubuf) +{ +unsigned int i; +u64 fpr_val; +int err;BUILD_BUG_ON (sizeof (fpr_val) !=sizeof (elf_fpreg_t)); -for (i =0 ; i <NUM_FPU_REGS && count >=sizeof (elf_fpreg_t); i++) { - err =user_regset_copyin (&pos, &count, &kbuf, &ubuf, +for (i =0 ; i <NUM_FPU_REGS && *count >=sizeof (elf_fpreg_t); i++) { + err =user_regset_copyin (pos, count, kbuf, ubuf, &fpr_val, i *sizeof (elf_fpreg_t), (i +1 ) *sizeof (elf_fpreg_t));if (err)
@@ -469,6 +507,26 @@ static int fpr_set(struct task_struct *treturn 0 ; } +/* Copy the supplied NT_PRFPREG buffer to the floating-point context. */ +static int fpr_set (struct task_struct *target, +const struct user_regset *regset, +unsigned int pos,unsigned int count, +const void *kbuf,const void __user *ubuf) +{ +int err; + +/* XXX fcr31 */ + +init_fp_ctx (target); + +if (sizeof (target->thread.fpu.fpr[0 ]) ==sizeof (elf_fpreg_t)) + err =fpr_set_fpa (target, &pos, &count, &kbuf, &ubuf); +else + err =fpr_set_msa (target, &pos, &count, &kbuf, &ubuf); + +return err; +} +enum mips_regset {REGSET_GPR ,REGSET_FPR ,
Greg Kroah-Hartman
maintainerPATCH 9/118 MIPS: Guard against any partial write attempt with PTRACE_SETREGSET
In reply to Greg Kroah-Hartman4.14-stable review patch. If anyone has any objections, please let me know.
------------------
From: Maciej W. Rozycki <[email protected]>
commit dc24d0edf33c3e15099688b6bbdf7bdc24bf6e91 upstream.
Complement commit d614fd58a283 ("mips/ptrace: Preserve previous registers for short regset write") and ensure that no partial register write attempt is made with PTRACE_SETREGSET, as we do not preinitialize any temporaries used to hold incoming register data and consequently random data could be written.
It is the responsibility of the caller, such as `ptrace_regset', to arrange for writes to span whole registers only, so here we only assert that it has indeed happened.
Patchwork: https://patchwork.linux-mips.org/patch/17926/
--- arch/mips/kernel/ptrace.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)
arch/mips/kernel/ptrace.c +11 -1
@@ -507,7 +507,15 @@ static int fpr_set_msa(struct task_strucreturn 0 ; } -/* Copy the supplied NT_PRFPREG buffer to the floating-point context. */ +/* +* Copy the supplied NT_PRFPREG buffer to the floating-point context. +* +* We optimize for the case where `count % sizeof(elf_fpreg_t) == 0', +* which is supposed to have been guaranteed by the kernel before +* calling us, e.g. in `ptrace_regset'. We enforce that requirement, +* so that we can safely avoid preinitializing temporaries for +* partial register writes. +*/ static int fpr_set(struct task_struct *target, const struct user_regset *regset, unsigned int pos, unsigned int count,
@@ -515,6 +523,8 @@ static int fpr_set(struct task_struct *t {int err; +BUG_ON (count %sizeof (elf_fpreg_t)); +/* XXX fcr31 */ init_fp_ctx (target);
Greg Kroah-Hartman
maintainerPATCH 10/118 MIPS: Consistently handle buffer counter with PTRACE_SETREGSET
In reply to Greg Kroah-Hartman4.14-stable review patch. If anyone has any objections, please let me know.
------------------
From: Maciej W. Rozycki <[email protected]>
commit 80b3ffce0196ea50068885d085ff981e4b8396f4 upstream.
Update commit d614fd58a283 ("mips/ptrace: Preserve previous registers for short regset write") bug and consistently consume all data supplied to `fpr_set_msa' with the ptrace(2) PTRACE_SETREGSET request, such that a zero data buffer counter is returned where insufficient data has been given to fill a whole number of FP general registers.
In reality this is not going to happen, as the caller is supposed to only supply data covering a whole number of registers and it is verified in ptrace_regset' and again asserted in fpr_set', however structuring code such that the presence of trailing partial FP general register data causes `fpr_set_msa' to return with a non-zero data buffer counter makes it appear that this trailing data will be used if there are subsequent writes made to FP registers, which is going to be the case with the FCSR once the missing write to that register has been fixed.
Patchwork: https://patchwork.linux-mips.org/patch/17927/
--- arch/mips/kernel/ptrace.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/mips/kernel/ptrace.c +1 -1
@@ -495,7 +495,7 @@ static int fpr_set_msa(struct task_strucint err;BUILD_BUG_ON (sizeof (fpr_val) !=sizeof (elf_fpreg_t)); -for (i =0 ; i <NUM_FPU_REGS && *count >=sizeof (elf_fpreg_t); i++) { +for (i =0 ; i <NUM_FPU_REGS && *count >0 ; i++) { err =user_regset_copyin (pos, count, kbuf, ubuf, &fpr_val, i *sizeof (elf_fpreg_t), (i +1 ) *sizeof (elf_fpreg_t));
Greg Kroah-Hartman
maintainerPATCH 11/118 MIPS: Fix an FCSR access API regression with NT_PRFPREG and MSA
In reply to Greg Kroah-Hartman4.14-stable review patch. If anyone has any objections, please let me know.
------------------
From: Maciej W. Rozycki <[email protected]>
commit be07a6a1188372b6d19a3307ec33211fc9c9439d upstream.
Fix a commit 72b22bbad1e7 ("MIPS: Don't assume 64-bit FP registers for FP regset") public API regression, then activated by commit 1db1af84d6df ("MIPS: Basic MSA context switching support"), that caused the FCSR register not to be read or written for CONFIG_CPU_HAS_MSA kernel configurations (regardless of actual presence or absence of the MSA feature in a given processor) with ptrace(2) PTRACE_GETREGSET and PTRACE_SETREGSET requests nor recorded in core dumps.
This is because with !CONFIG_CPU_HAS_MSA configurations the whole of `elf_fpregset_t' array is bulk-copied as it is, which includes the FCSR in one half of the last, 33rd slot, whereas with CONFIG_CPU_HAS_MSA configurations array elements are copied individually, and then only the leading 32 FGR slots while the remaining slot is ignored.
Correct the code then such that only FGR slots are copied in the respective !MSA and MSA helpers an then the FCSR slot is handled separately in common code. Use `ptrace_setfcr31' to update the FCSR too, so that the read-only mask is respected.
Retrieving a correct value of FCSR is important in debugging not only for the human to be able to get the right interpretation of the situation, but for correct operation of GDB as well. This is because the condition code bits in FSCR are used by GDB to determine the location to place a breakpoint at when single-stepping through an FPU branch instruction. If such a breakpoint is placed incorrectly (i.e. with the condition reversed), then it will be missed, likely causing the debuggee to run away from the control of GDB and consequently breaking the process of investigation.
Fortunately GDB continues using the older PTRACE_GETFPREGS ptrace(2) request which is unaffected, so the regression only really hits with post-mortem debug sessions using a core dump file, in which case execution, and consequently single-stepping through branches is not possible. Of course core files created by buggy kernels out there will have the value of FCSR recorded clobbered, but such core files cannot be corrected and the person using them simply will have to be aware that the value of FCSR retrieved is not reliable.
Which also means we can likely get away without defining a replacement API which would ensure a correct value of FSCR to be retrieved, or none at all.
This is based on previous work by Alex Smith, extensively rewritten.
Patchwork: https://patchwork.linux-mips.org/patch/17928/
--- arch/mips/kernel/ptrace.c | 47 +++++++++++++++++++++++++++++++++++----------- 1 file changed, 36 insertions(+), 11 deletions(-)
arch/mips/kernel/ptrace.c +36 -11
@@ -413,7 +413,7 @@ static int gpr64_set(struct task_struct/* * Copy the floating-point context to the supplied NT_PRFPREG buffer, * !CONFIG_CPU_HAS_MSA variant. FP context's general register slots -* correspond 1:1 to buffer slots. +* correspond 1:1 to buffer slots. Only general registers are copied. */ static int fpr_get_fpa(struct task_struct *target, unsigned int *pos, unsigned int *count,
@@ -421,13 +421,14 @@ static int fpr_get_fpa(struct task_struc {return user_regset_copyout (pos, count, kbuf, ubuf, &target->thread.fpu, -0 ,sizeof (elf_fpregset_t)); +0 ,NUM_FPU_REGS *sizeof (elf_fpreg_t)); }/* * Copy the floating-point context to the supplied NT_PRFPREG buffer, * CONFIG_CPU_HAS_MSA variant. Only lower 64 bits of FP context's -* general register slots are copied to buffer slots. +* general register slots are copied to buffer slots. Only general +* registers are copied. */ static int fpr_get_msa(struct task_struct *target, unsigned int *pos, unsigned int *count,
@@ -449,20 +450,29 @@ static int fpr_get_msa(struct task_strucreturn 0 ; } -/* Copy the floating-point context to the supplied NT_PRFPREG buffer. */ +/* +* Copy the floating-point context to the supplied NT_PRFPREG buffer. +* Choose the appropriate helper for general registers, and then copy +* the FCSR register separately. +*/ static int fpr_get (struct task_struct *target,const struct user_regset *regset,unsigned int pos,unsigned int count,void *kbuf,void __user *ubuf) { +const int fcr31_pos =NUM_FPU_REGS *sizeof (elf_fpreg_t);int err; -/* XXX fcr31 */ -if (sizeof (target->thread.fpu.fpr[0 ]) ==sizeof (elf_fpreg_t)) err =fpr_get_fpa (target, &pos, &count, &kbuf, &ubuf);else err =fpr_get_msa (target, &pos, &count, &kbuf, &ubuf); +if (err) +return err; + + err =user_regset_copyout (&pos, &count, &kbuf, &ubuf, + &target->thread.fpu.fcr31, + fcr31_pos, fcr31_pos +sizeof (u32));return err; }
@@ -470,7 +480,7 @@ static int fpr_get(struct task_struct *t/* * Copy the supplied NT_PRFPREG buffer to the floating-point context, * !CONFIG_CPU_HAS_MSA variant. Buffer slots correspond 1:1 to FP -* context's general register slots. +* context's general register slots. Only general registers are copied. */ static int fpr_set_fpa(struct task_struct *target, unsigned int *pos, unsigned int *count,
@@ -478,13 +488,14 @@ static int fpr_set_fpa(struct task_struc {return user_regset_copyin (pos, count, kbuf, ubuf, &target->thread.fpu, -0 ,sizeof (elf_fpregset_t)); +0 ,NUM_FPU_REGS *sizeof (elf_fpreg_t)); }/* * Copy the supplied NT_PRFPREG buffer to the floating-point context, * CONFIG_CPU_HAS_MSA variant. Buffer slots are copied to lower 64 -* bits only of FP context's general register slots. +* bits only of FP context's general register slots. Only general +* registers are copied. */ static int fpr_set_msa(struct task_struct *target, unsigned int *pos, unsigned int *count,
@@ -509,6 +520,8 @@ static int fpr_set_msa(struct task_struc/* * Copy the supplied NT_PRFPREG buffer to the floating-point context. +* Choose the appropriate helper for general registers, and then copy +* the FCSR register separately. * * We optimize for the case where `count % sizeof(elf_fpreg_t) == 0', * which is supposed to have been guaranteed by the kernel before
@@ -521,18 +534,30 @@ static int fpr_set(struct task_struct *t unsigned int pos, unsigned int count, const void *kbuf, const void __user *ubuf) { + const int fcr31_pos = NUM_FPU_REGS * sizeof(elf_fpreg_t); +u32 fcr31;int err;BUG_ON (count %sizeof (elf_fpreg_t)); -/* XXX fcr31 */ -init_fp_ctx (target);if (sizeof (target->thread.fpu.fpr[0 ]) ==sizeof (elf_fpreg_t)) err =fpr_set_fpa (target, &pos, &count, &kbuf, &ubuf);else err =fpr_set_msa (target, &pos, &count, &kbuf, &ubuf); +if (err) +return err; + +if (count >0 ) { + err =user_regset_copyin (&pos, &count, &kbuf, &ubuf, + &fcr31, + fcr31_pos, fcr31_pos +sizeof (u32)); +if (err) +return err; + +ptrace_setfcr31 (target, fcr31); + }return err; }
Greg Kroah-Hartman
maintainerPATCH 12/118 MIPS: Also verify sizeof `elf_fpreg_t with PTRACE_SETREGSET
In reply to Greg Kroah-Hartman4.14-stable review patch. If anyone has any objections, please let me know.
------------------
From: Maciej W. Rozycki <[email protected]>
commit 006501e039eec411842bb3150c41358867d320c2 upstream.
Complement commit d614fd58a283 ("mips/ptrace: Preserve previous registers for short regset write") and like with the PTRACE_GETREGSET ptrace(2) request also apply a BUILD_BUG_ON check for the size of the `elf_fpreg_t' type in the PTRACE_SETREGSET request handler.
Patchwork: https://patchwork.linux-mips.org/patch/17929/
--- arch/mips/kernel/ptrace.c | 1 + 1 file changed, 1 insertion(+)
arch/mips/kernel/ptrace.c +1 -0
@@ -438,6 +438,7 @@ static int fpr_get_msa(struct task_strucu64 fpr_val;int err; +BUILD_BUG_ON (sizeof (fpr_val) !=sizeof (elf_fpreg_t));for (i =0 ; i <NUM_FPU_REGS ; i++) { fpr_val =get_fpr64 (&target->thread.fpu.fpr[i],0 ); err = user_regset_copyout(pos, count, kbuf, ubuf,
Greg Kroah-Hartman
maintainerPATCH 13/118 MIPS: Disallow outsized PTRACE_SETREGSET NT_PRFPREG regset accesses
In reply to Greg Kroah-Hartman4.14-stable review patch. If anyone has any objections, please let me know.
------------------
From: Maciej W. Rozycki <[email protected]>
commit c8c5a3a24d395b14447a9a89d61586a913840a3b upstream.
Complement commit c23b3d1a5311 ("MIPS: ptrace: Change GP regset to use correct core dump register layout") and also reject outsized PTRACE_SETREGSET requests to the NT_PRFPREG regset, like with the NT_PRSTATUS regset.
Patchwork: https://patchwork.linux-mips.org/patch/17930/
--- arch/mips/kernel/ptrace.c | 3 +++ 1 file changed, 3 insertions(+)
arch/mips/kernel/ptrace.c +3 -0
@@ -541,6 +541,9 @@ static int fpr_set(struct task_struct *tBUG_ON (count %sizeof (elf_fpreg_t)); +if (pos + count >sizeof (elf_fpregset_t)) +return -EIO ; +init_fp_ctx (target);if (sizeof (target->thread.fpu.fpr[0 ]) ==sizeof (elf_fpreg_t))
Greg Kroah-Hartman
maintainerPATCH 14/118 cgroup: fix css_task_iter crash on CSS_TASK_ITER_PROC
In reply to Greg Kroah-Hartman4.14-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tejun Heo <[email protected]>
commit 74d0833c659a8a54735e5efdd44f4b225af68586 upstream.
While teaching css_task_iter to handle skipping over tasks which aren't group leaders, bc2fb7ed089f ("cgroup: add @flags to css_task_iter_start() and implement CSS_TASK_ITER_PROCS") introduced a silly bug.
CSS_TASK_ITER_PROCS is implemented by repeating css_task_iter_advance() while the advanced cursor is pointing to a non-leader thread. However, the cursor variable, @l, wasn't updated when the iteration has to advance to the next css_set and the following repetition would operate on the terminal @l from the previous iteration which isn't pointing to a valid task leading to oopses like the following or infinite looping.
BUG: unable to handle kernel NULL pointer dereference at 0000000000000254 IP: __task_pid_nr_ns+0xc7/0xf0 PGD 0 P4D 0 Oops: 0000 [#1] SMP ... CPU: 2 PID: 1 Comm: systemd Not tainted 4.14.4-200.fc26.x86_64 #1 Hardware name: System manufacturer System Product Name/PRIME B350M-A, BIOS 3203 11/09/2017 task: ffff88c4baee8000 task.stack: ffff96d5c3158000 RIP: 0010:__task_pid_nr_ns+0xc7/0xf0 RSP: 0018:ffff96d5c315bd50 EFLAGS: 00010206 RAX: 0000000000000000 RBX: ffff88c4b68c6000 RCX: 0000000000000250 RDX: ffffffffa5e47960 RSI: 0000000000000000 RDI: ffff88c490f6ab00 RBP: ffff96d5c315bd50 R08: 0000000000001000 R09: 0000000000000005 R10: ffff88c4be006b80 R11: ffff88c42f1b8004 R12: ffff96d5c315bf18 R13: ffff88c42d7dd200 R14: ffff88c490f6a510 R15: ffff88c4b68c6000 FS: 00007f9446f8ea00(0000) GS:ffff88c4be680000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 0000000000000254 CR3: 00000007f956f000 CR4: 00000000003406e0 Call Trace: cgroup_procs_show+0x19/0x30 cgroup_seqfile_show+0x4c/0xb0 kernfs_seq_show+0x21/0x30 seq_read+0x2ec/0x3f0 kernfs_fop_read+0x134/0x180 __vfs_read+0x37/0x160 ? security_file_permission+0x9b/0xc0 vfs_read+0x8e/0x130 SyS_read+0x55/0xc0 entry_SYSCALL_64_fastpath+0x1a/0xa5 RIP: 0033:0x7f94455f942d RSP: 002b:00007ffe81ba2d00 EFLAGS: 00000293 ORIG_RAX: 0000000000000000 RAX: ffffffffffffffda RBX: 00005574e2233f00 RCX: 00007f94455f942d RDX: 0000000000001000 RSI: 00005574e2321a90 RDI: 000000000000002b RBP: 0000000000000000 R08: 00005574e2321a90 R09: 00005574e231de60 R10: 00007f94458c8b38 R11: 0000000000000293 R12: 00007f94458c8ae0 R13: 00007ffe81ba3800 R14: 0000000000000000 R15: 00005574e2116560 Code: 04 74 0e 89 f6 48 8d 04 76 48 8d 04 c5 f0 05 00 00 48 8b bf b8 05 00 00 48 01 c7 31 c0 48 8b 0f 48 85 c9 74 18 8b b2 30 08 00 00 <3b> 71 04 77 0d 48 c1 e6 05 48 01 f1 48 3b 51 38 74 09 5d c3 8b RIP: __task_pid_nr_ns+0xc7/0xf0 RSP: ffff96d5c315bd50
Fix it by moving the initialization of the cursor below the repeat label. While at it, rename it to @next for readability.
--- kernel/cgroup/cgroup.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-)
kernel/cgroup/cgroup.c +6 -8
@@ -4059,26 +4059,24 @@ static void css_task_iter_advance_css_sestatic void css_task_iter_advance (struct css_task_iter *it) { -struct list_head *l = it->task_pos; +struct list_head *next;lockdep_assert_held (&css_set_lock); -WARN_ON_ONCE (!l); - repeat:/* * Advance iterator to find next entry. cset->tasks is consumed * first and then ->mg_tasks. After ->mg_tasks, we move onto the * next cset. */ - l = l->next; + next = it->task_pos->next; -if (l == it->tasks_head) - l = it->mg_tasks_head->next; +if (next == it->tasks_head) + next = it->mg_tasks_head->next; -if (l == it->mg_tasks_head) +if (next == it->mg_tasks_head)css_task_iter_advance_css_set (it);else - it->task_pos = l; + it->task_pos = next;/* if PROCS, skip over tasks which aren't group leaders */ if ((it->flags & CSS_TASK_ITER_PROCS) && it->task_pos &&
Greg Kroah-Hartman
maintainerPATCH 15/118 kvm: vmx: Scrub hardware GPRs at VM-exit
In reply to Greg Kroah-Hartman4.14-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jim Mattson <[email protected]>
commit 0cb5b30698fdc8f6b4646012e3acb4ddce430788 upstream.
Guest GPR values are live in the hardware GPRs at VM-exit. Do not leave any guest values in hardware GPRs after the guest GPR values are saved to the vcpu_vmx structure.
This is a partial mitigation for CVE 2017-5715 and CVE 2017-5753. Specifically, it defeats the Project Zero PoC for CVE 2017-5715.
--- arch/x86/kvm/svm.c | 19 +++++++++++++++++++ arch/x86/kvm/vmx.c | 14 +++++++++++++- 2 files changed, 32 insertions(+), 1 deletion(-)
arch/x86/kvm/svm.c +19 -0
@@ -4965,6 +4965,25 @@ static void svm_vcpu_run(struct kvm_vcpu"mov %%r14, %c[r14](%[svm]) \n\t" "mov %%r15, %c[r15](%[svm]) \n\t"#endif +/* +* Clear host registers marked as clobbered to prevent +* speculative use. +*/ +"xor %%" _ASM_BX", %%" _ASM_BX" \n\t" +"xor %%" _ASM_CX", %%" _ASM_CX" \n\t" +"xor %%" _ASM_DX", %%" _ASM_DX" \n\t" +"xor %%" _ASM_SI", %%" _ASM_SI" \n\t" +"xor %%" _ASM_DI", %%" _ASM_DI" \n\t" +#ifdef CONFIG_X86_64 +"xor %%r8, %%r8 \n\t" +"xor %%r9, %%r9 \n\t" +"xor %%r10, %%r10 \n\t" +"xor %%r11, %%r11 \n\t" +"xor %%r12, %%r12 \n\t" +"xor %%r13, %%r13 \n\t" +"xor %%r14, %%r14 \n\t" +"xor %%r15, %%r15 \n\t" +#endif "pop %%" _ASM_BP : : [svm]"a"(svm),
arch/x86/kvm/vmx.c +13 -1
@@ -9405,6 +9405,7 @@ static void __noclone vmx_vcpu_run(struc/* Save guest registers, load host registers, keep flags */ "mov %0, %c[wordsize](%%" _ASM_SP") \n\t" "pop %0 \n\t" +"setbe %c[fail](%0)\n\t" "mov %%" _ASM_AX", %c[rax](%0) \n\t" "mov %%" _ASM_BX", %c[rbx](%0) \n\t" __ASM_SIZE(pop) " %c[rcx](%0) \n\t"
@@ -9421,12 +9422,23 @@ static void __noclone vmx_vcpu_run(struc"mov %%r13, %c[r13](%0) \n\t" "mov %%r14, %c[r14](%0) \n\t" "mov %%r15, %c[r15](%0) \n\t" +"xor %%r8d, %%r8d \n\t" +"xor %%r9d, %%r9d \n\t" +"xor %%r10d, %%r10d \n\t" +"xor %%r11d, %%r11d \n\t" +"xor %%r12d, %%r12d \n\t" +"xor %%r13d, %%r13d \n\t" +"xor %%r14d, %%r14d \n\t" + "xor %%r15d, %%r15d \n\t"#endif "mov %%cr2, %%" _ASM_AX" \n\t" "mov %%" _ASM_AX", %c[cr2](%0) \n\t" +"xor %%eax, %%eax \n\t" +"xor %%ebx, %%ebx \n\t" +"xor %%esi, %%esi \n\t" +"xor %%edi, %%edi \n\t" "pop %%" _ASM_BP"; pop %%" _ASM_DX" \n\t" -"setbe %c[fail](%0) \n\t" ".pushsection .rodata \n\t" ".global vmx_return \n\t" "vmx_return: " _ASM_PTR" 2b \n\t"
Greg Kroah-Hartman
maintainerPATCH 16/118 platform/x86: wmi: Call acpi_wmi_init() later
In reply to Greg Kroah-Hartman4.14-stable review patch. If anyone has any objections, please let me know.
------------------
From: Rafael J. Wysocki <[email protected]>
commit 98b8e4e5c17bf87c1b18ed929472051dab39878c upstream.
Calling acpi_wmi_init() at the subsys_initcall() level causes ordering issues to appear on some systems and they are difficult to reproduce, because there is no guaranteed ordering between subsys_initcall() calls, so they may occur in different orders on different systems.
In particular, commit 86d9f48534e8 (mm/slab: fix kmemcg cache creation delayed issue) exposed one of these issues where genl_init() and acpi_wmi_init() are both called at the same initcall level, but the former must run before the latter so as to avoid a NULL pointer dereference.
For this reason, move the acpi_wmi_init() invocation to the initcall_sync level which should still be early enough for things to work correctly in the WMI land.
--- drivers/platform/x86/wmi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/platform/x86/wmi.c +1 -1
@@ -1268,5 +1268,5 @@ static void __exit acpi_wmi_exit(void)bus_unregister (&wmi_bus_type); } -subsys_initcall (acpi_wmi_init); +subsys_initcall_sync (acpi_wmi_init);module_exit (acpi_wmi_exit);
Greg Kroah-Hartman
maintainerPATCH 17/118 iw_cxgb4: only call the cq comp_handler when the cq is armed
In reply to Greg Kroah-Hartman4.14-stable review patch. If anyone has any objections, please let me know.
------------------
From: Steve Wise <[email protected]>
commit cbb40fadd31c6bbc59104e58ac95c6ef492d038b upstream.
The ULPs completion handler should only be called if the CQ is armed for notification.
--- drivers/infiniband/hw/cxgb4/ev.c | 8 +++++--- drivers/infiniband/hw/cxgb4/qp.c | 20 ++++++++++++-------- 2 files changed, 17 insertions(+), 11 deletions(-)
drivers/infiniband/hw/cxgb4/ev.c +5 -3
@@ -109,9 +109,11 @@ static void post_qp_event(struct c4iw_deif (qhp->ibqp.event_handler) (*qhp->ibqp.event_handler)(&event, qhp->ibqp.qp_context); -spin_lock_irqsave (&chp->comp_handler_lock, flag); - (*chp->ibcq.comp_handler)(&chp->ibcq, chp->ibcq.cq_context); -spin_unlock_irqrestore (&chp->comp_handler_lock, flag); +if (t4_clear_cq_armed (&chp->cq)) { +spin_lock_irqsave (&chp->comp_handler_lock, flag); + (*chp->ibcq.comp_handler)(&chp->ibcq, chp->ibcq.cq_context); +spin_unlock_irqrestore (&chp->comp_handler_lock, flag); + } }void c4iw_ev_dispatch (struct c4iw_dev *dev,struct t4_cqe *err_cqe)
drivers/infiniband/hw/cxgb4/qp.c +12 -8
@@ -817,10 +817,12 @@ static void complete_sq_drain_wr(structt4_swcq_produce (cq);spin_unlock_irqrestore (&schp->lock, flag); -spin_lock_irqsave (&schp->comp_handler_lock, flag); - (*schp->ibcq.comp_handler)(&schp->ibcq, - schp->ibcq.cq_context); -spin_unlock_irqrestore (&schp->comp_handler_lock, flag); +if (t4_clear_cq_armed (&schp->cq)) { +spin_lock_irqsave (&schp->comp_handler_lock, flag); + (*schp->ibcq.comp_handler)(&schp->ibcq, + schp->ibcq.cq_context); +spin_unlock_irqrestore (&schp->comp_handler_lock, flag); + } }static void complete_rq_drain_wr (struct c4iw_qp *qhp,struct ib_recv_wr *wr)
@@ -846,10 +848,12 @@ static void complete_rq_drain_wr(structt4_swcq_produce (cq);spin_unlock_irqrestore (&rchp->lock, flag); -spin_lock_irqsave (&rchp->comp_handler_lock, flag); - (*rchp->ibcq.comp_handler)(&rchp->ibcq, - rchp->ibcq.cq_context); -spin_unlock_irqrestore (&rchp->comp_handler_lock, flag); +if (t4_clear_cq_armed (&rchp->cq)) { +spin_lock_irqsave (&rchp->comp_handler_lock, flag); + (*rchp->ibcq.comp_handler)(&rchp->ibcq, + rchp->ibcq.cq_context); +spin_unlock_irqrestore (&rchp->comp_handler_lock, flag); + } } int c4iw_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
Greg Kroah-Hartman
maintainerPATCH 18/118 iw_cxgb4: atomically flush the qp
In reply to Greg Kroah-Hartman4.14-stable review patch. If anyone has any objections, please let me know.
------------------
From: Steve Wise <[email protected]>
commit bc52e9ca74b9a395897bb640c6671b2cbf716032 upstream.
__flush_qp() has a race condition where during the flush operation, the qp lock is released allowing another thread to possibly post a WR, which corrupts the queue state, possibly causing crashes. The lock was released to preserve the cq/qp locking hierarchy of cq first, then qp. However releasing the qp lock is not necessary; both RQ and SQ CQ locks can be acquired first, followed by the qp lock, and then the RQ and SQ flushing can be done w/o unlocking.
--- drivers/infiniband/hw/cxgb4/qp.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-)
drivers/infiniband/hw/cxgb4/qp.c +11 -8
@@ -1271,31 +1271,34 @@ static void __flush_qp(struct c4iw_qp *qpr_debug ("%s qhp %p rchp %p schp %p\n" , __func__, qhp, rchp, schp); -/* locking hierarchy: cq lock first, then qp lock. */ +/* locking hierarchy: cqs lock first, then qp lock. */ spin_lock_irqsave (&rchp->lock, flag); +if (schp != rchp) +spin_lock (&schp->lock);spin_lock (&qhp->lock);if (qhp->wq.flushed) {spin_unlock (&qhp->lock); +if (schp != rchp) +spin_unlock (&schp->lock);spin_unlock_irqrestore (&rchp->lock, flag);return ; } qhp->wq.flushed =1 ; +t4_set_wq_in_error (&qhp->wq);c4iw_flush_hw_cq (rchp);c4iw_count_rcqes (&rchp->cq, &qhp->wq, &count); rq_flushed =c4iw_flush_rq (&qhp->wq, &rchp->cq, count); -spin_unlock (&qhp->lock); -spin_unlock_irqrestore (&rchp->lock, flag); -/* locking hierarchy: cq lock first, then qp lock. */ -spin_lock_irqsave (&schp->lock, flag); -spin_lock (&qhp->lock);if (schp != rchp)c4iw_flush_hw_cq (schp); sq_flushed =c4iw_flush_sq (qhp); +spin_unlock (&qhp->lock); -spin_unlock_irqrestore (&schp->lock, flag); +if (schp != rchp) +spin_unlock (&schp->lock); +spin_unlock_irqrestore (&rchp->lock, flag);if (schp == rchp) { if (t4_clear_cq_armed(&rchp->cq) &&
@@ -1329,8 +1332,8 @@ static void flush_qp(struct c4iw_qp *qhp rchp =to_c4iw_cq (qhp->ibqp.recv_cq); schp =to_c4iw_cq (qhp->ibqp.send_cq); -t4_set_wq_in_error (&qhp->wq);if (qhp->ibqp.uobject) { +t4_set_wq_in_error (&qhp->wq);t4_set_cq_in_error (&rchp->cq);spin_lock_irqsave (&rchp->comp_handler_lock, flag); (*rchp->ibcq.comp_handler)(&rchp->ibcq, rchp->ibcq.cq_context);
Greg Kroah-Hartman
maintainerPATCH 19/118 iw_cxgb4: only clear the ARMED bit if a notification is needed
In reply to Greg Kroah-Hartman4.14-stable review patch. If anyone has any objections, please let me know.
------------------
From: Steve Wise <[email protected]>
commit 335ebf6fa35ca1c59b73f76fad19b249d3550e86 upstream.
In __flush_qp(), the CQ ARMED bit was being cleared regardless of whether any notification is actually needed. This resulted in the iser termination logic getting stuck in ib_drain_sq() because the CQ was not marked ARMED and thus the drain CQE notification wasn't triggered.
This new bug was exposed when this commit was merged:
commit cbb40fadd31c ("iw_cxgb4: only call the cq comp_handler when the cq is armed")
--- drivers/infiniband/hw/cxgb4/qp.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/infiniband/hw/cxgb4/qp.c +4 -4
@@ -1301,21 +1301,21 @@ static void __flush_qp(struct c4iw_qp *qspin_unlock_irqrestore (&rchp->lock, flag);if (schp == rchp) { -if (t4_clear_cq_armed (&rchp->cq) && - (rq_flushed || sq_flushed)) { +if ((rq_flushed || sq_flushed) && +t4_clear_cq_armed (&rchp->cq)) {spin_lock_irqsave (&rchp->comp_handler_lock, flag); (*rchp->ibcq.comp_handler)(&rchp->ibcq, rchp->ibcq.cq_context);spin_unlock_irqrestore (&rchp->comp_handler_lock, flag); } }else { -if (t4_clear_cq_armed (&rchp->cq) && rq_flushed) { +if (rq_flushed &&t4_clear_cq_armed (&rchp->cq)) {spin_lock_irqsave (&rchp->comp_handler_lock, flag); (*rchp->ibcq.comp_handler)(&rchp->ibcq, rchp->ibcq.cq_context);spin_unlock_irqrestore (&rchp->comp_handler_lock, flag); } -if (t4_clear_cq_armed (&schp->cq) && sq_flushed) { +if (sq_flushed &&t4_clear_cq_armed (&schp->cq)) {spin_lock_irqsave (&schp->comp_handler_lock, flag); (*schp->ibcq.comp_handler)(&schp->ibcq, schp->ibcq.cq_context);
Greg Kroah-Hartman
maintainerPATCH 20/118 iw_cxgb4: reflect the original WR opcode in drain cqes
In reply to Greg Kroah-Hartman4.14-stable review patch. If anyone has any objections, please let me know.
------------------
From: Steve Wise <[email protected]>
commit 96a236ed286776554fbd227c6d2876fd3b5dc65d upstream.
The flush/drain logic was not retaining the original wr opcode in its completion. This can cause problems if the application uses the completion opcode to make decisions.
Use bit 10 of the CQE header word to indicate the CQE is a special drain completion, and save the original WR opcode in the cqe header opcode field.
--- drivers/infiniband/hw/cxgb4/cq.c | 7 +---- drivers/infiniband/hw/cxgb4/iw_cxgb4.h | 2 - drivers/infiniband/hw/cxgb4/qp.c | 46 ++++++++++++++++++++++++++++++--- drivers/infiniband/hw/cxgb4/t4.h | 6 ++++ 4 files changed, 50 insertions(+), 11 deletions(-)
drivers/infiniband/hw/cxgb4/cq.c +2 -5
@@ -410,7 +410,7 @@ next_cqe:static int cqe_completes_wr (struct t4_cqe *cqe,struct t4_wq *wq) { -if (CQE_OPCODE (cqe) ==C4IW_DRAIN_OPCODE ) { +if (DRAIN_CQE (cqe)) {WARN_ONCE (1 ,"Unexpected DRAIN CQE qp id %u!\n" , wq->sq.qid);return 0 ; }
@@ -509,7 +509,7 @@ static int poll_cq(struct t4_wq *wq, str/* * Special cqe for drain WR completions... */ -if (CQE_OPCODE (hw_cqe) ==C4IW_DRAIN_OPCODE ) { +if (DRAIN_CQE (hw_cqe)) { *cookie =CQE_DRAIN_COOKIE (hw_cqe); *cqe = *hw_cqe; goto skip_cqe;
@@ -766,9 +766,6 @@ static int c4iw_poll_cq_one(struct c4iw_c4iw_invalidate_mr (qhp->rhp,CQE_WRID_FR_STAG (&cqe));break ; -case C4IW_DRAIN_OPCODE : - wc->opcode =IB_WC_SEND ; -break ;default :pr_err ("Unexpected opcode %d in the CQE received for QPID=0x%0x\n" ,CQE_OPCODE (&cqe),CQE_QPID (&cqe));
drivers/infiniband/hw/cxgb4/iw_cxgb4.h +0 -2
@@ -631,8 +631,6 @@ static inline int to_ib_qp_state(int c4ireturn IB_QPS_ERR ; } -#define C4IW_DRAIN_OPCODE FW_RI_SGE_EC_CR_RETURN -static inline u32 c4iw_ib_to_tpt_access (int a) { return (a & IB_ACCESS_REMOTE_WRITE ? FW_RI_MEM_ACCESS_REM_WRITE : 0) |
drivers/infiniband/hw/cxgb4/qp.c +42 -4
85 lines not on this page · raw message
drivers/infiniband/hw/cxgb4/t4.h +6 -0
@@ -197,6 +197,11 @@ struct t4_cqe {#define CQE_SWCQE_G (x) ((((x) >> CQE_SWCQE_S)) & CQE_SWCQE_M)#define CQE_SWCQE_V (x) ((x)<<CQE_SWCQE_S) +#define CQE_DRAIN_S 10 +#define CQE_DRAIN_M 0x1 +#define CQE_DRAIN_G (x) ((((x) >> CQE_DRAIN_S)) & CQE_DRAIN_M) +#define CQE_DRAIN_V (x) ((x)<<CQE_DRAIN_S) +#define CQE_STATUS_S 5#define CQE_STATUS_M 0x1F#define CQE_STATUS_G (x) ((((x) >> CQE_STATUS_S)) & CQE_STATUS_M)
@@ -213,6 +218,7 @@ struct t4_cqe {#define CQE_OPCODE_V (x) ((x)<<CQE_OPCODE_S)#define SW_CQE (x) (CQE_SWCQE_G(be32_to_cpu((x)->header))) +#define DRAIN_CQE (x) (CQE_DRAIN_G(be32_to_cpu((x)->header)))#define CQE_QPID (x) (CQE_QPID_G(be32_to_cpu((x)->header)))#define CQE_TYPE (x) (CQE_TYPE_G(be32_to_cpu((x)->header)))#define SQ_TYPE (x) (CQE_TYPE((x)))
Greg Kroah-Hartman
maintainerPATCH 21/118 iw_cxgb4: when flushing, complete all wrs in a chain
In reply to Greg Kroah-Hartman4.14-stable review patch. If anyone has any objections, please let me know.
------------------
From: Steve Wise <[email protected]>
commit d14587334580bc94d3ee11e8320e0c157f91ae8f upstream.
If a wr chain was posted and needed to be flushed, only the first wr in the chain was completed with FLUSHED status. The rest were never completed. This caused isert to hang on shutdown due to the missing completions which left iscsi IO commands referenced, stalling the shutdown.
--- drivers/infiniband/hw/cxgb4/qp.c | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-)
drivers/infiniband/hw/cxgb4/qp.c +26 -2
@@ -862,6 +862,22 @@ static int complete_sq_drain_wr(struct creturn 0 ; } +static int complete_sq_drain_wrs (struct c4iw_qp *qhp,struct ib_send_wr *wr, +struct ib_send_wr **bad_wr) +{ +int ret =0 ; + +while (wr) { + ret =complete_sq_drain_wr (qhp, wr); +if (ret) { + *bad_wr = wr; +break ; + } + wr = wr->next; + } +return ret; +} +static void complete_rq_drain_wr (struct c4iw_qp *qhp,struct ib_recv_wr *wr) {struct t4_cqe cqe = {};
@@ -894,6 +910,14 @@ static void complete_rq_drain_wr(struct } } +static void complete_rq_drain_wrs (struct c4iw_qp *qhp,struct ib_recv_wr *wr) +{ +while (wr) { +complete_rq_drain_wr (qhp, wr); + wr = wr->next; + } +} +int c4iw_post_send (struct ib_qp *ibqp,struct ib_send_wr *wr,struct ib_send_wr **bad_wr) {
@@ -917,7 +941,7 @@ int c4iw_post_send(struct ib_qp *ibqp, s*/ if (qhp->wq.flushed) {spin_unlock_irqrestore (&qhp->lock, flag); - err =complete_sq_drain_wr (qhp, wr); + err =complete_sq_drain_wrs (qhp, wr, bad_wr);return err; } num_wrs =t4_sq_avail (&qhp->wq);
@@ -1066,7 +1090,7 @@ int c4iw_post_receive(struct ib_qp *ibqp*/ if (qhp->wq.flushed) {spin_unlock_irqrestore (&qhp->lock, flag); -complete_rq_drain_wr (qhp, wr); +complete_rq_drain_wrs (qhp, wr);return err; } num_wrs =t4_rq_avail (&qhp->wq);
Greg Kroah-Hartman
maintainerPATCH 22/118 x86/acpi: Handle SCI interrupts above legacy space gracefully
In reply to Greg Kroah-Hartman4.14-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vikas C Sajjan <[email protected]>
commit 252714155f04c5d16989cb3aadb85fd1b5772f99 upstream.
Platforms which support only IOAPIC mode, pass the SCI information above the legacy space (0-15) via the FADT mechanism and not via MADT.
In such cases mp_override_legacy_irq() which is invoked from acpi_sci_ioapic_setup() to register SCI interrupts fails for interrupts greater equal 16, since it is meant to handle only the legacy space and emits error "Invalid bus_irq %u for legacy override".
Add a new function to handle SCI interrupts >= 16 and invoke it conditionally in acpi_sci_ioapic_setup().
The code duplication due to this new function will be cleaned up in a separate patch.
--- arch/x86/kernel/acpi/boot.c | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-)
arch/x86/kernel/acpi/boot.c +33 -1
@@ -429,6 +429,34 @@ static int mp_config_acpi_gsi(struct devreturn 0 ; } +static int __init mp_register_ioapic_irq (u8 bus_irq,u8 polarity, +u8 trigger,u32 gsi) +{ +struct mpc_intsrc mp_irq; +int ioapic, pin; + +/* Convert 'gsi' to 'ioapic.pin'(INTIN#) */ + ioapic =mp_find_ioapic (gsi); +if (ioapic <0 ) { +pr_warn ("Failed to find ioapic for gsi : %u\n" , gsi); +return ioapic; + } + + pin =mp_find_ioapic_pin (ioapic, gsi); + + mp_irq.type =MP_INTSRC ; + mp_irq.irqtype = mp_INT; + mp_irq.irqflag = (trigger <<2 ) | polarity; + mp_irq.srcbus =MP_ISA_BUS ; + mp_irq.srcbusirq = bus_irq; + mp_irq.dstapic =mpc_ioapic_id (ioapic); + mp_irq.dstirq = pin; + +mp_save_irq (&mp_irq); + +return 0 ; +} +static int __init acpi_parse_ioapic (struct acpi_subtable_header * header,const unsigned long end) {
@@ -473,7 +501,11 @@ static void __init acpi_sci_ioapic_setupif (acpi_sci_flags &ACPI_MADT_POLARITY_MASK ) polarity = acpi_sci_flags &ACPI_MADT_POLARITY_MASK ; -mp_override_legacy_irq (bus_irq, polarity, trigger, gsi); +if (bus_irq <NR_IRQS_LEGACY ) +mp_override_legacy_irq (bus_irq, polarity, trigger, gsi); +else +mp_register_ioapic_irq (bus_irq, polarity, trigger, gsi); +acpi_penalize_sci_irq (bus_irq, trigger, polarity);/*
Greg Kroah-Hartman
maintainerPATCH 23/118 ALSA: pcm: Remove incorrect snd_BUG_ON() usages
In reply to Greg Kroah-Hartman4.14-stable review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
commit fe08f34d066f4404934a509b6806db1a4f700c86 upstream.
syzkaller triggered kernel warnings through PCM OSS emulation at closing a stream:
WARNING: CPU: 0 PID: 3502 at sound/core/pcm_lib.c:1635 snd_pcm_hw_param_first+0x289/0x690 sound/core/pcm_lib.c:1635 Call Trace: .... snd_pcm_hw_param_near.constprop.27+0x78d/0x9a0 sound/core/oss/pcm_oss.c:457 snd_pcm_oss_change_params+0x17d3/0x3720 sound/core/oss/pcm_oss.c:969 snd_pcm_oss_make_ready+0xaa/0x130 sound/core/oss/pcm_oss.c:1128 snd_pcm_oss_sync+0x257/0x830 sound/core/oss/pcm_oss.c:1638 snd_pcm_oss_release+0x20b/0x280 sound/core/oss/pcm_oss.c:2431 __fput+0x327/0x7e0 fs/file_table.c:210 ....
This happens while it tries to open and set up the aloop device concurrently. The warning above (invoked from snd_BUG_ON() macro) is to detect the unexpected logical error where snd_pcm_hw_refine() call shouldn't fail. The theory is true for the case where the hw_params config rules are static. But for an aloop device, the hw_params rule condition does vary dynamically depending on the connected target; when another device is opened and changes the parameters, the device connected in another side is also affected, and it caused the error from snd_pcm_hw_refine().
That is, the simplest "solution" for this is to remove the incorrect assumption of static rules, and treat such an error as a normal error path. As there are a couple of other places using snd_BUG_ON() incorrectly, this patch removes these spurious snd_BUG_ON() calls.
--- sound/core/oss/pcm_oss.c | 1 - sound/core/pcm_lib.c | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-)
sound/core/oss/pcm_oss.c +0 -1
@@ -455,7 +455,6 @@ static int snd_pcm_hw_param_near(struct v =snd_pcm_hw_param_last (pcm, params, var, dir); else v =snd_pcm_hw_param_first (pcm, params, var, dir); -snd_BUG_ON (v <0 );return v; }
sound/core/pcm_lib.c +2 -2
@@ -1632,7 +1632,7 @@ int snd_pcm_hw_param_first(struct snd_pcreturn changed;if (params->rmask) {int err =snd_pcm_hw_refine (pcm, params); -if (snd_BUG_ON (err <0 )) +if (err <0 )return err; }return snd_pcm_hw_param_value (params, var, dir);
@@ -1678,7 +1678,7 @@ int snd_pcm_hw_param_last(struct snd_pcmreturn changed;if (params->rmask) {int err =snd_pcm_hw_refine (pcm, params); -if (snd_BUG_ON (err <0 )) +if (err <0 )return err; }return snd_pcm_hw_param_value (params, var, dir);
Greg Kroah-Hartman
maintainerPATCH 24/118 ALSA: pcm: Workaround for weird PulseAudio behavior on rewind error
In reply to Greg Kroah-Hartman4.14-stable review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
commit fb51f1cd06f9ced7b7085a2a4636375d520431ca upstream.
The commit 9027c4639ef1 ("ALSA: pcm: Call ack() whenever appl_ptr is updated") introduced the possible error code returned from the PCM rewind ioctl. Basically the change was for handling the indirect PCM more correctly, but ironically, it caused rather a side-effect:
PulseAudio gets pissed off when receiving an error from rewind, throws everything away and stops processing further, resulting in the silence.
It's clearly a failure in the application side, so the best would be to fix that bug in PA. OTOH, PA is mostly the only user of the rewind feature, so it's not good to slap the sole customer.
This patch tries to mitigate the situation: instead of returning an error, now the rewind ioctl returns zero when the driver can't rewind. It indicates that no rewind was performed, so the behavior is consistent, at least.
--- sound/core/pcm_native.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
sound/core/pcm_native.c +7 -2
@@ -2582,7 +2582,7 @@ static snd_pcm_sframes_t forward_appl_ptreturn ret <0 ? ret : frames; } -/* decrease the appl_ptr; returns the processed frames or a negative error */ +/* decrease the appl_ptr; returns the processed frames or zero for error */ static snd_pcm_sframes_t rewind_appl_ptr (struct snd_pcm_substream *substream,snd_pcm_uframes_t frames,snd_pcm_sframes_t avail)
@@ -2599,7 +2599,12 @@ static snd_pcm_sframes_t rewind_appl_ptrif (appl_ptr <0 ) appl_ptr += runtime->boundary; ret =pcm_lib_apply_appl_ptr (substream, appl_ptr); -return ret <0 ? ret : frames; +/* NOTE: we return zero for errors because PulseAudio gets depressed +* upon receiving an error from rewind ioctl and stops processing +* any longer. Returning zero means that no rewind is done, so +* it's not absolutely wrong to answer like that. +*/ +return ret <0 ?0 : frames; } static snd_pcm_sframes_t snd_pcm_playback_rewind(struct snd_pcm_substream *substream,
Greg Kroah-Hartman
maintainerPATCH 25/118 ALSA: pcm: Add missing error checks in OSS emulation plugin builder
In reply to Greg Kroah-Hartman4.14-stable review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
commit 6708913750344a900f2e73bfe4a4d6dbbce4fe8d upstream.
In the OSS emulation plugin builder where the frame size is parsed in the plugin chain, some places miss the possible errors returned from the plugin src_ or dst_frames callback.
This patch papers over such places.
--- sound/core/oss/pcm_plugin.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-)
sound/core/oss/pcm_plugin.c +11 -3
@@ -592,18 +592,26 @@ snd_pcm_sframes_t snd_pcm_plug_write_trasnd_pcm_sframes_t frames = size; plugin =snd_pcm_plug_first (plug); -while (plugin && frames >0 ) { +while (plugin) { +if (frames <=0 ) +return frames;if ((next = plugin->next) !=NULL ) {snd_pcm_sframes_t frames1 = frames; -if (plugin->dst_frames) +if (plugin->dst_frames) { frames1 = plugin->dst_frames (plugin, frames); +if (frames1 <=0 ) +return frames1; + }if ((err = next->client_channels (next, frames1, &dst_channels)) <0 ) {return err; }if (err != frames1) { frames = err; -if (plugin->src_frames) +if (plugin->src_frames) { frames = plugin->src_frames (plugin, frames1); +if (frames <=0 ) +return frames; + } } }else dst_channels =NULL ;
Greg Kroah-Hartman
maintainerPATCH 26/118 ALSA: pcm: Abort properly at pending signal in OSS read/write loops
In reply to Greg Kroah-Hartman4.14-stable review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
commit 29159a4ed7044c52e3e2cf1a9fb55cec4745c60b upstream.
The loops for read and write in PCM OSS emulation have no proper check of pending signals, and they keep processing even after user tries to break. This results in a very long delay, often seen as RCU stall when a huge unprocessed bytes remain queued. The bug could be easily triggered by syzkaller.
As a simple workaround, this patch adds the proper check of pending signals and aborts the loop appropriately.
--- sound/core/oss/pcm_oss.c | 8 ++++++++ 1 file changed, 8 insertions(+)
sound/core/oss/pcm_oss.c +8 -0
@@ -1381,6 +1381,10 @@ static ssize_t snd_pcm_oss_write1(struct tmp != runtime->oss.period_bytes)break ; } +if (signal_pending (current)) { + tmp = -ERESTARTSYS ; + goto err; + } }mutex_unlock (&runtime->oss.params_lock);return xfer;
@@ -1466,6 +1470,10 @@ static ssize_t snd_pcm_oss_read1(struct bytes -= tmp; xfer += tmp; } +if (signal_pending (current)) { + tmp = -ERESTARTSYS ; + goto err; + } }mutex_unlock (&runtime->oss.params_lock);return xfer;
Greg Kroah-Hartman
maintainerPATCH 27/118 ALSA: pcm: Allow aborting mutex lock at OSS read/write loops
In reply to Greg Kroah-Hartman4.14-stable review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
commit 900498a34a3ac9c611e9b425094c8106bdd7dc1c upstream.
PCM OSS read/write loops keep taking the mutex lock for the whole read/write, and this might take very long when the exceptionally high amount of data is given. Also, since it invokes with mutex_lock(), the concurrent read/write becomes unbreakable.
This patch tries to address these issues by replacing mutex_lock() with mutex_lock_interruptible(), and also splits / re-takes the lock at each read/write period chunk, so that it can switch the context more finely if requested.
--- sound/core/oss/pcm_oss.c | 36 +++++++++++++++++++++--------------- 1 file changed, 21 insertions(+), 15 deletions(-)
sound/core/oss/pcm_oss.c +21 -15
@@ -1334,8 +1334,11 @@ static ssize_t snd_pcm_oss_write1(structif ((tmp =snd_pcm_oss_make_ready (substream)) <0 )return tmp; -mutex_lock (&runtime->oss.params_lock);while (bytes >0 ) { +if (mutex_lock_interruptible (&runtime->oss.params_lock)) { + tmp = -ERESTARTSYS ; +break ; + }if (bytes < runtime->oss.period_bytes || runtime->oss.buffer_used >0 ) { tmp = bytes;if (tmp + runtime->oss.buffer_used > runtime->oss.period_bytes)
@@ -1379,18 +1382,18 @@ static ssize_t snd_pcm_oss_write1(struct xfer += tmp;if ((substream->f_flags &O_NONBLOCK ) !=0 && tmp != runtime->oss.period_bytes) -break ; + tmp = -EAGAIN ; } + err: +mutex_unlock (&runtime->oss.params_lock); +if (tmp <0 ) +break ;if (signal_pending (current)) { tmp = -ERESTARTSYS ; - goto err; +break ; } + tmp =0 ; } -mutex_unlock (&runtime->oss.params_lock); -return xfer; - - err: -mutex_unlock (&runtime->oss.params_lock);return xfer >0 ? (snd_pcm_sframes_t )xfer : tmp; }
@@ -1438,8 +1441,11 @@ static ssize_t snd_pcm_oss_read1(structif ((tmp =snd_pcm_oss_make_ready (substream)) <0 )return tmp; -mutex_lock (&runtime->oss.params_lock);while (bytes >0 ) { +if (mutex_lock_interruptible (&runtime->oss.params_lock)) { + tmp = -ERESTARTSYS ; +break ; + }if (bytes < runtime->oss.period_bytes || runtime->oss.buffer_used >0 ) {if (runtime->oss.buffer_used ==0 ) { tmp =snd_pcm_oss_read2 (substream, runtime->oss.buffer, runtime->oss.period_bytes,1 );
@@ -1470,16 +1476,16 @@ static ssize_t snd_pcm_oss_read1(struct bytes -= tmp; xfer += tmp; } + err: +mutex_unlock (&runtime->oss.params_lock); +if (tmp <0 ) +break ;if (signal_pending (current)) { tmp = -ERESTARTSYS ; - goto err; +break ; } + tmp =0 ; } -mutex_unlock (&runtime->oss.params_lock); -return xfer; - - err: -mutex_unlock (&runtime->oss.params_lock);return xfer >0 ? (snd_pcm_sframes_t )xfer : tmp; }
Greg Kroah-Hartman
maintainerPATCH 28/118 ALSA: aloop: Release cable upon open error path
In reply to Greg Kroah-Hartman4.14-stable review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
commit 9685347aa0a5c2869058ca6ab79fd8e93084a67f upstream.
The aloop runtime object and its assignment in the cable are left even when opening a substream fails. This doesn't mean any memory leak, but it still keeps the invalid pointer that may be referred by the another side of the cable spontaneously, which is a potential Oops cause.
Clean up the cable assignment and the empty cable upon the error path properly.
--- sound/drivers/aloop.c | 38 +++++++++++++++++++++++++------------- 1 file changed, 25 insertions(+), 13 deletions(-)
sound/drivers/aloop.c +25 -13
@@ -658,12 +658,31 @@ static int rule_channels(struct snd_pcm_return snd_interval_refine (hw_param_interval (params, rule->var), &t); } +static void free_cable (struct snd_pcm_substream *substream) +{ +struct loopback *loopback = substream->private_data; +int dev =get_cable_index (substream); +struct loopback_cable *cable; + + cable = loopback->cables[substream->number][dev]; +if (!cable) +return ; +if (cable->streams[!substream->stream]) { +/* other stream is still alive */ + cable->streams[substream->stream] =NULL ; + }else { +/* free the cable */ + loopback->cables[substream->number][dev] =NULL ; +kfree (cable); + } +} +static int loopback_open (struct snd_pcm_substream *substream) {struct snd_pcm_runtime *runtime = substream->runtime;struct loopback *loopback = substream->private_data;struct loopback_pcm *dpcm; -struct loopback_cable *cable; +struct loopback_cable *cable =NULL ;int err =0 ;int dev =get_cable_index (substream);
@@ -682,7 +701,6 @@ static int loopback_open(struct snd_pcm_if (!cable) { cable =kzalloc (sizeof (*cable),GFP_KERNEL );if (!cable) { -kfree (dpcm); err = -ENOMEM ; goto unlock; }
@@ -724,6 +742,10 @@ static int loopback_open(struct snd_pcm_else runtime->hw = cable->hw; unlock: +if (err <0 ) { +free_cable (substream); +kfree (dpcm); + }mutex_unlock (&loopback->cable_lock);return err; }
@@ -732,20 +754,10 @@ static int loopback_close(struct snd_pcm {struct loopback *loopback = substream->private_data;struct loopback_pcm *dpcm = substream->runtime->private_data; -struct loopback_cable *cable; -int dev =get_cable_index (substream);loopback_timer_stop (dpcm);mutex_lock (&loopback->cable_lock); - cable = loopback->cables[substream->number][dev]; -if (cable->streams[!substream->stream]) { -/* other stream is still alive */ - cable->streams[substream->stream] =NULL ; - }else { -/* free the cable */ - loopback->cables[substream->number][dev] =NULL ; -kfree (cable); - } +free_cable (substream);mutex_unlock (&loopback->cable_lock);return 0 ; }
Greg Kroah-Hartman
maintainerPATCH 29/118 ALSA: aloop: Fix inconsistent format due to incomplete rule
In reply to Greg Kroah-Hartman4.14-stable review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
commit b088b53e20c7d09b5ab84c5688e609f478e5c417 upstream.
The extra hw constraint rule for the formats the aloop driver introduced has a slight flaw, where it doesn't return a positive value when the mask got changed. It came from the fact that it's basically a copy&paste from snd_hw_constraint_mask64(). The original code is supposed to be a single-shot and it modifies the mask bits only once and never after, while what we need for aloop is the dynamic hw rule that limits the mask bits.
This difference results in the inconsistent state, as the hw_refine doesn't apply the dependencies fully. The worse and surprisingly result is that it causes a crash in OSS emulation when multiple full-duplex reads/writes are performed concurrently (I leave why it triggers Oops to readers as a homework).
For fixing this, replace a few open-codes with the standard snd_mask_*() macros.
--- sound/drivers/aloop.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-)
sound/drivers/aloop.c +6 -7
@@ -39,6 +39,7 @@#include <sound/core.h> #include <sound/control.h> #include <sound/pcm.h> +#include <sound/pcm_params.h> #include <sound/info.h> #include <sound/initval.h>
@@ -622,14 +623,12 @@ static int rule_format(struct snd_pcm_hw {struct snd_pcm_hardware *hw = rule->private; -struct snd_mask *maskp =hw_param_mask (params, rule->var); +struct snd_mask m; - maskp->bits[0 ] &= (u_int32_t )hw->formats; - maskp->bits[1 ] &= (u_int32_t)(hw->formats >>32 ); -memset (maskp->bits +2 ,0 , (SNDRV_MASK_MAX -64 ) /8 );/* clear rest */ -if (! maskp->bits[0 ] && ! maskp->bits[1 ]) -return -EINVAL ; -return 0 ; +snd_mask_none (&m); + m.bits[0 ] = (u_int32_t )hw->formats; + m.bits[1 ] = (u_int32_t)(hw->formats >>32 ); +return snd_mask_refine (hw_param_mask (params, rule->var), &m); } static int rule_rate(struct snd_pcm_hw_params *params,
Greg Kroah-Hartman
maintainerPATCH 30/118 ALSA: aloop: Fix racy hw constraints adjustment
In reply to Greg Kroah-Hartman4.14-stable review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
commit 898dfe4687f460ba337a01c11549f87269a13fa2 upstream.
The aloop driver tries to update the hw constraints of the connected target on the cable of the opened PCM substream. This is done by adding the extra hw constraints rules referring to the substream runtime->hw fields, while the other substream may update the runtime hw of another side on the fly.
This is, however, racy and may result in the inconsistent values when both PCM streams perform the prepare concurrently. One of the reason is that it overwrites the other's runtime->hw field; which is not only racy but also broken when it's called before the open of another side finishes. And, since the reference to runtime->hw isn't protected, the concurrent write may give the partial value update and become inconsistent.
This patch is an attempt to fix and clean up:
- The prepare doesn't change the runtime->hw of other side any longer, but only update the cable->hw that is referred commonly.
- The extra rules refer to the loopback_pcm object instead of the runtime->hw. The actual hw is deduced from cable->hw.
- The extra rules take the cable_lock to protect against the race.
--- sound/drivers/aloop.c | 51 ++++++++++++++++++++------------------------------ 1 file changed, 21 insertions(+), 30 deletions(-)
sound/drivers/aloop.c +21 -30
@@ -306,19 +306,6 @@ static int loopback_trigger(struct snd_preturn 0 ; } -static void params_change_substream (struct loopback_pcm *dpcm, -struct snd_pcm_runtime *runtime) -{ -struct snd_pcm_runtime *dst_runtime; - -if (dpcm ==NULL || dpcm->substream ==NULL ) -return ; - dst_runtime = dpcm->substream->runtime; -if (dst_runtime ==NULL ) -return ; - dst_runtime->hw = dpcm->cable->hw; -} -static void params_change (struct snd_pcm_substream *substream) {struct snd_pcm_runtime *runtime = substream->runtime;
@@ -330,10 +317,6 @@ static void params_change(struct snd_pcm cable->hw.rate_max = runtime->rate; cable->hw.channels_min = runtime->channels; cable->hw.channels_max = runtime->channels; -params_change_substream (cable->streams[SNDRV_PCM_STREAM_PLAYBACK ], - runtime); -params_change_substream (cable->streams[SNDRV_PCM_STREAM_CAPTURE ], - runtime); }static int loopback_prepare (struct snd_pcm_substream *substream)
@@ -621,24 +604,29 @@ static unsigned int get_cable_index(strustatic int rule_format (struct snd_pcm_hw_params *params,struct snd_pcm_hw_rule *rule) { - -struct snd_pcm_hardware *hw = rule->private; +struct loopback_pcm *dpcm = rule->private; +struct loopback_cable *cable = dpcm->cable;struct snd_mask m;snd_mask_none (&m); - m.bits[0 ] = (u_int32_t )hw->formats; - m.bits[1 ] = (u_int32_t)(hw->formats >>32 ); +mutex_lock (&dpcm->loopback->cable_lock); + m.bits[0 ] = (u_int32_t )cable->hw.formats; + m.bits[1 ] = (u_int32_t)(cable->hw.formats >>32 ); +mutex_unlock (&dpcm->loopback->cable_lock);return snd_mask_refine (hw_param_mask (params, rule->var), &m); }static int rule_rate (struct snd_pcm_hw_params *params,struct snd_pcm_hw_rule *rule) { -struct snd_pcm_hardware *hw = rule->private; +struct loopback_pcm *dpcm = rule->private; +struct loopback_cable *cable = dpcm->cable;struct snd_interval t; - t.min = hw->rate_min; - t.max = hw->rate_max; +mutex_lock (&dpcm->loopback->cable_lock); + t.min = cable->hw.rate_min; + t.max = cable->hw.rate_max; +mutex_unlock (&dpcm->loopback->cable_lock); t.openmin = t.openmax =0 ; t.integer =0 ;return snd_interval_refine (hw_param_interval (params, rule->var), &t);
@@ -647,11 +635,14 @@ static int rule_rate(struct snd_pcm_hw_pstatic int rule_channels (struct snd_pcm_hw_params *params,struct snd_pcm_hw_rule *rule) { -struct snd_pcm_hardware *hw = rule->private; +struct loopback_pcm *dpcm = rule->private; +struct loopback_cable *cable = dpcm->cable;struct snd_interval t; - t.min = hw->channels_min; - t.max = hw->channels_max; +mutex_lock (&dpcm->loopback->cable_lock); + t.min = cable->hw.channels_min; + t.max = cable->hw.channels_max; +mutex_unlock (&dpcm->loopback->cable_lock); t.openmin = t.openmax =0 ; t.integer =0 ;return snd_interval_refine (hw_param_interval (params, rule->var), &t);
@@ -717,19 +708,19 @@ static int loopback_open(struct snd_pcm_/* are cached -> they do not reflect the actual state */ err =snd_pcm_hw_rule_add (runtime,0 ,SNDRV_PCM_HW_PARAM_FORMAT , - rule_format, &runtime->hw, + rule_format, dpcm,SNDRV_PCM_HW_PARAM_FORMAT ,-1 );if (err <0 ) goto unlock; err =snd_pcm_hw_rule_add (runtime,0 ,SNDRV_PCM_HW_PARAM_RATE , - rule_rate, &runtime->hw, + rule_rate, dpcm,SNDRV_PCM_HW_PARAM_RATE ,-1 );if (err <0 ) goto unlock; err =snd_pcm_hw_rule_add (runtime,0 ,SNDRV_PCM_HW_PARAM_CHANNELS , - rule_channels, &runtime->hw, + rule_channels, dpcm,SNDRV_PCM_HW_PARAM_CHANNELS ,-1 );if (err <0 ) goto unlock;
Greg Kroah-Hartman
maintainerPATCH 31/118 x86/acpi: Reduce code duplication in mp_override_legacy_irq()
In reply to Greg Kroah-Hartman4.14-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vikas C Sajjan <[email protected]>
commit 4ee2ec1b122599f7b10c849fa7915cebb37b7edb upstream.
The new function mp_register_ioapic_irq() is a subset of the code in mp_override_legacy_irq().
Replace the code duplication by invoking mp_register_ioapic_irq() from mp_override_legacy_irq().
--- arch/x86/kernel/acpi/boot.c | 27 +++++---------------------- 1 file changed, 5 insertions(+), 22 deletions(-)
arch/x86/kernel/acpi/boot.c +5 -22
@@ -342,13 +342,12 @@ acpi_parse_lapic_nmi(struct acpi_subtabl#ifdef CONFIG_X86_IO_APIC #define MP_ISA_BUS 0 +static int __init mp_register_ioapic_irq (u8 bus_irq,u8 polarity, +u8 trigger,u32 gsi); +static void __init mp_override_legacy_irq (u8 bus_irq,u8 polarity,u8 trigger,u32 gsi) { -int ioapic; -int pin; -struct mpc_intsrc mp_irq; -/* * Check bus_irq boundary. */
@@ -358,14 +357,6 @@ static void __init mp_override_legacy_ir }/* -* Convert 'gsi' to 'ioapic.pin'. -*/ - ioapic =mp_find_ioapic (gsi); -if (ioapic <0 ) -return ; - pin =mp_find_ioapic_pin (ioapic, gsi); - -/* * TBD: This check is for faulty timer entries, where the override * erroneously sets the trigger to level, resulting in a HUGE * increase of timer interrupts!
@@ -373,16 +364,8 @@ static void __init mp_override_legacy_irif ((bus_irq ==0 ) && (trigger ==3 )) trigger =1 ; - mp_irq.type =MP_INTSRC ; - mp_irq.irqtype = mp_INT; - mp_irq.irqflag = (trigger <<2 ) | polarity; - mp_irq.srcbus =MP_ISA_BUS ; - mp_irq.srcbusirq = bus_irq;/* IRQ */ - mp_irq.dstapic =mpc_ioapic_id (ioapic);/* APIC ID */ - mp_irq.dstirq = pin;/* INTIN# */ - -mp_save_irq (&mp_irq); - +if (mp_register_ioapic_irq (bus_irq, polarity, trigger, gsi) <0 ) +return ;/* * Reset default identity mapping if gsi is also an legacy IRQ, * otherwise there will be more than one entry with the same GSI
Greg Kroah-Hartman
maintainerPATCH 32/118 8021q: fix a memory leak for VLAN 0 device
In reply to Greg Kroah-Hartman4.14-stable review patch. If anyone has any objections, please let me know.
------------------
From: Cong Wang <[email protected]>
[ Upstream commit 78bbb15f2239bc8e663aa20bbe1987c91a0b75f6 ]
A vlan device with vid 0 is allow to creat by not able to be fully cleaned up by unregister_vlan_dev() which checks for vlan_id!=0.
Also, VLAN 0 is probably not a valid number and it is kinda "reserved" for HW accelerating devices, but it is probably too late to reject it from creation even if makes sense. Instead, just remove the check in unregister_vlan_dev().
--- net/8021q/vlan.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-)
net/8021q/vlan.c +1 -6
@@ -111,12 +111,7 @@ void unregister_vlan_dev(struct net_devivlan_gvrp_uninit_applicant (real_dev); } -/* Take it out of our own structures, but be sure to interlock with -* HW accelerating devices or SW vlan input packet processing if -* VLAN is not 0 (leave it there for 802.1p). -*/ -if (vlan_id) -vlan_vid_del (real_dev, vlan->vlan_proto, vlan_id); +vlan_vid_del (real_dev, vlan->vlan_proto, vlan_id);/* Get rid of the vlan's reference to real_dev */ dev_put (real_dev);
Greg Kroah-Hartman
maintainerPATCH 33/118 ip6_tunnel: disable dst caching if tunnel is dual-stack
In reply to Greg Kroah-Hartman4.14-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eli Cooper <[email protected]>
[ Upstream commit 23263ec86a5f44312d2899323872468752324107 ]
When an ip6_tunnel is in mode 'any', where the transport layer protocol can be either 4 or 41, dst_cache must be disabled.
This is because xfrm policies might apply to only one of the two protocols. Caching dst would cause xfrm policies for one protocol incorrectly used for the other.
--- net/ipv6/ip6_tunnel.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
net/ipv6/ip6_tunnel.c +5 -4
@@ -1081,10 +1081,11 @@ int ip6_tnl_xmit(struct sk_buff *skb, stmemcpy (&fl6->daddr, addr6,sizeof (fl6->daddr));neigh_release (neigh); } - }else if (!(t->parms.flags & - (IP6_TNL_F_USE_ORIG_TCLASS |IP6_TNL_F_USE_ORIG_FWMARK ))) { -/* enable the cache only only if the routing decision does -* not depend on the current inner header value + }else if (t->parms.proto !=0 && !(t->parms.flags & + (IP6_TNL_F_USE_ORIG_TCLASS | +IP6_TNL_F_USE_ORIG_FWMARK ))) { +/* enable the cache only if neither the outer protocol nor the +* routing decision depends on the current inner header value */ use_cache = true; }
Greg Kroah-Hartman
maintainerPATCH 34/118 net: core: fix module type in sock_diag_bind
In reply to Greg Kroah-Hartman4.14-stable review patch. If anyone has any objections, please let me know.
------------------
From: Andrii Vladyka <[email protected]>
[ Upstream commit b8fd0823e0770c2d5fdbd865bccf0d5e058e5287 ]
Use AF_INET6 instead of AF_INET in IPv6-related code path
--- net/core/sock_diag.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/core/sock_diag.c +1 -1
@@ -288,7 +288,7 @@ static int sock_diag_bind(struct net *necase SKNLGRP_INET6_UDP_DESTROY :if (!sock_diag_handlers[AF_INET6 ])request_module ("net-pf-%d-proto-%d-type-%d" ,PF_NETLINK , -NETLINK_SOCK_DIAG ,AF_INET ); +NETLINK_SOCK_DIAG ,AF_INET6 );break ; }return 0 ;
Greg Kroah-Hartman
maintainerPATCH 35/118 phylink: ensure we report link down when LOS asserted
In reply to Greg Kroah-Hartman4.14-stable review patch. If anyone has any objections, please let me know.
------------------
From: Russell King <[email protected]>
[ Upstream commit ac817f5ad066697e4d4d35ec68c974eba2c5f17a ]
Although we disable the netdev carrier, we fail to report in the kernel log that the link went down. Fix this.
--- drivers/net/phy/phylink.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/net/phy/phylink.c +1 -2
@@ -1428,9 +1428,8 @@ static void phylink_sfp_link_down(void *WARN_ON (!lockdep_rtnl_is_held ());set_bit (PHYLINK_DISABLE_LINK , &pl->phylink_disable_state); +queue_work (system_power_efficient_wq, &pl->resolve);flush_work (&pl->resolve); - -netif_carrier_off (pl->netdev); }static void phylink_sfp_link_up (void *upstream)
Greg Kroah-Hartman
maintainerPATCH 36/118 RDS: Heap OOB write in rds_message_alloc_sgs()
In reply to Greg Kroah-Hartman4.14-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mohamed Ghannam <[email protected]>
[ Upstream commit c095508770aebf1b9218e77026e48345d719b17c ]
When args->nr_local is 0, nr_pages gets also 0 due some size calculation via rds_rm_size(), which is later used to allocate pages for DMA, this bug produces a heap Out-Of-Bound write access to a specific memory region.
--- net/rds/rdma.c | 3 +++ 1 file changed, 3 insertions(+)
net/rds/rdma.c +3 -0
@@ -525,6 +525,9 @@ int rds_rdma_extra_size(struct rds_rdma_ local_vec = (struct rds_iovec __user *)(unsigned long ) args->local_vec_addr; +if (args->nr_local ==0 ) +return -EINVAL ; +/* figure out the number of pages in the vector */ for (i =0 ; i < args->nr_local; i++) { if (copy_from_user(&vec, &local_vec[i],
Greg Kroah-Hartman
maintainerPATCH 37/118 RDS: null pointer dereference in rds_atomic_free_op
In reply to Greg Kroah-Hartman4.14-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mohamed Ghannam <[email protected]>
[ Upstream commit 7d11f77f84b27cef452cee332f4e469503084737 ]
set rm->atomic.op_active to 0 when rds_pin_pages() fails or the user supplied address is invalid,
this prevents a NULL pointer usage in rds_atomic_free_op()
--- net/rds/rdma.c | 1 + 1 file changed, 1 insertion(+)
net/rds/rdma.c +1 -0
@@ -877,6 +877,7 @@ int rds_cmsg_atomic(struct rds_sock *rs, err:if (page)put_page (page); + rm->atomic.op_active =0 ;kfree (rm->atomic.op_notifier);return ret;
Greg Kroah-Hartman
maintainerPATCH 38/118 net: fec: restore dev_id in the cases of probe error
In reply to Greg Kroah-Hartman4.14-stable review patch. If anyone has any objections, please let me know.
------------------
From: Fugang Duan <[email protected]>
[ Upstream commit e90f686b4358d7d7e5dbaa48b8e78c9a4e41826e ]
The static variable dev_id always plus one before netdev registerred. It should restore the dev_id value in the cases of probe error.
--- drivers/net/ethernet/freescale/fec_main.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/ethernet/freescale/fec_main.c +1 -0
@@ -3543,6 +3543,7 @@ failed_phy:of_node_put (phy_node); failed_ioremap:free_netdev (ndev); + dev_id--;return ret; }
Greg Kroah-Hartman
maintainerPATCH 39/118 net: fec: defer probe if regulator is not ready
In reply to Greg Kroah-Hartman4.14-stable review patch. If anyone has any objections, please let me know.
------------------
From: Fugang Duan <[email protected]>
[ Upstream commit 3f38c683033a9a0a2738e7067f449deefabfa3ef ]
Defer probe if regulator is not ready. E.g. some regulator is fixed regulator controlled by i2c expander gpio, the i2c device may be probed after the driver, then it should handle the case of defer probe error.
--- drivers/net/ethernet/freescale/fec_main.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/net/ethernet/freescale/fec_main.c +4 -0
@@ -3458,6 +3458,10 @@ fec_probe(struct platform_device *pdev) goto failed_regulator; } }else { +if (PTR_ERR (fep->reg_phy) == -EPROBE_DEFER ) { + ret = -EPROBE_DEFER ; + goto failed_regulator; + } fep->reg_phy =NULL ; }
Greg Kroah-Hartman
maintainerPATCH 40/118 net: fec: free/restore resource in related probe error pathes
In reply to Greg Kroah-Hartman4.14-stable review patch. If anyone has any objections, please let me know.
------------------
From: Fugang Duan <[email protected]>
[ Upstream commit d1616f07e8f1a4a490d1791316d4a68906b284aa ]
Fixes in probe error path:
- Restore dev_id before failed_ioremap path.
Fixes: ("net: fec: restore dev_id in the cases of probe error")
- Call of_node_put(phy_node) before failed_phy path.
Fixes: ("net: fec: Support phys probed from devicetree and fixed-link")
--- drivers/net/ethernet/freescale/fec_main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/ethernet/freescale/fec_main.c +2 -2
@@ -3543,11 +3543,11 @@ failed_clk_ipg: failed_clk:if (of_phy_is_fixed_link (np))of_phy_deregister_fixed_link (np); -failed_phy:of_node_put (phy_node); +failed_phy: + dev_id--; failed_ioremap:free_netdev (ndev); - dev_id--;return ret; }
Greg Kroah-Hartman
maintainerPATCH 41/118 sctp: do not retransmit upon FragNeeded if PMTU discovery is disabled
In reply to Greg Kroah-Hartman4.14-stable review patch. If anyone has any objections, please let me know.
------------------
From: Marcelo Ricardo Leitner <[email protected]>
[ Upstream commit cc35c3d1edf7a8373a1a5daa80a912dec96a9cd5 ]
Currently, if PMTU discovery is disabled on a given transport, but the configured value is higher than the actual PMTU, it is likely that we will get some icmp Frag Needed. The issue is, if PMTU discovery is disabled, we won't update the information and will issue a retransmission immediately, which may very well trigger another ICMP, and another retransmission, leading to a loop.
The fix is to simply not trigger immediate retransmissions if PMTU discovery is disabled on the given transport.
Changes from v2:
- updated stale comment, noticed by Xin Long
--- net/sctp/input.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-)
net/sctp/input.c +12 -12
@@ -399,20 +399,20 @@ void sctp_icmp_frag_needed(struct sock *return ; } -if (t->param_flags &SPP_PMTUD_ENABLE ) { -/* Update transports view of the MTU */ -sctp_transport_update_pmtu (t, pmtu); +if (!(t->param_flags &SPP_PMTUD_ENABLE )) +/* We can't allow retransmitting in such case, as the +* retransmission would be sized just as before, and thus we +* would get another icmp, and retransmit again. +*/ +return ; -/* Update association pmtu. */ -sctp_assoc_sync_pmtu (asoc); - } +/* Update transports view of the MTU */ +sctp_transport_update_pmtu (t, pmtu); + +/* Update association pmtu. */ +sctp_assoc_sync_pmtu (asoc); -/* Retransmit with the new pmtu setting. -* Normally, if PMTU discovery is disabled, an ICMP Fragmentation -* Needed will never be sent, but if a message was sent before -* PMTU discovery was disabled that was larger than the PMTU, it -* would not be fragmented, so it must be re-transmitted fragmented. -*/ +/* Retransmit with the new pmtu setting. */ sctp_retransmit (&asoc->outqueue, t,SCTP_RTXR_PMTUD ); }
Greg Kroah-Hartman
maintainerPATCH 42/118 sctp: fix the handling of ICMP Frag Needed for too small MTUs
In reply to Greg Kroah-Hartman4.14-stable review patch. If anyone has any objections, please let me know.
------------------
From: Marcelo Ricardo Leitner <[email protected]>
[ Upstream commit b6c5734db07079c9410147b32407f2366d584e6c ]
syzbot reported a hang involving SCTP, on which it kept flooding dmesg with the message:
[ 246.742374] sctp: sctp_transport_update_pmtu: Reported pmtu 508 too
low, using default minimum of 512
That happened because whenever SCTP hits an ICMP Frag Needed, it tries to adjust to the new MTU and triggers an immediate retransmission. But it didn't consider the fact that MTUs smaller than the SCTP minimum MTU allowed (512) would not cause the PMTU to change, and issued the retransmission anyway (thus leading to another ICMP Frag Needed, and so on).
As IPv4 (ip_rt_min_pmtu=556) and IPv6 (IPV6_MIN_MTU=1280) minimum MTU are higher than that, sctp_transport_update_pmtu() is changed to re-fetch the PMTU that got set after our request, and with that, detect if there was an actual change or not.
The fix, thus, skips the immediate retransmission if the received ICMP resulted in no change, in the hope that SCTP will select another path.
Note: The value being used for the minimum MTU (512, SCTP_DEFAULT_MINSEGMENT) is not right and instead it should be (576, SCTP_MIN_PMTU), but such change belongs to another patch.
Changes from v1:
- do not disable PMTU discovery, in the light of commit 06ad391919b2 ("[SCTP] Don't disable PMTU discovery when mtu is small") and as suggested by Xin Long.
- changed the way to break the rtx loop by detecting if the icmp resulted in a change or not
Changes from v2:
none
See-also: https://lkml.org/lkml/2017/12/22/811
--- include/net/sctp/structs.h | 2 +- net/sctp/input.c | 8 ++++++-- net/sctp/transport.c | 29 +++++++++++++++++++---------- 3 files changed, 26 insertions(+), 13 deletions(-)
include/net/sctp/structs.h +1 -1
@@ -955,7 +955,7 @@ void sctp_transport_burst_limited(structvoid sctp_transport_burst_reset (struct sctp_transport *);unsigned long sctp_transport_timeout (struct sctp_transport *);void sctp_transport_reset (struct sctp_transport *t); -void sctp_transport_update_pmtu (struct sctp_transport *t,u32 pmtu); +bool sctp_transport_update_pmtu (struct sctp_transport *t,u32 pmtu);void sctp_transport_immediate_rtx (struct sctp_transport *);void sctp_transport_dst_release (struct sctp_transport *t);void sctp_transport_dst_confirm (struct sctp_transport *t);
net/sctp/input.c +6 -2
@@ -406,8 +406,12 @@ void sctp_icmp_frag_needed(struct sock **/ return ; -/* Update transports view of the MTU */ -sctp_transport_update_pmtu (t, pmtu); +/* Update transports view of the MTU. Return if no update was needed. +* If an update wasn't needed/possible, it also doesn't make sense to +* try to retransmit now. +*/ +if (!sctp_transport_update_pmtu (t, pmtu)) +return ;/* Update association pmtu. */ sctp_assoc_sync_pmtu (asoc);
net/sctp/transport.c +19 -10
@@ -251,28 +251,37 @@ void sctp_transport_pmtu(struct sctp_tra transport->pathmtu =SCTP_DEFAULT_MAXSEGMENT ; } -void sctp_transport_update_pmtu (struct sctp_transport *t,u32 pmtu) +bool sctp_transport_update_pmtu (struct sctp_transport *t,u32 pmtu) {struct dst_entry *dst =sctp_transport_dst_check (t); +bool change = true;if (unlikely (pmtu <SCTP_DEFAULT_MINSEGMENT )) { -pr_warn ("%s: Reported pmtu %d too low, using default minimum of %d\n" , - __func__, pmtu,SCTP_DEFAULT_MINSEGMENT ); -/* Use default minimum segment size and disable -* pmtu discovery on this transport. -*/ - t->pathmtu =SCTP_DEFAULT_MINSEGMENT ; - }else { - t->pathmtu = pmtu; +pr_warn_ratelimited ("%s: Reported pmtu %d too low, using default minimum of %d\n" , + __func__, pmtu,SCTP_DEFAULT_MINSEGMENT ); +/* Use default minimum segment instead */ + pmtu =SCTP_DEFAULT_MINSEGMENT ; } + pmtu =SCTP_TRUNC4 (pmtu);if (dst) { dst->ops->update_pmtu (dst, t->asoc->base.sk,NULL , pmtu); dst =sctp_transport_dst_check (t); } -if (!dst) +if (!dst) { t->af_specific->get_dst (t, &t->saddr, &t->fl, t->asoc->base.sk); + dst = t->dst; + } + +if (dst) { +/* Re-fetch, as under layers may have a higher minimum size */ + pmtu =SCTP_TRUNC4 (dst_mtu (dst)); + change = t->pathmtu != pmtu; + } + t->pathmtu = pmtu; + +return change; }/* Caches the dst entry and source address for a transport's destination
Greg Kroah-Hartman
maintainerPATCH 43/118 sh_eth: fix TSU resource handling
In reply to Greg Kroah-Hartman4.14-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sergei Shtylyov <[email protected]>
[ Upstream commit dfe8266b8dd10e12a731c985b725fcf7f0e537f0 ]
When switching the driver to the managed device API, I managed to break the case of a dual Ether devices sharing a single TSU: the 2nd Ether port wouldn't probe. Iwamatsu-san has tried to fix this but his patch was buggy and he then dropped the ball...
The solution is to limit calling devm_request_mem_region() to the first of the two ports sharing the same TSU, so devm_ioremap_resource() can't be used anymore for the TSU resource...
--- drivers/net/ethernet/renesas/sh_eth.c | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-)
drivers/net/ethernet/renesas/sh_eth.c +22 -3
@@ -3212,10 +3212,29 @@ static int sh_eth_drv_probe(struct platf/* ioremap the TSU registers */ if (mdp->cd->tsu) {struct resource *rtsu; + rtsu =platform_get_resource (pdev,IORESOURCE_MEM ,1 ); - mdp->tsu_addr =devm_ioremap_resource (&pdev->dev, rtsu); -if (IS_ERR (mdp->tsu_addr)) { - ret =PTR_ERR (mdp->tsu_addr); +if (!rtsu) { +dev_err (&pdev->dev,"no TSU resource\n" ); + ret = -ENODEV ; + goto out_release; + } +/* We can only request the TSU region for the first port +* of the two sharing this TSU for the probe to succeed... +*/ +if (devno %2 ==0 && + !devm_request_mem_region (&pdev->dev, rtsu->start, +resource_size (rtsu), +dev_name (&pdev->dev))) { +dev_err (&pdev->dev,"can't request TSU resource.\n" ); + ret = -EBUSY ; + goto out_release; + } + mdp->tsu_addr =devm_ioremap (&pdev->dev, rtsu->start, +resource_size (rtsu)); +if (!mdp->tsu_addr) { +dev_err (&pdev->dev,"TSU region ioremap() failed.\n" ); + ret = -ENOMEM ; goto out_release; } mdp->port = devno %2 ;
Greg Kroah-Hartman
maintainerPATCH 44/118 net: stmmac: enable EEE in MII, GMII or RGMII only
In reply to Greg Kroah-Hartman4.14-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jerome Brunet <[email protected]>
[ Upstream commit 879626e3a52630316d817cbda7cec9a5446d1d82 ]
Note in the databook - Section 4.4 - EEE :
" The EEE feature is not supported when the MAC is configured to use the TBI, RTBI, SMII, RMII or SGMII single PHY interface. Even if the MAC supports multiple PHY interfaces, you should activate the EEE mode only when the MAC is operating with GMII, MII, or RGMII interface."
Applying this restriction solves a stability issue observed on Amlogic gxl platforms operating with RMII interface and the internal PHY.
--- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +6 -0
@@ -364,9 +364,15 @@ static void stmmac_eee_ctrl_timer(unsignbool stmmac_eee_init (struct stmmac_priv *priv) {struct net_device *ndev = priv->dev; +int interface = priv->plat->interface;unsigned long flags;bool ret = false; +if ((interface !=PHY_INTERFACE_MODE_MII ) && + (interface !=PHY_INTERFACE_MODE_GMII ) && + !phy_interface_mode_is_rgmii (interface)) + goto out; +/* Using PCS we cannot dial with the phy registers at this stage * so we do not support extra feature like EEE. */
Greg Kroah-Hartman
maintainerPATCH 45/118 sh_eth: fix SH7757 GEther initialization
In reply to Greg Kroah-Hartman4.14-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sergei Shtylyov <[email protected]>
[ Upstream commit 5133550296d43236439494aa955bfb765a89f615 ]
Renesas SH7757 has 2 Fast and 2 Gigabit Ether controllers, while the 'sh_eth' driver can only reset and initialize TSU of the first controller pair. Shimoda-san tried to solve that adding the 'needs_init' member to the 'struct sh_eth_plat_data', however the platform code still never sets this flag. I think that we can infer this information from the 'devno' variable (set to 'platform_device::id') and reset/init the Ether controller pair only for an even 'devno'; therefore 'sh_eth_plat_data::needs_init' can be removed...
--- drivers/net/ethernet/renesas/sh_eth.c | 4 ++-- include/linux/sh_eth.h | 1 - 2 files changed, 2 insertions(+), 3 deletions(-)
drivers/net/ethernet/renesas/sh_eth.c +2 -2
@@ -3241,8 +3241,8 @@ static int sh_eth_drv_probe(struct platf ndev->features =NETIF_F_HW_VLAN_CTAG_FILTER ; } -/* initialize first or needed device */ -if (!devno || pd->needs_init) { +/* Need to init only the first port of the two sharing a TSU */ +if (devno %2 ==0 ) {if (mdp->cd->chip_reset) mdp->cd->chip_reset (ndev);
include/linux/sh_eth.h +0 -1
@@ -17,7 +17,6 @@ struct sh_eth_plat_data {unsigned char mac_addr[ETH_ALEN ]; unsigned no_ether_link:1; unsigned ether_link_active_low:1; - unsigned needs_init:1; };#endif
Greg Kroah-Hartman
maintainerPATCH 46/118 ipv6: fix possible mem leaks in ipv6_make_skb()
In reply to Greg Kroah-Hartman4.14-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Dumazet <[email protected]>
[ Upstream commit 862c03ee1deb7e19e0f9931682e0294ecd1fcaf9 ]
ip6_setup_cork() might return an error, while memory allocations have been done and must be rolled back.
--- net/ipv6/ip6_output.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
net/ipv6/ip6_output.c +3 -2
@@ -1735,9 +1735,10 @@ struct sk_buff *ip6_make_skb(struct sock cork.base.opt =NULL ; v6_cork.opt =NULL ; err =ip6_setup_cork (sk, &cork, &v6_cork, ipc6, rt, fl6); -if (err) +if (err) { +ip6_cork_release (&cork, &v6_cork);return ERR_PTR (err); - + }if (ipc6->dontfrag <0 ) ipc6->dontfrag =inet6_sk (sk)->dontfrag;
Greg Kroah-Hartman
maintainerPATCH 47/118 ethtool: do not print warning for applications using legacy API
In reply to Greg Kroah-Hartman4.14-stable review patch. If anyone has any objections, please let me know.
------------------
From: Stephen Hemminger <[email protected]>
[ Upstream commit 71891e2dab6b55a870f8f7735e44a2963860b5c6 ]
In kernel log ths message appears on every boot:
"warning: `NetworkChangeNo' uses legacy ethtool link settings API,
link modes are only partially reported"
When ethtool link settings API changed, it started complaining about usages of old API. Ironically, the original patch was from google but the application using the legacy API is chrome.
Linux ABI is fixed as much as possible. The kernel must not break it and should not complain about applications using legacy API's. This patch just removes the warning since using legacy API's in Linux is perfectly acceptable.
--- net/core/ethtool.c | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-)
net/core/ethtool.c +2 -13
@@ -754,15 +754,6 @@ static int ethtool_set_link_ksettings(streturn dev->ethtool_ops->set_link_ksettings (dev, &link_ksettings); } -static void -warn_incomplete_ethtool_legacy_settings_conversion (const char *details) -{ -char name[sizeof (current->comm)]; - -pr_info_once ("warning: `%s' uses legacy ethtool link settings API, %s\n" , -get_task_comm (name, current), details); -} -/* Query device for its ethtool_cmd settings. * * Backward compatibility note: for compatibility with legacy ethtool,
@@ -789,10 +780,8 @@ static int ethtool_get_settings(struct n &link_ksettings);if (err <0 )return err; -if (!convert_link_ksettings_to_legacy_settings (&cmd, - &link_ksettings)) -warn_incomplete_ethtool_legacy_settings_conversion ( -"link modes are only partially reported" ); +convert_link_ksettings_to_legacy_settings (&cmd, + &link_ksettings);/* send a sensible cmd tag back to user */ cmd.cmd =ETHTOOL_GSET ;
Greg Kroah-Hartman
maintainerPATCH 48/118 mlxsw: spectrum_router: Fix NULL pointer deref
In reply to Greg Kroah-Hartman4.14-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ido Schimmel <[email protected]>
[ Upstream commit 8764a8267b128405cf383157d5e9a4a3735d2409 ]
When we remove the neighbour associated with a nexthop we should always refuse to write the nexthop to the adjacency table. Regardless if it is already present in the table or not.
Otherwise, we risk dereferencing the NULL pointer that was set instead of the neighbour.
--- drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c +1 -1
@@ -2536,7 +2536,7 @@ static void __mlxsw_sp_nexthop_neigh_upd {if (!removing) nh->should_offload =1 ; -else if (nh->offloaded) +else nh->should_offload =0 ; nh->update =1 ; }
Greg Kroah-Hartman
maintainerPATCH 49/118 net/sched: Fix update of lastuse in act modules implementing stats_update
In reply to Greg Kroah-Hartman4.14-stable review patch. If anyone has any objections, please let me know.
------------------
From: Roi Dayan <[email protected]>
[ Upstream commit 3bb23421a504f01551b7cb9dff0e41dbf16656b0 ]
We need to update lastuse to to the most updated value between what is already set and the new value.
If HW matching fails, i.e. because of an issue, the stats are not updated but it could be that software did match and updated lastuse.
--- net/sched/act_gact.c | 2 +- net/sched/act_mirred.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
net/sched/act_gact.c +1 -1
@@ -159,7 +159,7 @@ static void tcf_gact_stats_update(structif (action ==TC_ACT_SHOT )this_cpu_ptr (gact->common.cpu_qstats)->drops += packets; - tm->lastuse = lastuse; + tm->lastuse =max_t (u64, tm->lastuse, lastuse); } static int tcf_gact_dump(struct sk_buff *skb, struct tc_action *a,
net/sched/act_mirred.c +1 -1
@@ -238,7 +238,7 @@ static void tcf_stats_update(struct tc_astruct tcf_t *tm = &m->tcf_tm;_bstats_cpu_update (this_cpu_ptr (a->cpu_bstats), bytes, packets); - tm->lastuse = lastuse; + tm->lastuse =max_t (u64, tm->lastuse, lastuse); } static int tcf_mirred_dump(struct sk_buff *skb, struct tc_action *a, int bind,
Greg Kroah-Hartman
maintainerPATCH 50/118 ipv6: sr: fix TLVs not being copied using setsockopt
In reply to Greg Kroah-Hartman4.14-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mathieu Xhonneux <[email protected]>
[ Upstream commit ccc12b11c5332c84442ef120dcd631523be75089 ]
Function ipv6_push_rthdr4 allows to add an IPv6 Segment Routing Header to a socket through setsockopt, but the current implementation doesn't copy possible TLVs at the end of the SRH received from userspace.
Therefore, the execution of the following branch if (sr_has_hmac(sr_phdr)) { ... } will never complete since the len and type fields of a possible HMAC TLV are not copied, hence seg6_get_tlv_hmac will return an error, and the HMAC will not be computed.
This commit adds a memcpy in case TLVs have been appended to the SRH.
--- net/ipv6/exthdrs.c | 9 +++++++++ 1 file changed, 9 insertions(+)
net/ipv6/exthdrs.c +9 -0
@@ -884,6 +884,15 @@ static void ipv6_push_rthdr4(struct sk_b sr_phdr->segments[0 ] = **addr_p; *addr_p = &sr_ihdr->segments[sr_ihdr->segments_left]; +if (sr_ihdr->hdrlen > hops *2 ) { +int tlvs_offset, tlvs_length; + + tlvs_offset = (1 + hops *2 ) <<3 ; + tlvs_length = (sr_ihdr->hdrlen - hops *2 ) <<3 ; +memcpy ((char *)sr_phdr + tlvs_offset, + (char *)sr_ihdr + tlvs_offset, tlvs_length); + } +#ifdef CONFIG_IPV6_SEG6_HMAC if (sr_has_hmac (sr_phdr)) {struct net *net =NULL ;
Greg Kroah-Hartman
maintainerPATCH 51/118 mlxsw: spectrum: Relax sanity checks during enslavement
In reply to Greg Kroah-Hartman4.14-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ido Schimmel <[email protected]>
[ Upstream commit 90045fc9c78855bdc625a0ab185d97b72a937613 ]
Since commit 25cc72a33835 ("mlxsw: spectrum: Forbid linking to devices that have uppers") the driver forbids enslavement to netdevs that already have uppers of their own, as this can result in various ordering problems.
This requirement proved to be too strict for some users who need to be able to enslave ports to a bridge that already has uppers. In this case, we can allow the enslavement if the bridge is already known to us, as any configuration performed on top of the bridge was already reflected to the device.
--- drivers/net/ethernet/mellanox/mlxsw/spectrum.c | 11 +++++++++-- drivers/net/ethernet/mellanox/mlxsw/spectrum.h | 2 ++ drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c | 6 ++++++ 3 files changed, 17 insertions(+), 2 deletions(-)
drivers/net/ethernet/mellanox/mlxsw/spectrum.c +9 -2
@@ -4235,7 +4235,10 @@ static int mlxsw_sp_netdevice_port_upperreturn -EINVAL ;if (!info->linking)break ; -if (netdev_has_any_upper_dev (upper_dev)) +if (netdev_has_any_upper_dev (upper_dev) && + (!netif_is_bridge_master (upper_dev) || + !mlxsw_sp_bridge_device_is_offloaded (mlxsw_sp, + upper_dev)))return -EINVAL ;if (netif_is_lag_master (upper_dev) && !mlxsw_sp_master_lag_check(mlxsw_sp, upper_dev,
@@ -4347,6 +4350,7 @@ static int mlxsw_sp_netdevice_port_vlan_ u16 vid) {struct mlxsw_sp_port *mlxsw_sp_port =netdev_priv (dev); +struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp;struct netdev_notifier_changeupper_info *info = ptr;struct net_device *upper_dev;int err =0 ;
@@ -4358,7 +4362,10 @@ static int mlxsw_sp_netdevice_port_vlan_return -EINVAL ;if (!info->linking)break ; -if (netdev_has_any_upper_dev (upper_dev)) +if (netdev_has_any_upper_dev (upper_dev) && + (!netif_is_bridge_master (upper_dev) || + !mlxsw_sp_bridge_device_is_offloaded (mlxsw_sp, + upper_dev)))return -EINVAL ;break ;case NETDEV_CHANGEUPPER :
drivers/net/ethernet/mellanox/mlxsw/spectrum.h +2 -0
@@ -326,6 +326,8 @@ int mlxsw_sp_port_bridge_join(struct mlxvoid mlxsw_sp_port_bridge_leave (struct mlxsw_sp_port *mlxsw_sp_port,struct net_device *brport_dev,struct net_device *br_dev); +bool mlxsw_sp_bridge_device_is_offloaded (const struct mlxsw_sp *mlxsw_sp, +const struct net_device *br_dev);/* spectrum.c */ int mlxsw_sp_port_ets_set(struct mlxsw_sp_port *mlxsw_sp_port,
drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c +6 -0
@@ -134,6 +134,12 @@ mlxsw_sp_bridge_device_find(const structreturn NULL ; } +bool mlxsw_sp_bridge_device_is_offloaded (const struct mlxsw_sp *mlxsw_sp, +const struct net_device *br_dev) +{ +return !!mlxsw_sp_bridge_device_find (mlxsw_sp->bridge, br_dev); +} +static struct mlxsw_sp_bridge_device *mlxsw_sp_bridge_device_create (struct mlxsw_sp_bridge *bridge,struct net_device *br_dev)
Greg Kroah-Hartman
maintainerPATCH 52/118 sfp: fix sfp-bus oops when removing socket/upstream
In reply to Greg Kroah-Hartman4.14-stable review patch. If anyone has any objections, please let me know.
------------------
From: Russell King <[email protected]>
[ Upstream commit 0b2122e4934c7783d336397864e34ee53aad0965 ]
When we remove a socket or upstream, and the other side isn't registered, we dereference a NULL pointer, causing a kernel oops. Fix this.
--- drivers/net/phy/sfp-bus.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/net/phy/sfp-bus.c +4 -2
@@ -359,7 +359,8 @@ EXPORT_SYMBOL_GPL(sfp_register_upstream)void sfp_unregister_upstream (struct sfp_bus *bus) {rtnl_lock (); -sfp_unregister_bus (bus); +if (bus->sfp) +sfp_unregister_bus (bus); bus->upstream =NULL ; bus->netdev =NULL ;rtnl_unlock ();
@@ -464,7 +465,8 @@ EXPORT_SYMBOL_GPL(sfp_register_socket);void sfp_unregister_socket (struct sfp_bus *bus) {rtnl_lock (); -sfp_unregister_bus (bus); +if (bus->netdev) +sfp_unregister_bus (bus); bus->sfp_dev =NULL ; bus->sfp =NULL ; bus->socket_ops =NULL ;
Greg Kroah-Hartman
maintainerPATCH 53/118 Revert "Revert "xfrm: Fix stack-out-of-bounds read in xfrm_state_find.""
In reply to Greg Kroah-Hartman4.14-stable review patch. If anyone has any objections, please let me know.
------------------
From: "David S. Miller" <[email protected]>
This reverts commit 94802151894d482e82c324edf2c658f8e6b96508.
It breaks transport mode when the policy template has wildcard addresses configured.
--- net/xfrm/xfrm_policy.c | 29 +++++++++++------------------ 1 file changed, 11 insertions(+), 18 deletions(-)
net/xfrm/xfrm_policy.c +11 -18
@@ -1362,36 +1362,29 @@ xfrm_tmpl_resolve_one(struct xfrm_policystruct net *net =xp_net (policy);int nx;int i, error; -xfrm_address_t *daddr =xfrm_flowi_daddr (fl, family); -xfrm_address_t *saddr =xfrm_flowi_saddr (fl, family);xfrm_address_t tmp;for (nx =0 , i =0 ; i < policy->xfrm_nr; i++) {struct xfrm_state *x; -xfrm_address_t *remote = daddr; -xfrm_address_t *local = saddr; +xfrm_address_t *local; +xfrm_address_t *remote;struct xfrm_tmpl *tmpl = &policy->xfrm_vec[i]; -if (tmpl->mode ==XFRM_MODE_TUNNEL || - tmpl->mode ==XFRM_MODE_BEET ) { - remote = &tmpl->id.daddr; - local = &tmpl->saddr; -if (xfrm_addr_any (local, tmpl->encap_family)) { - error =xfrm_get_saddr (net, fl->flowi_oif, - &tmp, remote, - tmpl->encap_family,0 ); -if (error) - goto fail; - local = &tmp; - } + remote = &tmpl->id.daddr; + local = &tmpl->saddr; +if (xfrm_addr_any (local, tmpl->encap_family)) { + error =xfrm_get_saddr (net, fl->flowi_oif, + &tmp, remote, + tmpl->encap_family,0 ); +if (error) + goto fail; + local = &tmp; } x =xfrm_state_find (remote, local, fl, tmpl, policy, &error, family);if (x && x->km.state ==XFRM_STATE_VALID ) { xfrm[nx++] = x; - daddr = remote; - saddr = local;continue ; }if (x) {
Re: [PATCH 4.14 053/118] Revert "Revert "xfrm: Fix stack-out-of-bounds read in xfrm_state_find.""
Quoted 7 lines · Greg Kroah-Hartman
4.14-stable review patch. If anyone has any objections, please let me know.
------------------
From: "David S. Miller" <[email protected]>
Quoted 7 lines
This reverts commit
94802151894d482e82c324edf2c658f8e6b96508.It breaks transport mode when the policy template has wildcard addresses configured.
Signed-off-by David S. Miller <[email protected]>Signed-off-by Greg Kroah-Hartman <[email protected]>
Hm, this seems to be one revert too much.
commit 94802151894d482e82c324edf2c658f8e6b96508 reverted already the buggy commit. Reverting the revert will bring the bug back.
Greg Kroah-Hartman
maintainerRe: [PATCH 4.14 053/118] Revert "Revert "xfrm: Fix stack-out-of-bounds read in xfrm_state_find.""
Quoted 13 lines · Steffen Klassert
Quoted 12 lines · Greg Kroah-Hartman
4.14-stable review patch. If anyone has any objections, please let me know.
------------------
From: "David S. Miller" <[email protected]>
This reverts commit
94802151894d482e82c324edf2c658f8e6b96508.It breaks transport mode when the policy template has wildcard addresses configured.
Quoted 7 lines
Quoted 2 lines
Signed-off-by David S. Miller <[email protected]>Signed-off-by Greg Kroah-Hartman <[email protected]>Hm, this seems to be one revert too much.
commit
94802151894d482e82c324edf2c658f8e6b96508reverted already the buggy commit. Reverting the revert will bring the bug back.
Really? I have no idea what is going on here, I just take the patches that David gives me :)
David, should I drop this one?
thanks,
greg k-h
Re: [PATCH 4.14 053/118] Revert "Revert "xfrm: Fix stack-out-of-bounds read in xfrm_state_find.""
In reply to Steffen KlassertFrom: Steffen Klassert <[email protected]>
Date: Mon, 15 Jan 2018 14:23:29 +0100
Quoted 13 lines · Greg Kroah-Hartman
Quoted 12 lines
4.14-stable review patch. If anyone has any objections, please let me know.
------------------
From: "David S. Miller" <[email protected]>
This reverts commit
94802151894d482e82c324edf2c658f8e6b96508.It breaks transport mode when the policy template has wildcard addresses configured.
Quoted 7 lines
Quoted 2 lines
Signed-off-by David S. Miller <[email protected]>Signed-off-by Greg Kroah-Hartman <[email protected]>Hm, this seems to be one revert too much.
commit
94802151894d482e82c324edf2c658f8e6b96508reverted already the buggy commit. Reverting the revert will bring the bug back.
Steffen, in the email where you asked me to revert that is the commit ID you referenced.
We can drop this, but you need to then tell us whether 4.14 needs the revert any longer and if so what the correct SHA ID would be.
Re: [PATCH 4.14 053/118] Revert "Revert "xfrm: Fix stack-out-of-bounds read in xfrm_state_find.""
Quoted 19 lines · David Miller
From: Steffen Klassert <[email protected]>
Date: Mon, 15 Jan 2018 14:23:29 +0100Quoted 16 lines · Greg Kroah-Hartman
Quoted 14 lines
4.14-stable review patch. If anyone has any objections, please let me know.
------------------
From: "David S. Miller" <[email protected]>
This reverts commit
94802151894d482e82c324edf2c658f8e6b96508.It breaks transport mode when the policy template has wildcard addresses configured.
Signed-off-by David S. Miller <[email protected]>Signed-off-by Greg Kroah-Hartman <[email protected]>
Quoted 7 lines
Quoted 4 lines
Hm, this seems to be one revert too much.
commit
94802151894d482e82c324edf2c658f8e6b96508reverted already the buggy commit. Reverting the revert will bring the bug back.Steffen, in the email where you asked me to revert that is the commit ID you referenced.
I think there was a misunderstanding. I asked you to queue the commit with that ID to stable on Dec 23 (this commit ID is the revert of the buggy patch). This commit was included to stable on Jan 4 then:
https://www.spinics.net/lists/stable/msg208727.html
So with this, everything was ok.
Maybe you started to look again into this because Nicolas Dichtel (Cced) asked to queue this patch on Jan 5, the patch was already in the stable tree (Jan 4) but probably not in an actual release at this time.
Quoted 4 lines
We can drop this, but you need to then tell us whether 4.14 needs the revert any longer and if so what the correct SHA ID would be.
I think we can we can just drop this.
Unless Nicolas knows something that is still missing, v4.14.12 and above should be ok as is.
Re: [PATCH 4.14 053/118] Revert "Revert "xfrm: Fix stack-out-of-bounds read in xfrm_state_find.""
Le 16/01/2018 à 07:33, Steffen Klassert a écrit :
Quoted 33 lines · David Miller
Quoted 19 lines
From: Steffen Klassert <[email protected]>
Date: Mon, 15 Jan 2018 14:23:29 +0100Quoted 16 lines · Greg Kroah-Hartman
Quoted 14 lines
4.14-stable review patch. If anyone has any objections, please let me know.
------------------
From: "David S. Miller" <[email protected]>
This reverts commit
94802151894d482e82c324edf2c658f8e6b96508.It breaks transport mode when the policy template has wildcard addresses configured.
Signed-off-by David S. Miller <[email protected]>Signed-off-by Greg Kroah-Hartman <[email protected]>Quoted 7 lines
Quoted 4 lines
Hm, this seems to be one revert too much.
commit
94802151894d482e82c324edf2c658f8e6b96508reverted already the buggy commit. Reverting the revert will bring the bug back.Steffen, in the email where you asked me to revert that is the commit ID you referenced.
I think there was a misunderstanding. I asked you to queue the commit with that ID to stable on Dec 23 (this commit ID is the revert of the buggy patch). This commit was included to stable on Jan 4 then:
Quoted 8 lines
https://www.spinics.net/lists/stable/msg208727.html
So with this, everything was ok.
Maybe you started to look again into this because Nicolas Dichtel (Cced) asked to queue this patch on Jan 5, the patch was already in the stable tree (Jan 4) but probably not in an actual release at this time.
Oh, I didn't find it at this time in the linux-stable tree nor in the stable patchwork. Bad timing :/
I still don't find it in the patchwork:
http://patchwork.ozlabs.org/bundle/davem/stable/?series=&submitter=1442&state=*&q=&archive=both
Am I missing something?
Quoted 10 lines
Quoted 5 lines
We can drop this, but you need to then tell us whether 4.14 needs the revert any longer and if so what the correct SHA ID would be.
I think we can we can just drop this.
Unless Nicolas knows something that is still missing, v4.14.12 and above should be ok as is.
I agree, we can drop this.
Thank you,
Nicolas
Re: [PATCH 4.14 053/118] Revert "Revert "xfrm: Fix stack-out-of-bounds read in xfrm_state_find.""
Quoted 6 lines · Nicolas Dichtel
Le 16/01/2018 � 07:33, Steffen Klassert a �crit�:
Quoted 5 lines
Maybe you started to look again into this because Nicolas Dichtel (Cced) asked to queue this patch on Jan 5, the patch was already in the stable tree (Jan 4) but probably not in an actual release at this time.
Quoted 6 lines
Oh, I didn't find it at this time in the linux-stable tree nor in the stable patchwork. Bad timing :/
I still don't find it in the patchwork:
http://patchwork.ozlabs.org/bundle/davem/stable/?series=&submitter=1442&state=*&q=&archive=both
Am I missing something?
Not so sure which patches are included here, maybe just the ones that still needs to be submitted to stable.
Anyway, the commit we need is included in v4.14.12:
commit 2d01ac8cc12b973668bf898b03bf9ffb12d83b83
Author: Steffen Klassert <[email protected]>
Date: Wed, 15 Nov 2017 06:40:57 +0100
Revert "xfrm: Fix stack-out-of-bounds read in xfrm_state_find."
commit 94802151894d482e82c324edf2c658f8e6b96508 upstream.
This reverts commit c9f3f813d462c72dbe412cee6a5cbacf13c4ad5e.
This commit breaks transport mode when the policy template has widlcard addresses configured, so revert it.
Quoted 7 lines
Quoted 7 lines
Quoted 6 lines
We can drop this, but you need to then tell us whether 4.14 needs the revert any longer and if so what the correct SHA ID would be.
Quoted 5 lines
Quoted 4 lines
I think we can we can just drop this.
Unless Nicolas knows something that is still missing, v4.14.12 and above should be ok as is.
I agree, we can drop this.
Ok, so let's drop it.
Thanks!
Re: [PATCH 4.14 053/118] Revert "Revert "xfrm: Fix stack-out-of-bounds read in xfrm_state_find.""
In reply to Steffen KlassertFrom: Steffen Klassert <[email protected]>
Date: Tue, 16 Jan 2018 07:33:39 +0100
Quoted 4 lines
Maybe you started to look again into this because Nicolas Dichtel (Cced) asked to queue this patch on Jan 5, the patch was already in the stable tree (Jan 4) but probably not in an actual release at this time.
Yeah that's part of why I was confused.
Quoted 4 lines
I think we can we can just drop this.
Unless Nicolas knows something that is still missing, v4.14.12 and above should be ok as is.
Ok, then Greg please drop this.
Thanks Steffen.
Greg KH
maintainerRe: [PATCH 4.14 053/118] Revert "Revert "xfrm: Fix stack-out-of-bounds read in xfrm_state_find.""
Quoted 8 lines · David Miller
From: Steffen Klassert <[email protected]>
Date: Tue, 16 Jan 2018 07:33:39 +0100Quoted 4 lines
Maybe you started to look again into this because Nicolas Dichtel (Cced) asked to queue this patch on Jan 5, the patch was already in the stable tree (Jan 4) but probably not in an actual release at this time.
Quoted 8 lines
Yeah that's part of why I was confused.
Quoted 4 lines
I think we can we can just drop this.
Unless Nicolas knows something that is still missing, v4.14.12 and above should be ok as is.
Ok, then Greg please drop this.
Now dropped, thanks.
greg k-h
Greg Kroah-Hartman
maintainerPATCH 54/118 membarrier: Disable preemption when calling smp_call_function_many()
In reply to Greg Kroah-Hartman4.14-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mathieu Desnoyers <[email protected]>
commit 541676078b52f365f53d46ee5517d305cd1b6350 upstream.
smp_call_function_many() requires disabling preemption around the call.
--- kernel/sched/membarrier.c | 2 ++ 1 file changed, 2 insertions(+)
kernel/sched/membarrier.c +2 -0
@@ -89,7 +89,9 @@ static int membarrier_private_expedited(rcu_read_unlock (); }if (!fallback) { +preempt_disable ();smp_call_function_many (tmpmask, ipi_mb,NULL ,1 ); +preempt_enable ();free_cpumask_var (tmpmask); }cpus_read_unlock ();
Greg Kroah-Hartman
maintainerPATCH 55/118 crypto: algapi - fix NULL dereference in crypto_remove_spawns()
In reply to Greg Kroah-Hartman4.14-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Biggers <[email protected]>
commit 9a00674213a3f00394f4e3221b88f2d21fc05789 upstream.
syzkaller triggered a NULL pointer dereference in crypto_remove_spawns() via a program that repeatedly and concurrently requests AEADs "authenc(cmac(des3_ede-asm),pcbc-aes-aesni)" and hashes "cmac(des3_ede)" through AF_ALG, where the hashes are requested as "untested" (CRYPTO_ALG_TESTED is set in ->salg_mask but clear in ->salg_feat; this causes the template to be instantiated for every request).
Although AF_ALG users really shouldn't be able to request an "untested" algorithm, the NULL pointer dereference is actually caused by a longstanding race condition where crypto_remove_spawns() can encounter an instance which has had spawn(s) "grabbed" but hasn't yet been registered, resulting in ->cra_users still being NULL.
We probably should properly initialize ->cra_users earlier, but that would require updating many templates individually. For now just fix the bug in a simple way that can easily be backported: make crypto_remove_spawns() treat a NULL ->cra_users list as empty.
--- crypto/algapi.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
crypto/algapi.c +12 -0
@@ -167,6 +167,18 @@ void crypto_remove_spawns(struct crypto_ spawn->alg =NULL ; spawns = &inst->alg.cra_users; + +/* +* We may encounter an unregistered instance here, since +* an instance's spawns are set up prior to the instance +* being registered. An unregistered instance will have +* NULL ->cra_users.next, since ->cra_users isn't +* properly initialized until registration. But an +* unregistered instance cannot have any users, so treat +* it the same as ->cra_users being empty. +*/ +if (spawns->next ==NULL ) +break ; } }while ((spawns =crypto_more_spawns (alg, &stack, &top, &secondary_spawns)));
Greg Kroah-Hartman
maintainerPATCH 56/118 mmc: renesas_sdhi: Add MODULE_LICENSE
In reply to Greg Kroah-Hartman4.14-stable review patch. If anyone has any objections, please let me know.
------------------
From: Masaharu Hayakawa <[email protected]>
commit 967a6a07e95c58eb9c1581d22a1d9c2d1929843f upstream.
The following error occurs when loading renesas_sdhi_core.c module, so add MODULE_LICENSE("GPL v2").
renesas_sdhi_core: module license 'unspecified' taints kernel.
--- drivers/mmc/host/renesas_sdhi_core.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/mmc/host/renesas_sdhi_core.c +3 -0
@@ -24,6 +24,7 @@#include <linux/kernel.h> #include <linux/clk.h> #include <linux/slab.h> +#include <linux/module.h> #include <linux/of_device.h> #include <linux/platform_device.h> #include <linux/mmc/host.h>
@@ -667,3 +668,5 @@ int renesas_sdhi_remove(struct platform_return 0 ; }EXPORT_SYMBOL_GPL (renesas_sdhi_remove); + +MODULE_LICENSE ("GPL v2" );
Greg Kroah-Hartman
maintainerPATCH 57/118 rbd: reacquire lock should update lock owner client id
In reply to Greg Kroah-Hartman4.14-stable review patch. If anyone has any objections, please let me know.
------------------
From: Florian Margaine <[email protected]>
commit edd8ca8015800b354453b891d38960f3a474b7e4 upstream.
Otherwise, future operations on this RBD using exclusive-lock are going to require the lock from a non-existent client id.
--- drivers/block/rbd.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-)
drivers/block/rbd.c +11 -5
@@ -3074,13 +3074,21 @@ static void format_lock_cookie(struct rbmutex_unlock (&rbd_dev->watch_mutex); } +static void __rbd_lock (struct rbd_device *rbd_dev,const char *cookie) +{ +struct rbd_client_id cid =rbd_get_cid (rbd_dev); + +strcpy (rbd_dev->lock_cookie, cookie); +rbd_set_owner_cid (rbd_dev, &cid); +queue_work (rbd_dev->task_wq, &rbd_dev->acquired_lock_work); +} +/* * lock_rwsem must be held for write */ static int rbd_lock (struct rbd_device *rbd_dev) {struct ceph_osd_client *osdc = &rbd_dev->rbd_client->client->osdc; -struct rbd_client_id cid =rbd_get_cid (rbd_dev);char cookie[32 ];int ret;
@@ -3095,9 +3103,7 @@ static int rbd_lock(struct rbd_device *rreturn ret; rbd_dev->lock_state =RBD_LOCK_STATE_LOCKED ; -strcpy (rbd_dev->lock_cookie, cookie); -rbd_set_owner_cid (rbd_dev, &cid); -queue_work (rbd_dev->task_wq, &rbd_dev->acquired_lock_work); +__rbd_lock (rbd_dev, cookie);return 0 ; }
@@ -3883,7 +3889,7 @@ static void rbd_reacquire_lock(struct rbqueue_delayed_work (rbd_dev->task_wq, &rbd_dev->lock_dwork,0 ); }else { -strcpy (rbd_dev->lock_cookie, cookie); +__rbd_lock (rbd_dev, cookie); } }
Greg Kroah-Hartman
maintainerPATCH 58/118 rbd: set max_segments to USHRT_MAX
In reply to Greg Kroah-Hartman4.14-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ilya Dryomov <[email protected]>
commit 21acdf45f4958135940f0b4767185cf911d4b010 upstream.
Commit d3834fefcfe5 ("rbd: bump queue_max_segments") bumped max_segments (unsigned short) to max_hw_sectors (unsigned int). max_hw_sectors is set to the number of 512-byte sectors in an object and overflows unsigned short for 32M (largest possible) objects, making the block layer resort to handing us single segment (i.e. single page or even smaller) bios in that case.
--- drivers/block/rbd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/block/rbd.c +1 -1
@@ -4421,7 +4421,7 @@ static int rbd_init_disk(struct rbd_devi segment_size =rbd_obj_bytes (&rbd_dev->header);blk_queue_max_hw_sectors (q, segment_size /SECTOR_SIZE ); q->limits.max_sectors =queue_max_hw_sectors (q); -blk_queue_max_segments (q, segment_size /SECTOR_SIZE ); +blk_queue_max_segments (q,USHRT_MAX );blk_queue_max_segment_size (q, segment_size);blk_queue_io_min (q, segment_size);blk_queue_io_opt (q, segment_size);
Greg Kroah-Hartman
maintainerPATCH 59/118 iwlwifi: pcie: fix DMA memory mapping / unmapping
In reply to Greg Kroah-Hartman4.14-stable review patch. If anyone has any objections, please let me know.
------------------
From: Emmanuel Grumbach <[email protected]>
commit 943309d4aad6732b905f3f500e6e17e33c211494 upstream.
22000 devices (previously referenced as A000) can support short transmit queues. This means that we have less DMA descriptors (TFD) for those shorter queues. Previous devices must still have 256 TFDs for each queue even if those 256 TFDs point to fewer buffers.
When I introduced support for the short queues for 22000 I broke older devices by assuming that they can also have less TFDs in their queues. This led to several problems:
1) the payload of the commands weren't unmapped properly which caused the SWIOTLB to complain at some point.
2) the hardware could get confused and we get hardware crashes.
The corresponding bugzilla entries are:
https://bugzilla.kernel.org/show_bug.cgi?id=198201
https://bugzilla.kernel.org/show_bug.cgi?id=198265
--- drivers/net/wireless/intel/iwlwifi/pcie/internal.h | 10 +++++++--- drivers/net/wireless/intel/iwlwifi/pcie/tx-gen2.c | 11 +++-------- drivers/net/wireless/intel/iwlwifi/pcie/tx.c | 8 ++++---- 3 files changed, 14 insertions(+), 15 deletions(-)
drivers/net/wireless/intel/iwlwifi/pcie/internal.h +7 -3
@@ -666,11 +666,15 @@ static inline u8 iwl_pcie_get_cmd_index(return index & (q->n_window -1 ); } -static inline void *iwl_pcie_get_tfd (struct iwl_trans_pcie *trans_pcie, +static inline void *iwl_pcie_get_tfd (struct iwl_trans *trans,struct iwl_txq *txq,int idx) { -return txq->tfds + trans_pcie->tfd_size *iwl_pcie_get_cmd_index (txq, - idx); +struct iwl_trans_pcie *trans_pcie =IWL_TRANS_GET_PCIE_TRANS (trans); + +if (trans->cfg->use_tfh) + idx =iwl_pcie_get_cmd_index (txq, idx); + +return txq->tfds + trans_pcie->tfd_size * idx; }static inline void iwl_enable_rfkill_int (struct iwl_trans *trans)
drivers/net/wireless/intel/iwlwifi/pcie/tx-gen2.c +3 -8
@@ -171,8 +171,6 @@ static void iwl_pcie_gen2_tfd_unmap(strustatic void iwl_pcie_gen2_free_tfd (struct iwl_trans *trans,struct iwl_txq *txq) { -struct iwl_trans_pcie *trans_pcie =IWL_TRANS_GET_PCIE_TRANS (trans); -/* rd_ptr is bounded by TFD_QUEUE_SIZE_MAX and * idx is bounded by n_window */
@@ -181,7 +179,7 @@ static void iwl_pcie_gen2_free_tfd(struclockdep_assert_held (&txq->lock);iwl_pcie_gen2_tfd_unmap (trans, &txq->entries[idx].meta, -iwl_pcie_get_tfd (trans_pcie, txq, idx)); +iwl_pcie_get_tfd (trans, txq, idx));/* free SKB */ if (txq->entries) {
@@ -367,11 +365,9 @@ struct iwl_tfh_tfd *iwl_pcie_gen2_build_struct sk_buff *skb, struct iwl_cmd_meta *out_meta) { - struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;int idx =iwl_pcie_get_cmd_index (txq, txq->write_ptr); -struct iwl_tfh_tfd *tfd = -iwl_pcie_get_tfd (trans_pcie, txq, idx); +struct iwl_tfh_tfd *tfd =iwl_pcie_get_tfd (trans, txq, idx);dma_addr_t tb_phys;bool amsdu;int i, len, tb1_len, tb2_len, hdr_len;
@@ -568,8 +564,7 @@ static int iwl_pcie_gen2_enqueue_hcmd(stu8 group_id =iwl_cmd_groupid (cmd->id);const u8 *cmddata[IWL_MAX_CMD_TBS_PER_TFD ];u16 cmdlen[IWL_MAX_CMD_TBS_PER_TFD ]; -struct iwl_tfh_tfd *tfd = -iwl_pcie_get_tfd (trans_pcie, txq, txq->write_ptr); +struct iwl_tfh_tfd *tfd =iwl_pcie_get_tfd (trans, txq, txq->write_ptr);memset (tfd,0 ,sizeof (*tfd));
drivers/net/wireless/intel/iwlwifi/pcie/tx.c +4 -4
@@ -373,7 +373,7 @@ static void iwl_pcie_tfd_unmap(struct iw {struct iwl_trans_pcie *trans_pcie =IWL_TRANS_GET_PCIE_TRANS (trans);int i, num_tbs; -void *tfd =iwl_pcie_get_tfd (trans_pcie, txq, index); +void *tfd =iwl_pcie_get_tfd (trans, txq, index);/* Sanity check on number of chunks */ num_tbs =iwl_pcie_tfd_get_num_tbs (trans, tfd);
@@ -1999,7 +1999,7 @@ static int iwl_fill_data_tbs(struct iwl_ }trace_iwlwifi_dev_tx (trans->dev, skb, -iwl_pcie_get_tfd (trans_pcie, txq, txq->write_ptr), +iwl_pcie_get_tfd (trans, txq, txq->write_ptr), trans_pcie->tfd_size, &dev_cmd->hdr,IWL_FIRST_TB_SIZE + tb1_len, hdr_len);
@@ -2073,7 +2073,7 @@ static int iwl_fill_data_tbs_amsdu(struc IEEE80211_CCMP_HDR_LEN :0 ;trace_iwlwifi_dev_tx (trans->dev, skb, -iwl_pcie_get_tfd (trans_pcie, txq, txq->write_ptr), +iwl_pcie_get_tfd (trans, txq, txq->write_ptr), trans_pcie->tfd_size, &dev_cmd->hdr,IWL_FIRST_TB_SIZE + tb1_len,0 );
@@ -2406,7 +2406,7 @@ int iwl_trans_pcie_tx(struct iwl_trans *memcpy (&txq->first_tb_bufs[txq->write_ptr], &dev_cmd->hdr,IWL_FIRST_TB_SIZE ); - tfd =iwl_pcie_get_tfd (trans_pcie, txq, txq->write_ptr); + tfd =iwl_pcie_get_tfd (trans, txq, txq->write_ptr);/* Set up entry for this TFD in Tx byte-count array */ iwl_pcie_txq_update_byte_cnt_tbl (trans, txq,le16_to_cpu (tx_cmd->len),iwl_pcie_tfd_get_num_tbs (trans, tfd));
Greg Kroah-Hartman
maintainerPATCH 60/118 x86/microcode/intel: Extend BDW late-loading with a revision check
In reply to Greg Kroah-Hartman4.14-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jia Zhang <[email protected]>
commit b94b7373317164402ff7728d10f7023127a02b60 upstream.
Instead of blacklisting all model 79 CPUs when attempting a late microcode loading, limit that only to CPUs with microcode revisions < 0x0b000021 because only on those late loading may cause a system hang.
For such processors either:
a) a BIOS update which might contain a newer microcode revision
or
b) the early microcode loading method
should be considered.
Processors with revisions 0x0b000021 or higher will not experience such hangs.
For more details, see erratum BDF90 in document #334165 (Intel Xeon Processor E7-8800/4800 v4 Product Family Specification Update) from September 2017.
[ bp: Heavily massage commit message and pr_* statements. ]
--- arch/x86/kernel/cpu/microcode/intel.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-)
arch/x86/kernel/cpu/microcode/intel.c +11 -2
@@ -910,8 +910,17 @@ static bool is_blacklisted(unsigned int {struct cpuinfo_x86 *c = &cpu_data (cpu); -if (c->x86 ==6 && c->x86_model ==INTEL_FAM6_BROADWELL_X ) { -pr_err_once ("late loading on model 79 is disabled.\n" ); +/* +* Late loading on model 79 with microcode revision less than 0x0b000021 +* may result in a system hang. This behavior is documented in item +* BDF90, #334165 (Intel Xeon Processor E7-8800/4800 v4 Product Family). +*/ +if (c->x86 ==6 && + c->x86_model ==INTEL_FAM6_BROADWELL_X && + c->x86_mask ==0x01 && + c->microcode <0x0b000021 ) { +pr_err_once ("Erratum BDF90: late loading with revision < 0x0b000021 (0x%x) disabled.\n" , c->microcode); +pr_err_once ("Please consider either early loading through initrd/built-in or a potential BIOS update.\n" );return true; }
Greg Kroah-Hartman
maintainerPATCH 61/118 KVM: x86: Add memory barrier on vmcs field lookup
In reply to Greg Kroah-Hartman4.14-stable review patch. If anyone has any objections, please let me know.
------------------
From: Andrew Honig <[email protected]>
commit 75f139aaf896d6fdeec2e468ddfa4b2fe469bf40 upstream.
This adds a memory barrier when performing a lookup into the vmcs_field_to_offset_table. This is related to CVE-2017-5753.
--- arch/x86/kvm/vmx.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-)
arch/x86/kvm/vmx.c +10 -2
@@ -888,8 +888,16 @@ static inline short vmcs_field_to_offset {BUILD_BUG_ON (ARRAY_SIZE (vmcs_field_to_offset_table) >SHRT_MAX ); -if (field >=ARRAY_SIZE (vmcs_field_to_offset_table) || - vmcs_field_to_offset_table[field] ==0 ) +if (field >=ARRAY_SIZE (vmcs_field_to_offset_table)) +return -ENOENT ; + +/* +* FIXME: Mitigation for CVE-2017-5753. To be replaced with a +* generic mechanism. +*/ + asm("lfence" ); + +if (vmcs_field_to_offset_table[field] ==0 )return -ENOENT ;return vmcs_field_to_offset_table[field];
Greg Kroah-Hartman
maintainerPATCH 62/118 KVM: PPC: Book3S PR: Fix WIMG handling under pHyp
In reply to Greg Kroah-Hartman4.14-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alexey Kardashevskiy <[email protected]>
commit 6c7d47c33ed323f14f2a3b8de925e831dbaa4e69 upstream.
Commit 96df226 ("KVM: PPC: Book3S PR: Preserve storage control bits") added code to preserve WIMG bits but it missed 2 special cases:
- a magic page in kvmppc_mmu_book3s_64_xlate() and
- guest real mode in kvmppc_handle_pagefault().
For these ptes, WIMG was 0 and pHyp failed on these causing a guest to stop in the very beginning at NIP=0x100 (due to bd9166ffe "KVM: PPC:
Book3S PR: Exit KVM on failed mapping").
According to LoPAPR v1.1 14.5.4.1.2 H_ENTER:
The hypervisor checks that the WIMG bits within the PTE are appropriate for the physical page number else H_Parameter return. (For System Memory pages WIMG=0010, or, 1110 if the SAO option is enabled, and for IO pages WIMG=01**.)
This hence initializes WIMG to non-zero value HPTE_R_M (0x10), as expected by pHyp.
[[email protected] - fix compile for 32-bit]
--- arch/powerpc/kvm/book3s_64_mmu.c | 1 + arch/powerpc/kvm/book3s_pr.c | 2 ++ 2 files changed, 3 insertions(+)
arch/powerpc/kvm/book3s_64_mmu.c +1 -0
@@ -235,6 +235,7 @@ static int kvmppc_mmu_book3s_64_xlate(st gpte->may_read = true; gpte->may_write = true; gpte->page_size =MMU_PAGE_4K ; + gpte->wimg =HPTE_R_M ;return 0 ; }
arch/powerpc/kvm/book3s_pr.c +2 -0
@@ -60,6 +60,7 @@ static void kvmppc_giveup_fac(struct kvm#define MSR_USER32 MSR_USER#define MSR_USER64 MSR_USER#define HW_PAGE_SIZE PAGE_SIZE +#define HPTE_R_M _PAGE_COHERENT#endif static bool kvmppc_is_split_real (struct kvm_vcpu *vcpu)
@@ -557,6 +558,7 @@ int kvmppc_handle_pagefault(struct kvm_r pte.eaddr = eaddr; pte.vpage = eaddr >>12 ; pte.page_size =MMU_PAGE_64K ; + pte.wimg =HPTE_R_M ; }switch (kvmppc_get_msr (vcpu) & (MSR_DR |MSR_IR )) {
Greg Kroah-Hartman
maintainerPATCH 63/118 KVM: PPC: Book3S HV: Drop prepare_done from struct kvm_resize_hpt
In reply to Greg Kroah-Hartman4.14-stable review patch. If anyone has any objections, please let me know.
------------------
From: Serhii Popovych <[email protected]>
commit 3073774e638ef18d222465fe92bfc8fccb90d288 upstream.
Currently the kvm_resize_hpt structure has two fields relevant to the state of an ongoing resize: 'prepare_done', which indicates whether the worker thread has completed or not, and 'error' which indicates whether it was successful or not.
Since the success/failure isn't known until completion, this is confusingly redundant. This patch consolidates the information into just the 'error' value: -EBUSY indicates the worked is still in progress, other negative values indicate (completed) failure, 0 indicates successful completion.
As a bonus this reduces size of struct kvm_resize_hpt by __alignof__(struct kvm_hpt_info) and saves few bytes of code.
While there correct comment in struct kvm_resize_hpt which references a non-existent semaphore (leftover from an early draft).
Assert with WARN_ON() in case of HPT allocation thread work runs more than once for resize request or resize_hpt_allocate() returns -EBUSY that is treated specially.
Change comparison against zero to make checkpatch.pl happy.
[dwg: Changed BUG_ON()s to WARN_ON()s and altered commit message for
clarity]
--- arch/powerpc/kvm/book3s_64_mmu_hv.c | 44 ++++++++++++++++++++++-------------- 1 file changed, 27 insertions(+), 17 deletions(-)
arch/powerpc/kvm/book3s_64_mmu_hv.c +27 -17
@@ -65,11 +65,17 @@ struct kvm_resize_hpt {u32 order;/* These fields protected by kvm->lock */ + +/* Possible values and their usage: +* <0 an error occurred during allocation, +* -EBUSY allocation is in the progress, +* 0 allocation made successfuly. +*/ int error; -bool prepare_done; -/* Private to the work thread, until prepare_done is true, -* then protected by kvm->resize_hpt_sem */ +/* Private to the work thread, until error != -EBUSY, +* then protected by kvm->lock. +*/ struct kvm_hpt_info hpt; };
@@ -1444,15 +1450,23 @@ static void resize_hpt_prepare_work(strustruct kvm *kvm = resize->kvm;int err; +if (WARN_ON (resize->error != -EBUSY )) +return ; +resize_hpt_debug (resize,"resize_hpt_prepare_work(): order = %d\n" , resize->order); err =resize_hpt_allocate (resize); +/* We have strict assumption about -EBUSY +* when preparing for HPT resize. +*/ +if (WARN_ON (err == -EBUSY )) + err = -EINPROGRESS ; +mutex_lock (&kvm->lock); resize->error = err; - resize->prepare_done = true;mutex_unlock (&kvm->lock); }
@@ -1477,14 +1491,12 @@ long kvm_vm_ioctl_resize_hpt_prepare(strif (resize) {if (resize->order == shift) { -/* Suitable resize in progress */ -if (resize->prepare_done) { - ret = resize->error; -if (ret !=0 ) -resize_hpt_release (kvm, resize); - }else { +/* Suitable resize in progress? */ + ret = resize->error; +if (ret == -EBUSY ) ret =100 ;/* estimated time in ms */ - } +else if (ret) +resize_hpt_release (kvm, resize); goto out; }
@@ -1504,6 +1516,8 @@ long kvm_vm_ioctl_resize_hpt_prepare(str ret = -ENOMEM ; goto out; } + + resize->error = -EBUSY ; resize->order = shift; resize->kvm = kvm;INIT_WORK (&resize->work, resize_hpt_prepare_work);
@@ -1558,16 +1572,12 @@ long kvm_vm_ioctl_resize_hpt_commit(struif (!resize || (resize->order != shift)) goto out; - ret = -EBUSY ; -if (!resize->prepare_done) - goto out; - ret = resize->error; -if (ret !=0 ) +if (ret) goto out; ret =resize_hpt_rehash (resize); -if (ret !=0 ) +if (ret) goto out;resize_hpt_pivot (resize);
Greg Kroah-Hartman
maintainerPATCH 64/118 KVM: PPC: Book3S HV: Fix use after free in case of multiple resize requests
In reply to Greg Kroah-Hartman4.14-stable review patch. If anyone has any objections, please let me know.
------------------
From: Serhii Popovych <[email protected]>
commit 4ed11aeefda439c76ddae3ceebcfa4fad111f149 upstream.
When serving multiple resize requests following could happen:
CPU0 CPU1
---- ----
kvm_vm_ioctl_resize_hpt_prepare(1);
-> schedule_work()
/* system_rq might be busy: delay */
kvm_vm_ioctl_resize_hpt_prepare(2);
mutex_lock();
if (resize) {
...
release_hpt_resize();
}
... resize_hpt_prepare_work()
-> schedule_work() {
mutex_unlock() /* resize->kvm could be wrong */
struct kvm *kvm = resize->kvm;
mutex_lock(&kvm->lock); <<<< UAF
...
}i.e. a second resize request with different order could be started by kvm_vm_ioctl_resize_hpt_prepare(), causing the previous request to be free()d when there's still an active worker thread which will try to access it. This leads to a use after free in point marked with UAF on the diagram above.
To prevent this from happening, instead of unconditionally releasing a pre-existing resize structure from the prepare ioctl(), we check if the existing structure has an in-progress worker. We do that by checking if the resize->error == -EBUSY, which is safe because the resize->error field is protected by the kvm->lock. If there is an active worker, instead of releasing, we mark the structure as stale by unlinking it from kvm_struct.
In the worker thread we check for a stale structure (with kvm->lock held), and in that case abort, releasing the stale structure ourself. We make the check both before and the actual allocation. Strictly, only the check afterwards is needed, the check before is an
optimization: if the structure happens to become stale before the worker thread is dispatched, rather than during the allocation, it means we can avoid allocating then immediately freeing a potentially substantial amount of memory.
This fixes following or similar host kernel crash message:
[ 635.277361] Unable to handle kernel paging request for data at address 0x00000000 [ 635.277438] Faulting instruction address: 0xc00000000052f568 [ 635.277446] Oops: Kernel access of bad area, sig: 11 [#1] [ 635.277451] SMP NR_CPUS=2048 NUMA PowerNV [ 635.277470] Modules linked in: xt_CHECKSUM iptable_mangle ipt_MASQUERADE
nf_nat_masquerade_ipv4 iptable_nat nf_nat_ipv4 nf_nat nf_conntrack_ipv4 nf_defrag_ipv4 xt_conntrack nf_conntrack ipt_REJECT nf_reject_ipv4 tun bridge stp llc ebtable_filter ebtables ip6table_filter ip6_tables iptable_filter nfsv3 nfs_acl nfs lockd grace fscache kvm_hv kvm rpcrdma sunrpc ib_isert iscsi_target_mod ib_iser libiscsi scsi_transport_iscsi ib_srpt target_core_mod ext4 ib_srp scsi_transport_srp ib_ipoib mbcache jbd2 rdma_ucm ib_ucm ib_uverbs ib_umad rdma_cm ib_cm iw_cm ocrdma(T) ib_core ses enclosure scsi_transport_sas sg shpchp leds_powernv ibmpowernv i2c_opal i2c_core powernv_rng ipmi_powernv ipmi_devintf ipmi_msghandler ip_tables xfs libcrc32c sr_mod sd_mod cdrom lpfc nvme_fc(T) nvme_fabrics nvme_core ipr nvmet_fc(T) tg3 nvmet libata be2net crc_t10dif crct10dif_generic scsi_transport_fc ptp scsi_tgt pps_core crct10dif_common dm_mirror dm_region_hash dm_log dm_mod
[ 635.278687] CPU: 40 PID: 749 Comm: kworker/40:1 Tainted: G ------------ T 3.10.0.bz1510771+ #1 [ 635.278782] Workqueue: events resize_hpt_prepare_work [kvm_hv] [ 635.278851] task: c0000007e6840000 ti: c0000007e9180000 task.ti: c0000007e9180000 [ 635.278919] NIP: c00000000052f568 LR: c0000000009ea310 CTR: c0000000009ea4f0 [ 635.278988] REGS: c0000007e91837f0 TRAP: 0300 Tainted: G ------------ T (3.10.0.bz1510771+) [ 635.279077] MSR: 9000000100009033 <SF,HV,EE,ME,IR,DR,RI,LE> CR: 24002022 XER: 00000000 [ 635.279248] CFAR: c000000000009368 DAR: 0000000000000000 DSISR: 40000000 SOFTE: 1
GPR00: c0000000009ea310 c0000007e9183a70 c000000001250b00 c0000007e9183b10
GPR04: 0000000000000000 0000000000000000 c0000007e9183650 0000000000000000
GPR08: c0000007ffff7b80 00000000ffffffff 0000000080000028 d00000000d2529a0
GPR12: 0000000000002200 c000000007b56800 c000000000120028 c0000007f135bb40
GPR16: 0000000000000000 c000000005c1e018 c000000005c1e018 0000000000000000
GPR20: 0000000000000001 c0000000011bf778 0000000000000001 fffffffffffffef7
GPR24: 0000000000000000 c000000f1e262e50 0000000000000002 c0000007e9180000
GPR28: c000000f1e262e4c c000000f1e262e50 0000000000000000 c0000007e9183b10
[ 635.280149] NIP [c00000000052f568] __list_add+0x38/0x110 [ 635.280197] LR [c0000000009ea310] __mutex_lock_slowpath+0xe0/0x2c0 [ 635.280253] Call Trace: [ 635.280277] [c0000007e9183af0] [c0000000009ea310] __mutex_lock_slowpath+0xe0/0x2c0 [ 635.280356] [c0000007e9183b70] [c0000000009ea554] mutex_lock+0x64/0x70 [ 635.280426] [c0000007e9183ba0] [d00000000d24da04] resize_hpt_prepare_work+0xe4/0x1c0 [kvm_hv] [ 635.280507] [c0000007e9183c40] [c000000000113c0c] process_one_work+0x1dc/0x680 [ 635.280587] [c0000007e9183ce0] [c000000000114250] worker_thread+0x1a0/0x520 [ 635.280655] [c0000007e9183d80] [c00000000012010c] kthread+0xec/0x100 [ 635.280724] [c0000007e9183e30] [c00000000000a4b8] ret_from_kernel_thread+0x5c/0xa4 [ 635.280814] Instruction dump: [ 635.280880] 7c0802a6 fba1ffe8 fbc1fff0 7cbd2b78 fbe1fff8 7c9e2378 7c7f1b78 f8010010 [ 635.281099] f821ff81 e8a50008 7fa52040 40de00b8 <e8be0000> 7fbd2840 40de008c 7fbff040 [ 635.281324] ---[ end trace b628b73449719b9d ]---
[dwg: Replaced BUG_ON()s with WARN_ONs() and reworded commit message
for clarity]
--- arch/powerpc/kvm/book3s_64_mmu_hv.c | 54 ++++++++++++++++++++++++------------ 1 file changed, 37 insertions(+), 17 deletions(-)
arch/powerpc/kvm/book3s_64_mmu_hv.c +37 -17
@@ -1430,16 +1430,20 @@ static void resize_hpt_pivot(struct kvm_static void resize_hpt_release (struct kvm *kvm,struct kvm_resize_hpt *resize) { -BUG_ON (kvm->arch.resize_hpt != resize); +if (WARN_ON (!mutex_is_locked (&kvm->lock))) +return ;if (!resize)return ; -if (resize->hpt.virt) -kvmppc_free_hpt (&resize->hpt); +if (resize->error != -EBUSY ) { +if (resize->hpt.virt) +kvmppc_free_hpt (&resize->hpt); +kfree (resize); + } - kvm->arch.resize_hpt =NULL ; -kfree (resize); +if (kvm->arch.resize_hpt == resize) + kvm->arch.resize_hpt =NULL ; }static void resize_hpt_prepare_work (struct work_struct *work)
@@ -1448,26 +1452,42 @@ static void resize_hpt_prepare_work(stru struct kvm_resize_hpt, work);struct kvm *kvm = resize->kvm; -int err; +int err =0 ;if (WARN_ON (resize->error != -EBUSY ))return ; -resize_hpt_debug (resize,"resize_hpt_prepare_work(): order = %d\n" , - resize->order); - - err =resize_hpt_allocate (resize); - -/* We have strict assumption about -EBUSY -* when preparing for HPT resize. -*/ -if (WARN_ON (err == -EBUSY )) - err = -EINPROGRESS ; -mutex_lock (&kvm->lock); +/* Request is still current? */ +if (kvm->arch.resize_hpt == resize) { +/* We may request large allocations here: +* do not sleep with kvm->lock held for a while. +*/ +mutex_unlock (&kvm->lock); + +resize_hpt_debug (resize,"resize_hpt_prepare_work(): order = %d\n" , + resize->order); + + err =resize_hpt_allocate (resize); + +/* We have strict assumption about -EBUSY +* when preparing for HPT resize. +*/ +if (WARN_ON (err == -EBUSY )) + err = -EINPROGRESS ; + +mutex_lock (&kvm->lock); +/* It is possible that kvm->arch.resize_hpt != resize +* after we grab kvm->lock again. +*/ + } + resize->error = err; +if (kvm->arch.resize_hpt != resize) +resize_hpt_release (kvm, resize); +mutex_unlock (&kvm->lock); }
Greg Kroah-Hartman
maintainerPATCH 65/118 KVM: PPC: Book3S HV: Always flush TLB in kvmppc_alloc_reset_hpt()
In reply to Greg Kroah-Hartman4.14-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Gibson <[email protected]>
commit ecba8297aafd50db6ae867e90844eead1611ef1c upstream.
The KVM_PPC_ALLOCATE_HTAB ioctl(), implemented by kvmppc_alloc_reset_hpt() is supposed to completely clear and reset a guest's Hashed Page Table (HPT) allocating or re-allocating it if necessary.
In the case where an HPT of the right size already exists and it just zeroes it, it forces a TLB flush on all guest CPUs, to remove any stale TLB entries loaded from the old HPT.
However, that situation can arise when the HPT is resizing as well - or even when switching from an RPT to HPT - so those cases need a TLB flush as well.
So, move the TLB flush to trigger in all cases except for errors.
--- arch/powerpc/kvm/book3s_64_mmu_hv.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
arch/powerpc/kvm/book3s_64_mmu_hv.c +4 -2
@@ -165,8 +165,6 @@ long kvmppc_alloc_reset_hpt(struct kvm ** Reset all the reverse-mapping chains for all memslots */ kvmppc_rmap_reset (kvm); -/* Ensure that each vcpu will flush its TLB on next entry. */ -cpumask_setall (&kvm->arch.need_tlb_flush); err =0 ; goto out; }
@@ -182,6 +180,10 @@ long kvmppc_alloc_reset_hpt(struct kvm *kvmppc_set_hpt (kvm, &info); out: +if (err ==0 ) +/* Ensure that each vcpu will flush its TLB on next entry. */ +cpumask_setall (&kvm->arch.need_tlb_flush); +mutex_unlock (&kvm->lock);return err; }
Greg Kroah-Hartman
maintainerPATCH 66/118 drm/vmwgfx: Dont cache framebuffer maps
In reply to Greg Kroah-Hartman4.14-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thomas Hellstrom <[email protected]>
commit 98648ae6ef6bdcdcb88c46cad963906ab452e96d upstream.
Buffer objects need to be either pinned or reserved while a map is active, that's not the case here, so avoid caching the framebuffer map. This will cause increasing mapping activity mainly when we don't do page flipping.
This fixes occasional garbage filled screens when the framebuffer has been evicted after the map.
Since in-kernel mapping of whole buffer objects is error-prone on 32-bit architectures and also quite inefficient, we will revisit this later.
--- drivers/gpu/drm/vmwgfx/vmwgfx_kms.c | 6 ----- drivers/gpu/drm/vmwgfx/vmwgfx_kms.h | 2 - drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c | 41 ++++++++++------------------------- 3 files changed, 13 insertions(+), 36 deletions(-)
drivers/gpu/drm/vmwgfx/vmwgfx_kms.c +0 -6
@@ -697,7 +697,6 @@ vmw_du_plane_duplicate_state(struct drm_ vps->pinned =0 ;/* Mapping is managed by prepare_fb/cleanup_fb */ -memset (&vps->guest_map,0 ,sizeof (vps->guest_map));memset (&vps->host_map,0 ,sizeof (vps->host_map)); vps->cpp =0 ;
@@ -760,11 +759,6 @@ vmw_du_plane_destroy_state(struct drm_pl/* Should have been freed by cleanup_fb */ -if (vps->guest_map.virtual) { -DRM_ERROR ("Guest mapping not freed\n" ); -ttm_bo_kunmap (&vps->guest_map); - } -if (vps->host_map.virtual) {DRM_ERROR ("Host mapping not freed\n" );ttm_bo_kunmap (&vps->host_map);
drivers/gpu/drm/vmwgfx/vmwgfx_kms.h +1 -1
@@ -175,7 +175,7 @@ struct vmw_plane_state {int pinned;/* For CPU Blit */ -struct ttm_bo_kmap_obj host_map, guest_map; +struct ttm_bo_kmap_obj host_map;unsigned int cpp; };
drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c +12 -29
94 lines not on this page · raw message
Greg Kroah-Hartman
maintainerPATCH 67/118 drm/vmwgfx: Potential off by one in vmw_view_add()
In reply to Greg Kroah-Hartman4.14-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dan Carpenter <[email protected]>
commit 0d9cac0ca0429830c40fe1a4e50e60f6221fd7b6 upstream.
The vmw_view_cmd_to_type() function returns vmw_view_max (3) on error. It's one element beyond the end of the vmw_view_cotables[] table.
My read on this is that it's possible to hit this failure. header->id comes from vmw_cmd_check() and it's a user controlled number between 1040 and 1225 so we can hit that error. But I don't have the hardware to test this code.
--- drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c +2 -0
@@ -2731,6 +2731,8 @@ static int vmw_cmd_dx_view_define(struct } view_type =vmw_view_cmd_to_type (header->id); +if (view_type == vmw_view_max) +return -EINVAL ; cmd =container_of (header,typeof (*cmd), header); ret = vmw_cmd_res_check(dev_priv, sw_context, vmw_res_surface, user_surface_converter,
Greg Kroah-Hartman
maintainerPATCH 68/118 drm/i915/gvt: Clear the shadow page table entry after post-sync
In reply to Greg Kroah-Hartman4.14-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zhi Wang <[email protected]>
commit 121d760d0788f95619049c63449d977065cab69d upstream.
A shadow page table entry needs to be cleared after being set as post-sync. This patch fixes the recent error reported in Win7-32 test.
--- drivers/gpu/drm/i915/gvt/gtt.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/gvt/gtt.c +4 -1
@@ -1359,12 +1359,15 @@ static int ppgtt_handle_guest_write_pagereturn ret; }else {if (!test_bit (index, spt->post_shadow_bitmap)) { +int type = spt->shadow_page.type; +ppgtt_get_shadow_entry (spt, &se, index); ret =ppgtt_handle_guest_entry_removal (gpt, &se, index);if (ret)return ret; + ops->set_pfn (&se, vgpu->gtt.scratch_pt[type].page_mfn); +ppgtt_set_shadow_entry (spt, &se, index); } -ppgtt_set_post_shadow (spt, index); }
Greg Kroah-Hartman
maintainerPATCH 69/118 drm/i915: Whitelist SLICE_COMMON_ECO_CHICKEN1 on Geminilake.
In reply to Greg Kroah-Hartman4.14-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kenneth Graunke <[email protected]>
commit 4636bda86aa1f34f45c629477476a0dcfa04e597 upstream.
Geminilake requires the 3D driver to select whether barriers are intended for compute shaders, or tessellation control shaders, by whacking a "Barrier Mode" bit in SLICE_COMMON_ECO_CHICKEN1 when switching pipelines. Failure to do this properly can result in GPU hangs.
Unfortunately, this means it needs to switch mid-batch, so only userspace can properly set it. To facilitate this, the kernel needs to whitelist the register.
The workarounds page currently tags this as applying to Broxton only, but that doesn't make sense. The documentation for the register it references says the bit userspace is supposed to toggle only exists on Geminilake. Empirically, the Mesa patch to toggle this bit appears to fix intermittent GPU hangs in tessellation control shader barrier tests on Geminilake; we haven't seen those hangs on Broxton.
v2: Mention WA #0862 in the comment (it doesn't have a name).
--- drivers/gpu/drm/i915/i915_reg.h | 2 ++ drivers/gpu/drm/i915/intel_engine_cs.c | 5 +++++ 2 files changed, 7 insertions(+)
drivers/gpu/drm/i915/i915_reg.h +2 -0
@@ -6987,6 +6987,8 @@ enum {#define GEN9_SLICE_COMMON_ECO_CHICKEN0 _MMIO(0x7308)#define DISABLE_PIXEL_MASK_CAMMING (1<<14) +#define GEN9_SLICE_COMMON_ECO_CHICKEN1 _MMIO(0x731c) +#define GEN7_L3SQCREG1 _MMIO(0xB010)#define VLV_B0_WA_L3SQCREG1_VALUE 0x00D30000
drivers/gpu/drm/i915/intel_engine_cs.c +5 -0
@@ -1125,6 +1125,11 @@ static int glk_init_workarounds(struct iif (ret)return ret; +/* WA #0862: Userspace has to set "Barrier Mode" to avoid hangs. */ + ret =wa_ring_whitelist_reg (engine,GEN9_SLICE_COMMON_ECO_CHICKEN1 ); +if (ret) +return ret; +/* WaToEnableHwFixForPushConstHWBug:glk */ WA_SET_BIT_MASKED (COMMON_SLICE_CHICKEN2 ,GEN8_SBE_DISABLE_REPLAY_BUF_OPTIMIZATION );
Greg Kroah-Hartman
maintainerPATCH 70/118 drm/i915: Move init_clock_gating() back to where it was
In reply to Greg Kroah-Hartman4.14-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ville Syrjälä <[email protected]>
commit 6ac43272768ca901daac4076a66c2c4e3c7b9321 upstream.
Apparently setting up a bunch of GT registers before we've properly initialized the rest of the GT hardware leads to these setting being lost. So looks like I broke HSW with commit b7048ea12fbb ("drm/i915:
Do .init_clock_gating() earlier to avoid it clobbering watermarks") by doing init_clock_gating() too early. This should actually affect other platforms as well, but apparently not to such a great degree.
What I was ultimately after in that commit was to move the ilk_init_lp_watermarks() call earlier. So let's undo the damage and move init_clock_gating() back to where it was, and call ilk_init_lp_watermarks() just before the watermark state readout.
This highlights how fragile and messed up our init order really is. I wonder why we even initialize the display before gem. The opposite order would make much more sense to me...
v2: Keep WaRsPkgCStateDisplayPMReq:hsw early as it really must
be done before all planes might get disabled.
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=103549
References: https://lists.freedesktop.org/archives/intel-gfx/2017-November/145432.html
--- drivers/gpu/drm/i915/intel_display.c | 14 +++++++++-- drivers/gpu/drm/i915/intel_pm.c | 44 ++++++++++++++--------------------- 2 files changed, 30 insertions(+), 28 deletions(-)
drivers/gpu/drm/i915/intel_display.c +12 -2
@@ -3800,6 +3800,7 @@ void intel_finish_reset(struct drm_i915_intel_pps_unlock_regs_wa (dev_priv);intel_modeset_init_hw (dev); +intel_init_clock_gating (dev_priv);spin_lock_irq (&dev_priv->irq_lock);if (dev_priv->display.hpd_irq_setup)
@@ -14406,8 +14407,6 @@ void intel_modeset_init_hw(struct drm_deintel_update_cdclk (dev_priv); dev_priv->cdclk.logical = dev_priv->cdclk.actual = dev_priv->cdclk.hw; - -intel_init_clock_gating (dev_priv); }/*
@@ -15124,6 +15123,15 @@ intel_modeset_setup_hw_state(struct drm_struct intel_encoder *encoder;int i; +if (IS_HASWELL (dev_priv)) { +/* +* WaRsPkgCStateDisplayPMReq:hsw +* System hang if this isn't done before disabling all planes! +*/ +I915_WRITE (CHICKEN_PAR1_1 , +I915_READ (CHICKEN_PAR1_1 ) |FORCE_ARB_IDLE_PLANES ); + } +intel_modeset_readout_hw_state (dev);/* HW state is read out, now we need to sanitize this mess. */
@@ -15220,6 +15228,8 @@ void intel_modeset_gem_init(struct drm_dintel_init_gt_powersave (dev_priv); +intel_init_clock_gating (dev_priv); +intel_setup_overlay (dev_priv); }
drivers/gpu/drm/i915/intel_pm.c +18 -26
98 lines not on this page · raw message
Greg Kroah-Hartman
maintainerPATCH 71/118 drm/i915: Fix init_clock_gating for resume
In reply to Greg Kroah-Hartman4.14-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ville Syrjälä <[email protected]>
commit 3572f04c69ed4369da5d3c65d84fb18774aa60b6 upstream.
Moving the init_clock_gating() call from intel_modeset_init_hw() to intel_modeset_gem_init() had an unintended effect of not applying some workarounds on resume. This, for example, cause some kind of corruption to appear at the top of my IVB Thinkpad X1 Carbon LVDS screen after hibernation. Fix the problem by explicitly calling init_clock_gating() from the resume path.
I really hope this doesn't break something else again. At least the problems reported at https://bugs.freedesktop.org/show_bug.cgi?id=103549
didn't make a comeback, even after a hibernate cycle.
v2: Reorder the init_clock_gating vs. modeset_init_hw to match
the display reset path (Rodrigo)
--- drivers/gpu/drm/i915/i915_drv.c | 1 + 1 file changed, 1 insertion(+)
drivers/gpu/drm/i915/i915_drv.c +1 -0
@@ -1693,6 +1693,7 @@ static int i915_drm_resume(struct drm_deintel_guc_resume (dev_priv);intel_modeset_init_hw (dev); +intel_init_clock_gating (dev_priv);spin_lock_irq (&dev_priv->irq_lock);if (dev_priv->display.hpd_irq_setup)
Greg Kroah-Hartman
maintainerPATCH 72/118 bpf: prevent out-of-bounds speculation
In reply to Greg Kroah-Hartman4.14-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alexei Starovoitov <[email protected]>
commit b2157399cc9898260d6031c5bfe45fe137c1fbe7 upstream.
Under speculation, CPUs may mis-predict branches in bounds checks. Thus, memory accesses under a bounds check may be speculated even if the bounds check fails, providing a primitive for building a side channel.
To avoid leaking kernel data round up array-based maps and mask the index after bounds check, so speculated load with out of bounds index will load either valid value from the array or zero from the padded area.
Unconditionally mask index for all array types even when max_entries are not rounded to power of 2 for root user.
When map is created by unpriv user generate a sequence of bpf insns that includes AND operation to make sure that JITed code includes the same 'index & index_mask' operation.
If prog_array map is created by unpriv user replace
bpf_tail_call(ctx, map, index);
with
if (index >= max_entries) {
index &= map->index_mask;
bpf_tail_call(ctx, map, index); }
(along with roundup to power 2) to prevent out-of-bounds speculation. There is secondary redundant 'if (index >= max_entries)' in the interpreter and in all JITs, but they can be optimized later if necessary.
Other array-like maps (cpumap, devmap, sockmap, perf_event_array, cgroup_array) cannot be used by unpriv, so no changes there.
That fixes bpf side of "Variant 1: bounds check bypass (CVE-2017-5753)" on all architectures with and without JIT.
v2->v3:
Daniel noticed that attack potentially can be crafted via syscall commands without loading the program, so add masking to those paths as well.
--- include/linux/bpf.h | 2 ++ kernel/bpf/arraymap.c | 47 ++++++++++++++++++++++++++++++++++++----------- kernel/bpf/verifier.c | 36 ++++++++++++++++++++++++++++++++++++ 3 files changed, 74 insertions(+), 11 deletions(-)
include/linux/bpf.h +2 -0
@@ -51,6 +51,7 @@ struct bpf_map {u32 pages;u32 id;int numa_node; +bool unpriv_array;struct user_struct *user;const struct bpf_map_ops *ops;struct work_struct work;
@@ -195,6 +196,7 @@ struct bpf_prog_aux {struct bpf_array {struct bpf_map map;u32 elem_size; +u32 index_mask;/* 'ownership' of prog_array is claimed by the first program that * is going to use this map or by the first program which FD is stored * in the map to make sure that all callers and callees have the same
kernel/bpf/arraymap.c +36 -11
125 lines not on this page · raw message
kernel/bpf/verifier.c +36 -0
@@ -1701,6 +1701,13 @@ static int check_call(struct bpf_verifie err =check_func_arg (env,BPF_REG_2 , fn->arg2_type, &meta);if (err)return err; +if (func_id == BPF_FUNC_tail_call) { +if (meta.map_ptr ==NULL ) { +verbose ("verifier bug\n" ); +return -EINVAL ; + } + env->insn_aux_data[insn_idx].map_ptr = meta.map_ptr; + } err =check_func_arg (env,BPF_REG_3 , fn->arg3_type, &meta);if (err)return err;
@@ -4315,6 +4322,35 @@ static int fixup_bpf_calls(struct bpf_ve*/ insn->imm =0 ; insn->code =BPF_JMP |BPF_TAIL_CALL ; + +/* instead of changing every JIT dealing with tail_call +* emit two extra insns: +* if (index >= max_entries) goto out; +* index &= array->index_mask; +* to avoid out-of-bounds cpu speculation +*/ + map_ptr = env->insn_aux_data[i + delta].map_ptr; +if (map_ptr ==BPF_MAP_PTR_POISON ) { +verbose ("tail_call obusing map_ptr\n" ); +return -EINVAL ; + } +if (!map_ptr->unpriv_array) +continue ; + insn_buf[0 ] =BPF_JMP_IMM (BPF_JGE ,BPF_REG_3 , + map_ptr->max_entries,2 ); + insn_buf[1 ] =BPF_ALU32_IMM (BPF_AND ,BPF_REG_3 , +container_of (map_ptr, + struct bpf_array, + map)->index_mask); + insn_buf[2 ] = *insn; + cnt =3 ; + new_prog =bpf_patch_insn_data (env, i + delta, insn_buf, cnt); +if (!new_prog) +return -ENOMEM ; + + delta += cnt -1 ; + env->prog = prog = new_prog; + insn = new_prog->insnsi + i + delta;continue ; }
Greg Kroah-Hartman
maintainerPATCH 73/118 bpf, array: fix overflow in max_entries and undefined behavior in index_mask
In reply to Greg Kroah-Hartman4.14-stable review patch. If anyone has any objections, please let me know.
------------------
From: Daniel Borkmann <[email protected]>
commit bbeb6e4323dad9b5e0ee9f60c223dd532e2403b1 upstream.
syzkaller tried to alloc a map with 0xfffffffd entries out of a userns, and thus unprivileged. With the recently added logic in b2157399cc98 ("bpf: prevent out-of-bounds speculation") we round this up to the next power of two value for max_entries for unprivileged such that we can apply proper masking into potentially zeroed out map slots.
However, this will generate an index_mask of 0xffffffff, and therefore a + 1 will let this overflow into new max_entries of 0. This will pass allocation, etc, and later on map access we still enforce on the original attr->max_entries value which was 0xfffffffd, therefore triggering GPF all over the place. Thus bail out on overflow in such case.
Moreover, on 32 bit archs roundup_pow_of_two() can also not be used, since fls_long(max_entries - 1) can result in 32 and 1UL << 32 in 32 bit space is undefined. Therefore, do this by hand in a 64 bit variable.
This fixes all the issues triggered by syzkaller's reproducers.
--- kernel/bpf/arraymap.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-)
kernel/bpf/arraymap.c +15 -3
@@ -53,7 +53,7 @@ static struct bpf_map *array_map_alloc(uu32 elem_size, index_mask, max_entries;bool unpriv = !capable (CAP_SYS_ADMIN );struct bpf_array *array; -u64 array_size; +u64 array_size, mask64;/* check sanity of attributes */ if (attr->max_entries == 0 || attr->key_size != 4 ||
@@ -70,13 +70,25 @@ static struct bpf_map *array_map_alloc(u elem_size =round_up (attr->value_size,8 ); max_entries = attr->max_entries; - index_mask =roundup_pow_of_two (max_entries) -1 ; -if (unpriv) +/* On 32 bit archs roundup_pow_of_two() with max_entries that has +* upper most bit set in u32 space is undefined behavior due to +* resulting 1U << 32, so do it manually here in u64 space. +*/ + mask64 =fls_long (max_entries -1 ); + mask64 =1ULL << mask64; + mask64 -=1 ; + + index_mask = mask64; +if (unpriv) {/* round up array size to nearest power of 2, * since cpu will speculate within index_mask limits */ max_entries = index_mask +1 ; +/* Check for overflows. */ +if (max_entries < attr->max_entries) +return ERR_PTR (-E2BIG ); + } array_size =sizeof (*array);if (percpu)
Greg Kroah-Hartman
maintainerPATCH 74/118 bpf: arsh is not supported in 32 bit alu thus reject it
In reply to Greg Kroah-Hartman4.14-stable review patch. If anyone has any objections, please let me know.
------------------
From: Daniel Borkmann <[email protected]>
commit 7891a87efc7116590eaba57acc3c422487802c6f upstream.
The following snippet was throwing an 'unknown opcode cc' warning in BPF interpreter:
0: (18) r0 = 0x0
2: (7b) *(u64 *)(r10 -16) = r0
3: (cc) (u32) r0 s>>= (u32) r0
4: (95) exit
Although a number of JITs do support BPF_ALU | BPF_ARSH | BPF_{K,X} generation, not all of them do and interpreter does neither. We can leave existing ones and implement it later in bpf-next for the remaining ones, but reject this properly in verifier for the time being.
--- kernel/bpf/verifier.c | 5 +++ tools/testing/selftests/bpf/test_verifier.c | 40 ++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+)
kernel/bpf/verifier.c +5 -0
@@ -2493,6 +2493,11 @@ static int check_alu_op(struct bpf_verifreturn -EINVAL ; } +if (opcode ==BPF_ARSH &&BPF_CLASS (insn->code) !=BPF_ALU64 ) { +verbose ("BPF_ARSH not supported for 32 bit ALU\n" ); +return -EINVAL ; + } +if ((opcode ==BPF_LSH || opcode ==BPF_RSH || opcode ==BPF_ARSH ) &&BPF_SRC (insn->code) ==BPF_K ) {int size =BPF_CLASS (insn->code) ==BPF_ALU64 ?64 :32 ;
tools/testing/selftests/bpf/test_verifier.c +40 -0
@@ -273,6 +273,46 @@ static struct bpf_test tests[] = { .result = REJECT, }, { + "arsh32 on imm", + .insns = { +BPF_MOV64_IMM (BPF_REG_0 ,1 ), +BPF_ALU32_IMM (BPF_ARSH ,BPF_REG_0 ,5 ), + BPF_EXIT_INSN(), + }, + .result =REJECT , + .errstr = "BPF_ARSH not supported for 32 bit ALU", + }, + { +"arsh32 on reg" , + .insns = { +BPF_MOV64_IMM (BPF_REG_0 ,1 ), +BPF_MOV64_IMM (BPF_REG_1 ,5 ), +BPF_ALU32_REG (BPF_ARSH ,BPF_REG_0 ,BPF_REG_1 ), + BPF_EXIT_INSN(), + }, + .result =REJECT , + .errstr = "BPF_ARSH not supported for 32 bit ALU", + }, + { +"arsh64 on imm" , + .insns = { +BPF_MOV64_IMM (BPF_REG_0 ,1 ), +BPF_ALU64_IMM (BPF_ARSH ,BPF_REG_0 ,5 ), + BPF_EXIT_INSN(), + }, + .result =ACCEPT , + }, + { +"arsh64 on reg" , + .insns = { +BPF_MOV64_IMM (BPF_REG_0 ,1 ), +BPF_MOV64_IMM (BPF_REG_1 ,5 ), +BPF_ALU64_REG (BPF_ARSH ,BPF_REG_0 ,BPF_REG_1 ), + BPF_EXIT_INSN(), + }, + .result =ACCEPT , + }, + {"no bpf_exit" , .insns = { BPF_ALU64_REG(BPF_MOV, BPF_REG_0, BPF_REG_2),
Greg Kroah-Hartman
maintainerPATCH 75/118 USB: serial: cp210x: add IDs for LifeScan OneTouch Verio IQ
In reply to Greg Kroah-Hartman4.14-stable review patch. If anyone has any objections, please let me know.
------------------
From: Diego Elio Pettenò <[email protected]>
commit 4307413256ac1e09b8f53e8715af3df9e49beec3 upstream.
Add IDs for the OneTouch Verio IQ that comes with an embedded USB-to-serial converter.
--- drivers/usb/serial/cp210x.c | 1 + 1 file changed, 1 insertion(+)
drivers/usb/serial/cp210x.c +1 -0
@@ -127,6 +127,7 @@ static const struct usb_device_id id_tab { USB_DEVICE(0x10C4, 0x8470) }, /* Juniper Networks BX Series System Console */ { USB_DEVICE(0x10C4, 0x8477) }, /* Balluff RFID */ { USB_DEVICE(0x10C4, 0x84B6) }, /* Starizona Hyperion */ + { USB_DEVICE(0x10C4, 0x85A7) }, /* LifeScan OneTouch Verio IQ */ { USB_DEVICE(0x10C4, 0x85EA) }, /* AC-Services IBUS-IF */ { USB_DEVICE(0x10C4, 0x85EB) }, /* AC-Services CIS-IBUS */ { USB_DEVICE(0x10C4, 0x85F8) }, /* Virtenio Preon32 */
Greg Kroah-Hartman
maintainerPATCH 76/118 USB: serial: cp210x: add new device ID ELV ALC 8xxx
In reply to Greg Kroah-Hartman4.14-stable review patch. If anyone has any objections, please let me know.
------------------
From: Christian Holl <[email protected]>
commit d14ac576d10f865970bb1324d337e5e24d79aaf4 upstream.
This adds the ELV ALC 8xxx Battery Charging device to the list of USB IDs of drivers/usb/serial/cp210x.c
--- drivers/usb/serial/cp210x.c | 1 + 1 file changed, 1 insertion(+)
drivers/usb/serial/cp210x.c +1 -0
@@ -178,6 +178,7 @@ static const struct usb_device_id id_tab { USB_DEVICE(0x1843, 0x0200) }, /* Vaisala USB Instrument Cable */ { USB_DEVICE(0x18EF, 0xE00F) }, /* ELV USB-I2C-Interface */ { USB_DEVICE(0x18EF, 0xE025) }, /* ELV Marble Sound Board 1 */ + { USB_DEVICE(0x18EF, 0xE030) }, /* ELV ALC 8xxx Battery Charger */ { USB_DEVICE(0x18EF, 0xE032) }, /* ELV TFD500 Data Logger */ { USB_DEVICE(0x1901, 0x0190) }, /* GE B850 CP2105 Recorder interface */ { USB_DEVICE(0x1901, 0x0193) }, /* GE B650 CP2104 PMC interface */
Greg Kroah-Hartman
maintainerPATCH 77/118 usb: misc: usb3503: make sure reset is low for at least 100us
In reply to Greg Kroah-Hartman4.14-stable review patch. If anyone has any objections, please let me know.
------------------
From: Stefan Agner <[email protected]>
commit b8626f1dc29d3eee444bfaa92146ec7b291ef41c upstream.
When using a GPIO which is high by default, and initialize the driver in USB Hub mode, initialization fails with:
[ 111.757794] usb3503 0-0008: SP_ILOCK failed (-5)
The reason seems to be that the chip is not properly reset. Probe does initialize reset low, however some lines later the code already set it back high, which is not long enouth.
Make sure reset is asserted for at least 100us by inserting a delay after initializing the reset pin during probe.
--- drivers/usb/misc/usb3503.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/usb/misc/usb3503.c +2 -0
@@ -292,6 +292,8 @@ static int usb3503_probe(struct usb3503if (gpio_is_valid (hub->gpio_reset)) { err =devm_gpio_request_one (dev, hub->gpio_reset,GPIOF_OUT_INIT_LOW ,"usb3503 reset" ); +/* Datasheet defines a hardware reset to be at least 100us */ +usleep_range (100 ,10000 );if (err) { dev_err(dev, "unable to request GPIO %d as reset pin (%d)\n",
Greg Kroah-Hartman
maintainerPATCH 78/118 USB: fix usbmon BUG trigger
In reply to Greg Kroah-Hartman4.14-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pete Zaitcev <[email protected]>
commit 46eb14a6e1585d99c1b9f58d0e7389082a5f466b upstream.
Automated tests triggered this by opening usbmon and accessing the mmap while simultaneously resizing the buffers. This bug was with us since 2006, because typically applications only size the buffers once and thus avoid racing. Reported by Kirill A. Shutemov.
--- drivers/usb/mon/mon_bin.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/usb/mon/mon_bin.c +7 -1
@@ -1004,7 +1004,9 @@ static long mon_bin_ioctl(struct file *fbreak ;case MON_IOCQ_RING_SIZE : +mutex_lock (&rp->fetch_lock); ret = rp->b_size; +mutex_unlock (&rp->fetch_lock);break ;case MON_IOCT_RING_SIZE :
@@ -1231,12 +1233,16 @@ static int mon_bin_vma_fault(struct vm_funsigned long offset, chunk_idx;struct page *pageptr; +mutex_lock (&rp->fetch_lock); offset = vmf->pgoff <<PAGE_SHIFT ; -if (offset >= rp->b_size) +if (offset >= rp->b_size) { +mutex_unlock (&rp->fetch_lock);return VM_FAULT_SIGBUS ; + } chunk_idx = offset /CHUNK_SIZE ; pageptr = rp->b_vec[chunk_idx].pg;get_page (pageptr); +mutex_unlock (&rp->fetch_lock); vmf->page = pageptr;return 0 ; }
Greg Kroah-Hartman
maintainerPATCH 79/118 USB: UDC core: fix double-free in usb_add_gadget_udc_release
In reply to Greg Kroah-Hartman4.14-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alan Stern <[email protected]>
commit 7ae2c3c280db183ca9ada2675c34ec2f7378abfa upstream.
The error-handling pathways in usb_add_gadget_udc_release() are messed up. Aside from the uninformative statement labels, they can deallocate the udc structure after calling put_device(), which is a double-free. This was observed by KASAN in automatic testing.
This patch cleans up the routine. It preserves the requirement that when any failure occurs, we call put_device(&gadget->dev).
--- drivers/usb/gadget/udc/core.c | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-)
drivers/usb/gadget/udc/core.c +13 -15
@@ -1158,11 +1158,7 @@ int usb_add_gadget_udc_release(struct de udc =kzalloc (sizeof (*udc),GFP_KERNEL );if (!udc) - goto err1; - - ret =device_add (&gadget->dev); -if (ret) - goto err2; + goto err_put_gadget;device_initialize (&udc->dev); udc->dev.release = usb_udc_release;
@@ -1171,7 +1167,11 @@ int usb_add_gadget_udc_release(struct de udc->dev.parent = parent; ret =dev_set_name (&udc->dev,"%s" ,kobject_name (&parent->kobj));if (ret) - goto err3; + goto err_put_udc; + + ret =device_add (&gadget->dev); +if (ret) + goto err_put_udc; udc->gadget = gadget; gadget->udc = udc;
@@ -1181,7 +1181,7 @@ int usb_add_gadget_udc_release(struct de ret =device_add (&udc->dev);if (ret) - goto err4; + goto err_unlist_udc;usb_gadget_set_state (gadget,USB_STATE_NOTATTACHED ); udc->vbus = true;
@@ -1189,27 +1189,25 @@ int usb_add_gadget_udc_release(struct de/* pick up one of pending gadget drivers */ ret =check_pending_gadget_drivers (udc);if (ret) - goto err5; + goto err_del_udc;mutex_unlock (&udc_lock);return 0 ; -err5: + err_del_udc:device_del (&udc->dev); -err4: + err_unlist_udc:list_del (&udc->list);mutex_unlock (&udc_lock); -err3: -put_device (&udc->dev);device_del (&gadget->dev); -err2: -kfree (udc); + err_put_udc: +put_device (&udc->dev); -err1: + err_put_gadget:put_device (&gadget->dev);return ret; }
Greg Kroah-Hartman
maintainerPATCH 80/118 usbip: remove kernel addresses from usb device and urb debug msgs
In reply to Greg Kroah-Hartman4.14-stable review patch. If anyone has any objections, please let me know.
------------------
From: Shuah Khan <[email protected]>
commit e1346fd87c71a1f61de1fe476ec8df1425ac931c upstream.
usbip_dump_usb_device() and usbip_dump_urb() print kernel addresses. Remove kernel addresses from usb device and urb debug msgs and improve the message content.
Instead of printing parent device and bus addresses, print parent device and bus names.
--- drivers/usb/usbip/usbip_common.c | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-)
drivers/usb/usbip/usbip_common.c +3 -14
@@ -105,7 +105,7 @@ static void usbip_dump_usb_device(structdev_dbg (dev," devnum(%d) devpath(%s) usb speed(%s)" , udev->devnum, udev->devpath,usb_speed_string (udev->speed)); -pr_debug ("tt %p, ttport %d\n" , udev->tt, udev->ttport); +pr_debug ("tt hub ttport %d\n" , udev->ttport);dev_dbg (dev," " );for (i =0 ; i <16 ; i++)
@@ -138,12 +138,8 @@ static void usbip_dump_usb_device(struct }pr_debug ("\n" ); -dev_dbg (dev,"parent %p, bus %p\n" , udev->parent, udev->bus); - -dev_dbg (dev, -"descriptor %p, config %p, actconfig %p, rawdescriptors %p\n" , - &udev->descriptor, udev->config, - udev->actconfig, udev->rawdescriptors); +dev_dbg (dev,"parent %s, bus %s\n" ,dev_name (&udev->parent->dev), + udev->bus->bus_name);dev_dbg (dev,"have_langid %d, string_langid %d\n" , udev->have_langid, udev->string_langid);
@@ -251,9 +247,6 @@ void usbip_dump_urb(struct urb *urb) dev = &urb->dev->dev; -dev_dbg (dev," urb :%p\n" , urb); -dev_dbg (dev," dev :%p\n" , urb->dev); -usbip_dump_usb_device (urb->dev);dev_dbg (dev," pipe :%08x " , urb->pipe);
@@ -262,11 +255,9 @@ void usbip_dump_urb(struct urb *urb)dev_dbg (dev," status :%d\n" , urb->status);dev_dbg (dev," transfer_flags :%08X\n" , urb->transfer_flags); -dev_dbg (dev," transfer_buffer :%p\n" , urb->transfer_buffer);dev_dbg (dev," transfer_buffer_length:%d\n" , urb->transfer_buffer_length);dev_dbg (dev," actual_length :%d\n" , urb->actual_length); -dev_dbg (dev," setup_packet :%p\n" , urb->setup_packet);if (urb->setup_packet &&usb_pipetype (urb->pipe) ==PIPE_CONTROL ) usbip_dump_usb_ctrlrequest(
@@ -276,8 +267,6 @@ void usbip_dump_urb(struct urb *urb)dev_dbg (dev," number_of_packets :%d\n" , urb->number_of_packets);dev_dbg (dev," interval :%d\n" , urb->interval);dev_dbg (dev," error_count :%d\n" , urb->error_count); -dev_dbg (dev," context :%p\n" , urb->context); -dev_dbg (dev," complete :%p\n" , urb->complete); }EXPORT_SYMBOL_GPL (usbip_dump_urb);
Greg Kroah-Hartman
maintainerPATCH 81/118 usbip: fix vudc_rx: harden CMD_SUBMIT path to handle malicious input
In reply to Greg Kroah-Hartman4.14-stable review patch. If anyone has any objections, please let me know.
------------------
From: Shuah Khan <[email protected]>
commit b78d830f0049ef1966dc1e0ebd1ec2a594e2cf25 upstream.
Harden CMD_SUBMIT path to handle malicious input that could trigger large memory allocations. Add checks to validate transfer_buffer_length and number_of_packets to protect against bad input requesting for unbounded memory allocations.
--- drivers/usb/usbip/vudc_rx.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)
drivers/usb/usbip/vudc_rx.c +19 -0
@@ -132,6 +132,25 @@ static int v_recv_cmd_submit(struct vudc urb_p->new =1 ; urb_p->seqnum = pdu->base.seqnum; +if (urb_p->ep->type ==USB_ENDPOINT_XFER_ISOC ) { +/* validate packet size and number of packets */ +unsigned int maxp, packets, bytes; + + maxp =usb_endpoint_maxp (urb_p->ep->desc); + maxp *=usb_endpoint_maxp_mult (urb_p->ep->desc); + bytes = pdu->u.cmd_submit.transfer_buffer_length; + packets =DIV_ROUND_UP (bytes, maxp); + +if (pdu->u.cmd_submit.number_of_packets <0 || + pdu->u.cmd_submit.number_of_packets > packets) { +dev_err (&udc->gadget.dev, +"CMD_SUBMIT: isoc invalid num packets %d\n" , + pdu->u.cmd_submit.number_of_packets); + ret = -EMSGSIZE ; + goto free_urbp; + } + } + ret =alloc_urb_from_cmd (&urb_p->urb, pdu, urb_p->ep->type);if (ret) {usbip_event_add (&udc->ud,VUDC_EVENT_ERROR_MALLOC );
Greg Kroah-Hartman
maintainerPATCH 82/118 usbip: vudc_tx: fix v_send_ret_submit() vulnerability to null xfer buffer
In reply to Greg Kroah-Hartman4.14-stable review patch. If anyone has any objections, please let me know.
------------------
From: Shuah Khan <[email protected]>
commit 5fd77a3a0e408c23ab4002a57db980e46bc16e72 upstream.
v_send_ret_submit() handles urb with a null transfer_buffer, when it replays a packet with potential malicious data that could contain a null buffer.
Add a check for the condition when actual_length > 0 and transfer_buffer is null.
--- drivers/usb/usbip/vudc_tx.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
drivers/usb/usbip/vudc_tx.c +9 -2
@@ -97,6 +97,13 @@ static int v_send_ret_submit(struct vudcmemset (&pdu_header,0 ,sizeof (pdu_header));memset (&msg,0 ,sizeof (msg)); +if (urb->actual_length >0 && !urb->transfer_buffer) { +dev_err (&udc->gadget.dev, +"urb: actual_length %d transfer_buffer null\n" , + urb->actual_length); +return -1 ; + } +if (urb_p->type ==USB_ENDPOINT_XFER_ISOC ) iovnum =2 + urb->number_of_packets;else
@@ -112,8 +119,8 @@ static int v_send_ret_submit(struct vudc/* 1. setup usbip_header */ setup_ret_submit_pdu (&pdu_header, urb_p); -usbip_dbg_stub_tx ("setup txdata seqnum: %d urb: %p\n" , - pdu_header.base.seqnum, urb); +usbip_dbg_stub_tx ("setup txdata seqnum: %d\n" , + pdu_header.base.seqnum);usbip_header_correct_endian (&pdu_header,1 ); iov[iovnum].iov_base = &pdu_header;
Greg Kroah-Hartman
maintainerPATCH 83/118 staging: android: ashmem: fix a race condition in ASHMEM_SET_SIZE ioctl
In reply to Greg Kroah-Hartman4.14-stable review patch. If anyone has any objections, please let me know.
------------------
From: Viktor Slavkovic <[email protected]>
commit 443064cb0b1fb4569fe0a71209da7625129fb760 upstream.
A lock-unlock is missing in ASHMEM_SET_SIZE ioctl which can result in a race condition when mmap is called. After the !asma->file check, before setting asma->size, asma->file can be set in mmap. That would result in having different asma->size than the mapped memory size. Combined with ASHMEM_UNPIN ioctl and shrinker invocation, this can result in memory corruption.
--- drivers/staging/android/ashmem.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/staging/android/ashmem.c +2 -0
@@ -765,10 +765,12 @@ static long ashmem_ioctl(struct file *fibreak ;case ASHMEM_SET_SIZE : ret = -EINVAL ; +mutex_lock (&ashmem_mutex);if (!asma->file) { ret =0 ; asma->size = (size_t )arg; } +mutex_unlock (&ashmem_mutex);break ;case ASHMEM_GET_SIZE : ret = asma->size;
Greg Kroah-Hartman
maintainerPATCH 84/118 Bluetooth: Prevent stack info leak from the EFS element.
In reply to Greg Kroah-Hartman4.14-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ben Seri <[email protected]>
commit 06e7e776ca4d36547e503279aeff996cbb292c16 upstream.
In the function l2cap_parse_conf_rsp and in the function l2cap_parse_conf_req the following variable is declared without initialization:
struct l2cap_conf_efs efs;
In addition, when parsing input configuration parameters in both of these functions, the switch case for handling EFS elements may skip the memcpy call that will write to the efs variable:
...
case L2CAP_CONF_EFS:
if (olen == sizeof(efs))memcpy(&efs, (void *)val, olen);
...
The olen in the above if is attacker controlled, and regardless of that if, in both of these functions the efs variable would eventually be added to the outgoing configuration request that is being built:
l2cap_add_conf_opt(&ptr, L2CAP_CONF_EFS, sizeof(efs), (unsigned long) &efs);
So by sending a configuration request, or response, that contains an L2CAP_CONF_EFS element, but with an element length that is not sizeof(efs) - the memcpy to the uninitialized efs variable can be avoided, and the uninitialized variable would be returned to the attacker (16 bytes).
This issue has been assigned CVE-2017-1000410
--- net/bluetooth/l2cap_core.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-)
net/bluetooth/l2cap_core.c +11 -9
@@ -3363,9 +3363,10 @@ static int l2cap_parse_conf_req(struct lbreak ;case L2CAP_CONF_EFS : - remote_efs =1 ; -if (olen ==sizeof (efs)) +if (olen ==sizeof (efs)) { + remote_efs =1 ;memcpy (&efs, (void *) val, olen); + }break ;case L2CAP_CONF_EWS :
@@ -3584,16 +3585,17 @@ static int l2cap_parse_conf_rsp(struct lbreak ;case L2CAP_CONF_EFS : -if (olen ==sizeof (efs)) +if (olen ==sizeof (efs)) {memcpy (&efs, (void *)val, olen); -if (chan->local_stype !=L2CAP_SERV_NOTRAFIC && - efs.stype !=L2CAP_SERV_NOTRAFIC && - efs.stype != chan->local_stype) -return -ECONNREFUSED ; +if (chan->local_stype !=L2CAP_SERV_NOTRAFIC && + efs.stype !=L2CAP_SERV_NOTRAFIC && + efs.stype != chan->local_stype) +return -ECONNREFUSED ; -l2cap_add_conf_opt (&ptr,L2CAP_CONF_EFS ,sizeof (efs), - (unsigned long ) &efs, endptr - ptr); +l2cap_add_conf_opt (&ptr,L2CAP_CONF_EFS ,sizeof (efs), + (unsigned long ) &efs, endptr - ptr); + }break ;case L2CAP_CONF_FCS :
Greg Kroah-Hartman
maintainerPATCH 85/118 uas: ignore UAS for Norelsys NS1068(X) chips
In reply to Greg Kroah-Hartman4.14-stable review patch. If anyone has any objections, please let me know.
------------------
From: Icenowy Zheng <[email protected]>
commit 928afc85270753657b5543e052cc270c279a3fe9 upstream.
The UAS mode of Norelsys NS1068(X) is reported to fail to work on several platforms with the following error message:
xhci-hcd xhci-hcd.0.auto: ERROR Transfer event for unknown stream ring slot 1 ep 8 xhci-hcd xhci-hcd.0.auto: @00000000bf04a400 00000000 00000000 1b000000 01098001
And when trying to mount a partition on the disk the disk will disconnect from the USB controller, then after re-connecting the device will be offlined and not working at all.
Falling back to USB mass storage can solve this problem, so ignore UAS function of this chip.
--- drivers/usb/storage/unusual_uas.h | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/usb/storage/unusual_uas.h +7 -0
@@ -156,6 +156,13 @@ UNUSUAL_DEV(0x2109, 0x0711, 0x0000, 0x99 USB_SC_DEVICE, USB_PR_DEVICE, NULL, US_FL_NO_ATA_1X), +/* Reported-by: Icenowy Zheng <[email protected]> */ +UNUSUAL_DEV (0x2537 ,0x1068 ,0x0000 ,0x9999 , +"Norelsys" , +"NS1068X" , +USB_SC_DEVICE ,USB_PR_DEVICE ,NULL , +US_FL_IGNORE_UAS ), +/* Reported-by: Takeo Nakayama <[email protected]> */ UNUSUAL_DEV(0x357d, 0x7788, 0x0000, 0x9999, "JMicron",
Greg Kroah-Hartman
maintainerPATCH 86/118 mux: core: fix double get_device()
In reply to Greg Kroah-Hartman4.14-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hans de Goede <[email protected]>
commit aa1f10e85b0ab53dee85d8e293c8159d18d293a8 upstream.
class_find_device already does a get_device on the returned device. So the device returned by of_find_mux_chip_by_node is already referenced and we should not reference it again (and unref it on error).
--- drivers/mux/core.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/mux/core.c +3 -1
@@ -413,6 +413,7 @@ static int of_dev_node_match(struct devireturn dev->of_node == data; } +/* Note this function returns a reference to the mux_chip dev. */ static struct mux_chip *of_find_mux_chip_by_node (struct device_node *np) {struct device *dev;
@@ -466,6 +467,7 @@ struct mux_control *mux_control_get(stru (!args.args_count && (mux_chip->controllers > 1))) {dev_err (dev,"%pOF: wrong #mux-control-cells for %pOF\n" , np, args.np); +put_device (&mux_chip->dev);return ERR_PTR (-EINVAL ); }
@@ -476,10 +478,10 @@ struct mux_control *mux_control_get(struif (controller >= mux_chip->controllers) {dev_err (dev,"%pOF: bad mux controller %u specified in %pOF\n" , np, controller, args.np); +put_device (&mux_chip->dev);return ERR_PTR (-EINVAL ); } -get_device (&mux_chip->dev);return &mux_chip->mux[controller]; }EXPORT_SYMBOL_GPL (mux_control_get);
Greg Kroah-Hartman
maintainerPATCH 87/118 kdump: write correct address of mem_section into vmcoreinfo
In reply to Greg Kroah-Hartman4.14-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kirill A. Shutemov <[email protected]>
commit a0b1280368d1e91ab72f849ef095b4f07a39bbf1 upstream.
Depending on configuration mem_section can now be an array or a pointer to an array allocated dynamically. In most cases, we can continue to refer to it as 'mem_section' regardless of what it is.
But there's one exception: '&mem_section' means "address of the array" if mem_section is an array, but if mem_section is a pointer, it would mean "address of the pointer".
We've stepped onto this in kdump code. VMCOREINFO_SYMBOL(mem_section) writes down address of pointer into vmcoreinfo, not array as we wanted.
Let's introduce VMCOREINFO_SYMBOL_ARRAY() that would handle the situation correctly for both cases.
--- include/linux/crash_core.h | 2 ++ kernel/crash_core.c | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-)
include/linux/crash_core.h +2 -0
@@ -42,6 +42,8 @@ phys_addr_t paddr_vmcoreinfo_note(void); vmcoreinfo_append_str("PAGESIZE=%ld\n", value)#define VMCOREINFO_SYMBOL (name) \ vmcoreinfo_append_str("SYMBOL(%s)=%lx\n", #name, (unsigned long)&name) +#define VMCOREINFO_SYMBOL_ARRAY (name) \ + vmcoreinfo_append_str("SYMBOL(%s)=%lx\n", #name, (unsigned long)name)#define VMCOREINFO_SIZE (name) \ vmcoreinfo_append_str("SIZE(%s)=%lu\n", #name, \ (unsigned long)sizeof(name))
kernel/crash_core.c +1 -1
@@ -409,7 +409,7 @@ static int __init crash_save_vmcoreinfo_VMCOREINFO_SYMBOL (contig_page_data);#endif #ifdef CONFIG_SPARSEMEM -VMCOREINFO_SYMBOL (mem_section); +VMCOREINFO_SYMBOL_ARRAY (mem_section);VMCOREINFO_LENGTH (mem_section,NR_SECTION_ROOTS );VMCOREINFO_STRUCT_SIZE (mem_section);VMCOREINFO_OFFSET (mem_section, section_mem_map);
Greg Kroah-Hartman
maintainerPATCH 88/118 apparmor: fix ptrace label match when matching stacked labels
In reply to Greg Kroah-Hartman4.14-stable review patch. If anyone has any objections, please let me know.
------------------
From: John Johansen <[email protected]>
commit 0dda0b3fb255048a221f736c8a2a24c674da8bf3 upstream.
Given a label with a profile stack of
A//&B or A//&C ...
A ptrace rule should be able to specify a generic trace pattern with a rule like
ptrace trace A//&**,
however this is failing because while the correct label match routine is called, it is being done post label decomposition so it is always being done against a profile instead of the stacked label.
To fix this refactor the cross check to pass the full peer label in to the label_match.
--- security/apparmor/include/perms.h | 3 ++ security/apparmor/ipc.c | 53 ++++++++++++++++++++++---------------- 2 files changed, 35 insertions(+), 21 deletions(-)
security/apparmor/include/perms.h +3 -0
@@ -133,6 +133,9 @@ extern struct aa_perms allperms; #define xcheck_labels_profiles(L1, L2, FN, args...) \ xcheck_ns_labels((L1), (L2), xcheck_ns_profile_label, (FN), args) +#define xcheck_labels (L1 ,L2 ,P ,FN1 ,FN2 ) \ + xcheck(fn_for_each((L1), (P), (FN1)), fn_for_each((L2), (P), (FN2))) +void aa_perm_mask_to_str (char *str,const char *chrs,u32 mask);void aa_audit_perm_names (struct audit_buffer *ab,const char **names,u32 mask);
security/apparmor/ipc.c +32 -21
82 lines not on this page · raw message
Greg Kroah-Hartman
maintainerPATCH 89/118 e1000e: Fix e1000_check_for_copper_link_ich8lan return value.
In reply to Greg Kroah-Hartman4.14-stable review patch. If anyone has any objections, please let me know.
------------------
From: Benjamin Poirier <[email protected]>
commit 4110e02eb45ea447ec6f5459c9934de0a273fb91 upstream.
e1000e_check_for_copper_link() and e1000_check_for_copper_link_ich8lan() are the two functions that may be assigned to mac.ops.check_for_link when phy.media_type == e1000_media_type_copper. Commit 19110cfbb34d ("e1000e:
Separate signaling for link check/link up") changed the meaning of the return value of check_for_link for copper media but only adjusted the first function. This patch adjusts the second function likewise.
--- drivers/net/ethernet/intel/e1000e/ich8lan.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)
drivers/net/ethernet/intel/e1000e/ich8lan.c +8 -3
@@ -1367,6 +1367,9 @@ out:* Checks to see of the link status of the hardware has changed. If a * change in link status has been detected, then we read the PHY registers * to get the current speed/duplex if link exists. +* +* Returns a negative error code (-E1000_ERR_*) or 0 (link down) or 1 (link +* up). **/ static s32 e1000_check_for_copper_link_ich8lan (struct e1000_hw *hw) {
@@ -1382,7 +1385,7 @@ static s32 e1000_check_for_copper_link_i* Change or Rx Sequence Error interrupt. */ if (!mac->get_link_status) -return 0 ; +return 1 ;/* First we want to see if the MII Status Register reports * link. If so, then we want to get the current speed/duplex
@@ -1613,10 +1616,12 @@ static s32 e1000_check_for_copper_link_i* different link partner. */ ret_val =e1000e_config_fc_after_link_up (hw); -if (ret_val) +if (ret_val) {e_dbg ("Error configuring flow control\n" ); +return ret_val; + } -return ret_val; +return 1 ; }static s32 e1000_get_variants_ich8lan (struct e1000_adapter *adapter)
Greg Kroah-Hartman
maintainerPATCH 90/118 x86/pti: Unbreak EFI old_memmap
In reply to Greg Kroah-Hartman4.14-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiri Kosina <[email protected]>
commit de53c3786a3ce162a1c815d0c04c766c23ec9c0a upstream.
EFI_OLD_MEMMAP's efi_call_phys_prolog() calls set_pgd() with swapper PGD that has PAGE_USER set, which makes PTI set NX on it, and therefore EFI can't execute it's code.
Fix that by forcefully clearing _PAGE_NX from the PGD (this can't be done by the pgprot API).
_PAGE_NX will be automatically reintroduced in efi_call_phys_epilog(), as _set_pgd() will again notice that this is _PAGE_USER, and set _PAGE_NX on it.
--- arch/x86/platform/efi/efi_64.c | 2 ++ 1 file changed, 2 insertions(+)
arch/x86/platform/efi/efi_64.c +2 -0
@@ -134,7 +134,9 @@ pgd_t * __init efi_call_phys_prolog(void pud[j] = *pud_offset (p4d_k, vaddr); } } +pgd_offset_k (pgd *PGDIR_SIZE )->pgd &= ~_PAGE_NX; } + out:__flush_tlb_all ();
Greg Kroah-Hartman
maintainerPATCH 91/118 x86/Documentation: Add PTI description
In reply to Greg Kroah-Hartman4.14-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dave Hansen <[email protected]>
commit 01c9b17bf673b05bb401b76ec763e9730ccf1376 upstream.
Add some details about how PTI works, what some of the downsides are, and how to debug it when things go wrong.
Also document the kernel parameter: 'pti/nopti'.
--- Documentation/admin-guide/kernel-parameters.txt | 21 +- Documentation/x86/pti.txt | 186 ++++++++++++++++++++++++ 2 files changed, 200 insertions(+), 7 deletions(-)
Documentation/admin-guide/kernel-parameters.txt +14 -7
@@ -2685,8 +2685,6 @@ steal time is computed, but won't influence scheduler behaviour - nopti [X86-64] Disable kernel page table isolation - nolapic [X86-32,APIC] Do not enable or use the local APIC. nolapic_timer [X86-32,APIC] Do not use the local APIC timer.
@@ -3255,11 +3253,20 @@ pt. [PARIDE] See Documentation/blockdev/paride.txt. - pti= [X86_64] - Control user/kernel address space isolation: - on - enable - off - disable - auto - default setting + pti= [X86_64] Control Page Table Isolation of user and + kernel address spaces. Disabling this feature + removes hardening, but improves performance of + system calls and interrupts. + + on - unconditionally enable + off - unconditionally disable + auto - kernel detects whether your CPU model is + vulnerable to issues that PTI mitigates + + Not specifying this option is equivalent to pti=auto. + + nopti [X86_64] + Equivalent to pti=off pty.legacy_count= [KNL] Number of legacy pty's. Overwrites compiled-in
Documentation/x86/pti.txt new file +186 -0
186 lines not on this page · raw message
Greg Kroah-Hartman
maintainerPATCH 92/118 x86/cpufeatures: Add X86_BUG_SPECTRE_V[12]
In reply to Greg Kroah-Hartman4.14-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Woodhouse <[email protected]>
commit 99c6fa2511d8a683e61468be91b83f85452115fa upstream.
Add the bug bits for spectre v1/2 and force them unconditionally for all cpus.
--- arch/x86/include/asm/cpufeatures.h | 2 ++ arch/x86/kernel/cpu/common.c | 3 +++ 2 files changed, 5 insertions(+)
arch/x86/include/asm/cpufeatures.h +2 -0
@@ -342,5 +342,7 @@#define X86_BUG_MONITOR X86_BUG(12)/* IPI required to wake up remote CPU */ #define X86_BUG_AMD_E400 X86_BUG(13)/* CPU is among the affected by Erratum 400 */ #define X86_BUG_CPU_MELTDOWN X86_BUG(14)/* CPU is affected by meltdown attack and needs kernel page table isolation */ +#define X86_BUG_SPECTRE_V1 X86_BUG(15)/* CPU is affected by Spectre variant 1 attack with conditional branches */ +#define X86_BUG_SPECTRE_V2 X86_BUG(16)/* CPU is affected by Spectre variant 2 attack with indirect branches */ #endif /* _ASM_X86_CPUFEATURES_H */
arch/x86/kernel/cpu/common.c +3 -0
@@ -902,6 +902,9 @@ static void __init early_identify_cpu(stif (c->x86_vendor !=X86_VENDOR_AMD )setup_force_cpu_bug (X86_BUG_CPU_MELTDOWN ); +setup_force_cpu_bug (X86_BUG_SPECTRE_V1 ); +setup_force_cpu_bug (X86_BUG_SPECTRE_V2 ); +fpu__init_system (c);#ifdef CONFIG_X86_32
Greg Kroah-Hartman
maintainerPATCH 93/118 sysfs/cpu: Add vulnerability folder
In reply to Greg Kroah-Hartman4.14-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thomas Gleixner <[email protected]>
commit 87590ce6e373d1a5401f6539f0c59ef92dd924a9 upstream.
As the meltdown/spectre problem affects several CPU architectures, it makes sense to have common way to express whether a system is affected by a particular vulnerability or not. If affected the way to express the mitigation should be common as well.
Create /sys/devices/system/cpu/vulnerabilities folder and files for meltdown, spectre_v1 and spectre_v2.
Allow architectures to override the show function.
--- Documentation/ABI/testing/sysfs-devices-system-cpu | 16 +++++++ drivers/base/Kconfig | 3 + drivers/base/cpu.c | 48 +++++++++++++++++++++ include/linux/cpu.h | 7 +++ 4 files changed, 74 insertions(+)
Documentation/ABI/testing/sysfs-devices-system-cpu +16 -0
@@ -373,3 +373,19 @@ Contact: Linux kernel mailing list <linu Description: information about CPUs heterogeneity. cpu_capacity: capacity of cpu#. + +What: /sys/devices/system/cpu/vulnerabilities + /sys/devices/system/cpu/vulnerabilities/meltdown + /sys/devices/system/cpu/vulnerabilities/spectre_v1 + /sys/devices/system/cpu/vulnerabilities/spectre_v2 +Date: Januar 2018 +Contact: Linux kernel mailing list <[email protected]> +Description: Information about CPU vulnerabilities + + The files are named after the code names of CPU + vulnerabilities. The output of those files reflects the + state of the CPUs in the system. Possible output values: + + "Not affected" CPU is not affected by the vulnerability + "Vulnerable" CPU is affected and no mitigation in effect + "Mitigation: $M" CPU is affetcted and mitigation $M is in effect
drivers/base/Kconfig +3 -0
@@ -236,6 +236,9 @@ config GENERIC_CPU_DEVICES config GENERIC_CPU_AUTOPROBE bool +config GENERIC_CPU_VULNERABILITIES + bool + config SOC_BUS bool select GLOB
drivers/base/cpu.c +48 -0
58 lines not on this page · raw message
include/linux/cpu.h +7 -0
@@ -47,6 +47,13 @@ extern void cpu_remove_dev_attr(struct dextern int cpu_add_dev_attr_group (struct attribute_group *attrs);extern void cpu_remove_dev_attr_group (struct attribute_group *attrs); +extern ssize_t cpu_show_meltdown (struct device *dev, +struct device_attribute *attr,char *buf); +extern ssize_t cpu_show_spectre_v1 (struct device *dev, +struct device_attribute *attr,char *buf); +extern ssize_t cpu_show_spectre_v2 (struct device *dev, +struct device_attribute *attr,char *buf); + extern __printf(4, 5) struct device *cpu_device_create(struct device *parent, void *drvdata, const struct attribute_group **groups,
Greg Kroah-Hartman
maintainerPATCH 94/118 x86/cpu: Implement CPU vulnerabilites sysfs functions
In reply to Greg Kroah-Hartman4.14-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thomas Gleixner <[email protected]>
commit 61dc0f555b5c761cdafb0ba5bd41ecf22d68a4c4 upstream.
Implement the CPU vulnerabilty show functions for meltdown, spectre_v1 and spectre_v2.
--- arch/x86/Kconfig | 1 + arch/x86/kernel/cpu/bugs.c | 29 +++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+)
arch/x86/Kconfig +1 -0
@@ -89,6 +89,7 @@ config X86 select GENERIC_CLOCKEVENTS_MIN_ADJUST select GENERIC_CMOS_UPDATE select GENERIC_CPU_AUTOPROBE + select GENERIC_CPU_VULNERABILITIES select GENERIC_EARLY_IOREMAP select GENERIC_FIND_FIRST_BIT select GENERIC_IOMAP
arch/x86/kernel/cpu/bugs.c +29 -0
@@ -10,6 +10,7 @@*/ #include <linux/init.h> #include <linux/utsname.h> +#include <linux/cpu.h> #include <asm/bugs.h> #include <asm/processor.h> #include <asm/processor-flags.h>
@@ -60,3 +61,31 @@ void __init check_bugs(void)set_memory_4k ((unsigned long )__va (0 ),1 );#endif } + +#ifdef CONFIG_SYSFS +ssize_t cpu_show_meltdown (struct device *dev, +struct device_attribute *attr,char *buf) +{ +if (!boot_cpu_has_bug (X86_BUG_CPU_MELTDOWN )) +return sprintf (buf,"Not affected\n" ); +if (boot_cpu_has (X86_FEATURE_PTI )) +return sprintf (buf,"Mitigation: PTI\n" ); +return sprintf (buf,"Vulnerable\n" ); +} + +ssize_t cpu_show_spectre_v1 (struct device *dev, +struct device_attribute *attr,char *buf) +{ +if (!boot_cpu_has_bug (X86_BUG_SPECTRE_V1 )) +return sprintf (buf,"Not affected\n" ); +return sprintf (buf,"Vulnerable\n" ); +} + +ssize_t cpu_show_spectre_v2 (struct device *dev, +struct device_attribute *attr,char *buf) +{ +if (!boot_cpu_has_bug (X86_BUG_SPECTRE_V2 )) +return sprintf (buf,"Not affected\n" ); +return sprintf (buf,"Vulnerable\n" ); +} +#endif
Greg Kroah-Hartman
maintainerPATCH 95/118 x86/tboot: Unbreak tboot with PTI enabled
In reply to Greg Kroah-Hartman4.14-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dave Hansen <[email protected]>
commit 262b6b30087246abf09d6275eb0c0dc421bcbe38 upstream.
This is another case similar to what EFI does: create a new set of page tables, map some code at a low address, and jump to it. PTI mistakes this low address for userspace and mistakenly marks it non-executable in an effort to make it unusable for userspace.
Undo the poison to allow execution.
--- arch/x86/kernel/tboot.c | 1 + 1 file changed, 1 insertion(+)
arch/x86/kernel/tboot.c +1 -0
@@ -127,6 +127,7 @@ static int map_tboot_page(unsigned long p4d =p4d_alloc (&tboot_mm, pgd, vaddr);if (!p4d)return -1 ; + pgd->pgd &= ~_PAGE_NX; pud =pud_alloc (&tboot_mm, p4d, vaddr);if (!pud)return -1 ;
Greg Kroah-Hartman
maintainerPATCH 96/118 x86/mm/pti: Remove dead logic in pti_user_pagetable_walk*()
In reply to Greg Kroah-Hartman4.14-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jike Song <[email protected]>
commit 8d56eff266f3e41a6c39926269c4c3f58f881a8e upstream.
The following code contains dead logic:
162 if (pgd_none(*pgd)) {
163 unsigned long new_p4d_page = __get_free_page(gfp);
164 if (!new_p4d_page)
165 return NULL;
166
167 if (pgd_none(*pgd)) {
168 set_pgd(pgd, __pgd(_KERNPG_TABLE | __pa(new_p4d_page)));
169 new_p4d_page = 0;
170 }
171 if (new_p4d_page)
172 free_page(new_p4d_page);
173 }
There can't be any difference between two pgd_none(*pgd) at L162 and L167, so it's always false at L171.
Dave Hansen explained:
Yes, the double-test was part of an optimization where we attempted to avoid using a global spinlock in the fork() path. We would check for unallocated mid-level page tables without the lock. The lock was only taken when we needed to *make* an entry to avoid collisions.
Now that it is all single-threaded, there is no chance of a collision, no need for a lock, and no need for the re-check.
As all these functions are only called during init, mark them __init as well.
--- arch/x86/mm/pti.c | 32 ++++++-------------------------- 1 file changed, 6 insertions(+), 26 deletions(-)
arch/x86/mm/pti.c +6 -26
@@ -149,7 +149,7 @@ pgd_t __pti_set_user_pgd(pgd_t *pgdp, pg* * Returns a pointer to a P4D on success, or NULL on failure. */ -static p4d_t *pti_user_pagetable_walk_p4d (unsigned long address) +static __init p4d_t *pti_user_pagetable_walk_p4d (unsigned long address) {pgd_t *pgd =kernel_to_user_pgdp (pgd_offset_k (address));gfp_t gfp = (GFP_KERNEL | __GFP_NOTRACK | __GFP_ZERO);
@@ -164,12 +164,7 @@ static p4d_t *pti_user_pagetable_walk_p4if (!new_p4d_page)return NULL ; -if (pgd_none (*pgd)) { -set_pgd (pgd,__pgd (_KERNPG_TABLE |__pa (new_p4d_page))); - new_p4d_page =0 ; - } -if (new_p4d_page) -free_page (new_p4d_page); +set_pgd (pgd,__pgd (_KERNPG_TABLE |__pa (new_p4d_page))); }BUILD_BUG_ON (pgd_large (*pgd) !=0 );
@@ -182,7 +177,7 @@ static p4d_t *pti_user_pagetable_walk_p4* * Returns a pointer to a PMD on success, or NULL on failure. */ -static pmd_t *pti_user_pagetable_walk_pmd (unsigned long address) +static __init pmd_t *pti_user_pagetable_walk_pmd (unsigned long address) {gfp_t gfp = (GFP_KERNEL | __GFP_NOTRACK | __GFP_ZERO);p4d_t *p4d =pti_user_pagetable_walk_p4d (address);
@@ -194,12 +189,7 @@ static pmd_t *pti_user_pagetable_walk_pmif (!new_pud_page)return NULL ; -if (p4d_none (*p4d)) { -set_p4d (p4d,__p4d (_KERNPG_TABLE |__pa (new_pud_page))); - new_pud_page =0 ; - } -if (new_pud_page) -free_page (new_pud_page); +set_p4d (p4d,__p4d (_KERNPG_TABLE |__pa (new_pud_page))); } pud =pud_offset (p4d, address);
@@ -213,12 +203,7 @@ static pmd_t *pti_user_pagetable_walk_pmif (!new_pmd_page)return NULL ; -if (pud_none (*pud)) { -set_pud (pud,__pud (_KERNPG_TABLE |__pa (new_pmd_page))); - new_pmd_page =0 ; - } -if (new_pmd_page) -free_page (new_pmd_page); +set_pud (pud,__pud (_KERNPG_TABLE |__pa (new_pmd_page))); }return pmd_offset (pud, address);
@@ -251,12 +236,7 @@ static __init pte_t *pti_user_pagetable_if (!new_pte_page)return NULL ; -if (pmd_none (*pmd)) { -set_pmd (pmd,__pmd (_KERNPG_TABLE |__pa (new_pte_page))); - new_pte_page =0 ; - } -if (new_pte_page) -free_page (new_pte_page); +set_pmd (pmd,__pmd (_KERNPG_TABLE |__pa (new_pte_page))); } pte =pte_offset_kernel (pmd, address);
Greg Kroah-Hartman
maintainerPATCH 97/118 x86/cpu/AMD: Make LFENCE a serializing instruction
In reply to Greg Kroah-Hartman4.14-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tom Lendacky <[email protected]>
commit e4d0e84e490790798691aaa0f2e598637f1867ec upstream.
To aid in speculation control, make LFENCE a serializing instruction since it has less overhead than MFENCE. This is done by setting bit 1 of MSR 0xc0011029 (DE_CFG). Some families that support LFENCE do not have this MSR. For these families, the LFENCE instruction is already serializing.
--- arch/x86/include/asm/msr-index.h | 2 ++ arch/x86/kernel/cpu/amd.c | 10 ++++++++++ 2 files changed, 12 insertions(+)
arch/x86/include/asm/msr-index.h +2 -0
@@ -352,6 +352,8 @@#define FAM10H_MMIO_CONF_BASE_MASK 0xfffffffULL#define FAM10H_MMIO_CONF_BASE_SHIFT 20#define MSR_FAM10H_NODE_ID 0xc001100c +#define MSR_F10H_DECFG 0xc0011029 +#define MSR_F10H_DECFG_LFENCE_SERIALIZE_BIT 1/* K8 MSRs */ #define MSR_K8_TOP_MEM1 0xc001001a
arch/x86/kernel/cpu/amd.c +10 -0
@@ -829,6 +829,16 @@ static void init_amd(struct cpuinfo_x86set_cpu_cap (c,X86_FEATURE_K8 );if (cpu_has (c,X86_FEATURE_XMM2 )) { +/* +* A serializing LFENCE has less overhead than MFENCE, so +* use it for execution serialization. On families which +* don't have that MSR, LFENCE is already serializing. +* msr_set_bit() uses the safe accessors, too, even if the MSR +* is not present. +*/ +msr_set_bit (MSR_F10H_DECFG , +MSR_F10H_DECFG_LFENCE_SERIALIZE_BIT ); +/* MFENCE stops RDTSC speculation */ set_cpu_cap (c,X86_FEATURE_MFENCE_RDTSC ); }
Greg Kroah-Hartman
maintainerPATCH 98/118 x86/cpu/AMD: Use LFENCE_RDTSC in preference to MFENCE_RDTSC
In reply to Greg Kroah-Hartman4.14-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tom Lendacky <[email protected]>
commit 9c6a73c75864ad9fa49e5fa6513e4c4071c0e29f upstream.
With LFENCE now a serializing instruction, use LFENCE_RDTSC in preference to MFENCE_RDTSC. However, since the kernel could be running under a hypervisor that does not support writing that MSR, read the MSR back and verify that the bit has been set successfully. If the MSR can be read and the bit is set, then set the LFENCE_RDTSC feature, otherwise set the MFENCE_RDTSC feature.
--- arch/x86/include/asm/msr-index.h | 1 + arch/x86/kernel/cpu/amd.c | 18 ++++++++++++++++-- 2 files changed, 17 insertions(+), 2 deletions(-)
arch/x86/include/asm/msr-index.h +1 -0
@@ -354,6 +354,7 @@#define MSR_FAM10H_NODE_ID 0xc001100c#define MSR_F10H_DECFG 0xc0011029#define MSR_F10H_DECFG_LFENCE_SERIALIZE_BIT 1 +#define MSR_F10H_DECFG_LFENCE_SERIALIZE BIT_ULL(MSR_F10H_DECFG_LFENCE_SERIALIZE_BIT)/* K8 MSRs */ #define MSR_K8_TOP_MEM1 0xc001001a
arch/x86/kernel/cpu/amd.c +16 -2
@@ -829,6 +829,9 @@ static void init_amd(struct cpuinfo_x86set_cpu_cap (c,X86_FEATURE_K8 );if (cpu_has (c,X86_FEATURE_XMM2 )) { +unsigned long long val; +int ret; +/* * A serializing LFENCE has less overhead than MFENCE, so * use it for execution serialization. On families which
@@ -839,8 +842,19 @@ static void init_amd(struct cpuinfo_x86msr_set_bit (MSR_F10H_DECFG ,MSR_F10H_DECFG_LFENCE_SERIALIZE_BIT ); -/* MFENCE stops RDTSC speculation */ -set_cpu_cap (c,X86_FEATURE_MFENCE_RDTSC ); +/* +* Verify that the MSR write was successful (could be running +* under a hypervisor) and only then assume that LFENCE is +* serializing. +*/ + ret =rdmsrl_safe (MSR_F10H_DECFG , &val); +if (!ret && (val &MSR_F10H_DECFG_LFENCE_SERIALIZE )) { +/* A serializing LFENCE stops RDTSC speculation */ +set_cpu_cap (c,X86_FEATURE_LFENCE_RDTSC ); + }else { +/* MFENCE stops RDTSC speculation */ +set_cpu_cap (c,X86_FEATURE_MFENCE_RDTSC ); + } }/*
Greg Kroah-Hartman
maintainerPATCH 99/118 sysfs/cpu: Fix typos in vulnerability documentation
In reply to Greg Kroah-Hartman4.14-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Woodhouse <[email protected]>
commit 9ecccfaa7cb5249bd31bdceb93fcf5bedb8a24d8 upstream.
--- Documentation/ABI/testing/sysfs-devices-system-cpu | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
Documentation/ABI/testing/sysfs-devices-system-cpu +2 -2
@@ -378,7 +378,7 @@ What: /sys/devices/system/cpu/vulnerabi /sys/devices/system/cpu/vulnerabilities/meltdown /sys/devices/system/cpu/vulnerabilities/spectre_v1 /sys/devices/system/cpu/vulnerabilities/spectre_v2 -Date: Januar 2018 +Date: January 2018 Contact: Linux kernel mailing list <[email protected]> Description: Information about CPU vulnerabilities
@@ -388,4 +388,4 @@ Description: Information about CPU vulne "Not affected" CPU is not affected by the vulnerability "Vulnerable" CPU is affected and no mitigation in effect - "Mitigation: $M" CPU is affetcted and mitigation $M is in effect + "Mitigation: $M" CPU is affected and mitigation $M is in effect
Greg Kroah-Hartman
maintainerPATCH 100/118 x86/alternatives: Fix optimize_nops() checking
In reply to Greg Kroah-Hartman4.14-stable review patch. If anyone has any objections, please let me know.
------------------
From: Borislav Petkov <[email protected]>
commit 612e8e9350fd19cae6900cf36ea0c6892d1a0dca upstream.
The alternatives code checks only the first byte whether it is a NOP, but with NOPs in front of the payload and having actual instructions after it breaks the "optimized' test.
Make sure to scan all bytes before deciding to optimize the NOPs in there.
--- arch/x86/kernel/alternative.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
arch/x86/kernel/alternative.c +5 -2
@@ -344,9 +344,12 @@ done: static void __init_or_module noinline optimize_nops(struct alt_instr *a, u8 *instr) {unsigned long flags; +int i; -if (instr[0 ] !=0x90 ) -return ; +for (i =0 ; i < a->padlen; i++) { +if (instr[i] !=0x90 ) +return ; + }local_irq_save (flags);add_nops (instr + (a->instrlen - a->padlen), a->padlen);
Greg Kroah-Hartman
maintainerPATCH 101/118 x86/pti: Make unpoison of pgd for trusted boot work for real
In reply to Greg Kroah-Hartman4.14-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dave Hansen <[email protected]>
commit 445b69e3b75e42362a5bdc13c8b8f61599e2228a upstream.
The inital fix for trusted boot and PTI potentially misses the pgd clearing if pud_alloc() sets a PGD. It probably works in *practice* because for two adjacent calls to map_tboot_page() that share a PGD entry, the first will clear NX, *then* allocate and set the PGD (without NX clear). The second call will *not* allocate but will clear the NX bit.
Defer the NX clearing to a point after it is known that all top-level allocations have occurred. Add a comment to clarify why.
[ tglx: Massaged changelog ]
--- arch/x86/kernel/tboot.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)
arch/x86/kernel/tboot.c +11 -1
@@ -127,7 +127,6 @@ static int map_tboot_page(unsigned long p4d =p4d_alloc (&tboot_mm, pgd, vaddr);if (!p4d)return -1 ; - pgd->pgd &= ~_PAGE_NX; pud =pud_alloc (&tboot_mm, p4d, vaddr);if (!pud)return -1 ;
@@ -139,6 +138,17 @@ static int map_tboot_page(unsigned longreturn -1 ;set_pte_at (&tboot_mm, vaddr, pte,pfn_pte (pfn, prot));pte_unmap (pte); + +/* +* PTI poisons low addresses in the kernel page tables in the +* name of making them unusable for userspace. To execute +* code at such a low address, the poison must be cleared. +* +* Note: 'pgd' actually gets set in p4d_alloc() _or_ +* pud_alloc() depending on 4/5-level paging. +*/ + pgd->pgd &= ~_PAGE_NX; +return 0 ; }
Greg Kroah-Hartman
maintainerPATCH 102/118 objtool: Detect jumps to retpoline thunks
In reply to Greg Kroah-Hartman4.14-stable review patch. If anyone has any objections, please let me know.
------------------
From: Josh Poimboeuf <[email protected]>
commit 39b735332cb8b33a27c28592d969e4016c86c3ea upstream.
A direct jump to a retpoline thunk is really an indirect jump in disguise. Change the objtool instruction type accordingly.
Objtool needs to know where indirect branches are so it can detect switch statement jump tables.
This fixes a bunch of warnings with CONFIG_RETPOLINE like:
arch/x86/events/intel/uncore_nhmex.o: warning: objtool: nhmex_rbox_msr_enable_event()+0x44: sibling call from callable instruction with modified stack frame kernel/signal.o: warning: objtool: copy_siginfo_to_user()+0x91: sibling call from callable instruction with modified stack frame
...
--- tools/objtool/check.c | 7 +++++++ 1 file changed, 7 insertions(+)
tools/objtool/check.c +7 -0
@@ -456,6 +456,13 @@ static int add_jump_destinations(struct }else if (rela->sym->sec->idx) { dest_sec = rela->sym->sec; dest_off = rela->sym->sym.st_value + rela->addend +4 ; + }else if (strstr (rela->sym->name,"_indirect_thunk_" )) { +/* +* Retpoline jumps are really dynamic jumps in +* disguise, so convert them accordingly. +*/ + insn->type =INSN_JUMP_DYNAMIC ; +continue ; }else {/* sibling call */ insn->jump_dest =0 ;
Greg Kroah-Hartman
maintainerPATCH 103/118 objtool: Allow alternatives to be ignored
In reply to Greg Kroah-Hartman4.14-stable review patch. If anyone has any objections, please let me know.
------------------
From: Josh Poimboeuf <[email protected]>
commit 258c76059cece01bebae098e81bacb1af2edad17 upstream.
Getting objtool to understand retpolines is going to be a bit of a challenge. For now, take advantage of the fact that retpolines are patched in with alternatives. Just read the original (sane) non-alternative instruction, and ignore the patched-in retpoline.
This allows objtool to understand the control flow *around* the retpoline, even if it can't yet follow what's inside. This means the ORC unwinder will fail to unwind from inside a retpoline, but will work fine otherwise.
--- tools/objtool/check.c | 62 +++++++++++++++++++++++++++++++++++++++++++++----- tools/objtool/check.h | 2 - 2 files changed, 57 insertions(+), 7 deletions(-)
tools/objtool/check.c +56 -6
@@ -428,6 +428,40 @@ static void add_ignores(struct objtool_f }/* +* FIXME: For now, just ignore any alternatives which add retpolines. This is +* a temporary hack, as it doesn't allow ORC to unwind from inside a retpoline. +* But it at least allows objtool to understand the control flow *around* the +* retpoline. +*/ +static int add_nospec_ignores (struct objtool_file *file) +{ +struct section *sec; +struct rela *rela; +struct instruction *insn; + + sec =find_section_by_name (file->elf,".rela.discard.nospec" ); +if (!sec) +return 0 ; + +list_for_each_entry (rela, &sec->rela_list, list) { +if (rela->sym->type !=STT_SECTION ) { +WARN ("unexpected relocation symbol type in %s" , sec->name); +return -1 ; + } + + insn =find_insn (file, rela->sym->sec, rela->addend); +if (!insn) { +WARN ("bad .discard.nospec entry" ); +return -1 ; + } + + insn->ignore_alts = true; + } + +return 0 ; +} + +/* * Find the destination instructions for all jumps. */ static int add_jump_destinations (struct objtool_file *file)
@@ -509,11 +543,18 @@ static int add_call_destinations(struct dest_off = insn->offset + insn->len + insn->immediate; insn->call_dest =find_symbol_by_offset (insn->sec, dest_off); +/* +* FIXME: Thanks to retpolines, it's now considered +* normal for a function to call within itself. So +* disable this warning for now. +*/ +#if 0 if (!insn->call_dest) {WARN_FUNC ("can't find call dest symbol at offset 0x%lx" , insn->sec, insn->offset, dest_off);return -1 ; } +#endif }else if (rela->sym->type ==STT_SECTION ) { insn->call_dest =find_symbol_by_offset (rela->sym->sec, rela->addend+4 );
@@ -678,12 +719,6 @@ static int add_special_section_alts(strureturn ret;list_for_each_entry_safe (special_alt, tmp, &special_alts, list) { - alt =malloc (sizeof (*alt)); -if (!alt) { -WARN ("malloc failed" ); - ret =-1 ; - goto out; - } orig_insn =find_insn (file, special_alt->orig_sec, special_alt->orig_off);
@@ -694,6 +729,10 @@ static int add_special_section_alts(stru goto out; } +/* Ignore retpoline alternatives. */ +if (orig_insn->ignore_alts) +continue ; + new_insn =NULL ;if (!special_alt->group || special_alt->new_len) { new_insn = find_insn(file, special_alt->new_sec,
@@ -719,6 +758,13 @@ static int add_special_section_alts(stru goto out; } + alt =malloc (sizeof (*alt)); +if (!alt) { +WARN ("malloc failed" ); + ret =-1 ; + goto out; + } + alt->insn = new_insn;list_add_tail (&alt->list, &orig_insn->alts);
@@ -1035,6 +1081,10 @@ static int decode_sections(struct objtooadd_ignores (file); + ret =add_nospec_ignores (file); +if (ret) +return ret; + ret =add_jump_destinations (file);if (ret)return ret;
tools/objtool/check.h +1 -1
@@ -44,7 +44,7 @@ struct instruction {unsigned int len;unsigned char type;unsigned long immediate; -bool alt_group, visited, dead_end, ignore, hint, save, restore; +bool alt_group, visited, dead_end, ignore, hint, save, restore, ignore_alts;struct symbol *call_dest;struct instruction *jump_dest;struct list_head alts;
Greg Kroah-Hartman
maintainerPATCH 104/118 x86/retpoline: Add initial retpoline support
In reply to Greg Kroah-Hartman4.14-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Woodhouse <[email protected]>
commit 76b043848fd22dbf7f8bf3a1452f8c70d557b860 upstream.
Enable the use of -mindirect-branch=thunk-extern in newer GCC, and provide the corresponding thunks. Provide assembler macros for invoking the thunks in the same way that GCC does, from native and inline assembler.
This adds X86_FEATURE_RETPOLINE and sets it by default on all CPUs. In some circumstances, IBRS microcode features may be used instead, and the retpoline can be disabled.
On AMD CPUs if lfence is serialising, the retpoline can be dramatically simplified to a simple "lfence; jmp *\reg". A future patch, after it has been verified that lfence really is serialising in all circumstances, can enable this by setting the X86_FEATURE_RETPOLINE_AMD feature bit in addition to X86_FEATURE_RETPOLINE.
Do not align the retpoline in the altinstr section, because there is no guarantee that it stays aligned when it's copied over the oldinstr during alternative patching.
[ Andi Kleen: Rename the macros, add CONFIG_RETPOLINE option, export thunks] [ tglx: Put actual function CALL/JMP in front of the macros, convert to
symbolic labels ]
[ dwmw2: Convert back to numeric labels, merge objtool fixes ]
--- arch/x86/Kconfig | 13 +++ arch/x86/Makefile | 10 ++ arch/x86/include/asm/asm-prototypes.h | 25 ++++++ arch/x86/include/asm/cpufeatures.h | 2 arch/x86/include/asm/nospec-branch.h | 128 ++++++++++++++++++++++++++++++++++ arch/x86/kernel/cpu/common.c | 4 + arch/x86/lib/Makefile | 1 arch/x86/lib/retpoline.S | 48 ++++++++++++ 8 files changed, 231 insertions(+)
arch/x86/Kconfig +13 -0
@@ -429,6 +429,19 @@ config GOLDFISH def_bool y depends on X86_GOLDFISH +config RETPOLINE + bool "Avoid speculative indirect branches in kernel" + default y + help + Compile kernel with the retpoline compiler options to guard against + kernel-to-user data leaks by avoiding speculative indirect + 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. + config INTEL_RDT bool "Intel Resource Director Technology support" default n
arch/x86/Makefile +10 -0
@@ -235,6 +235,16 @@ KBUILD_CFLAGS += -Wno-sign-compare # KBUILD_CFLAGS += -fno-asynchronous-unwind-tables +# Avoid indirect branches in kernel to deal with Spectre +ifdef CONFIG_RETPOLINE + RETPOLINE_CFLAGS += $(call cc-option,-mindirect-branch=thunk-extern -mindirect-branch-register) + ifneq ($(RETPOLINE_CFLAGS),) + KBUILD_CFLAGS += $(RETPOLINE_CFLAGS) -DRETPOLINE + else + $(warning CONFIG_RETPOLINE=y, but not supported by the compiler. Toolchain update recommended.) + endif +endif + archscripts: scripts_basic $(Q)$(MAKE) $(build)=arch/x86/tools relocs
arch/x86/include/asm/asm-prototypes.h +25 -0
@@ -11,7 +11,32 @@#include <asm/pgtable.h> #include <asm/special_insns.h> #include <asm/preempt.h> +#include <asm/asm.h> #ifndef CONFIG_X86_CMPXCHG64 extern void cmpxchg8b_emu (void );#endif + +#ifdef CONFIG_RETPOLINE +#ifdef CONFIG_X86_32 +#define INDIRECT_THUNK (reg) extern asmlinkage void __x86_indirect_thunk_e ## reg(void); +#else +#define INDIRECT_THUNK (reg) extern asmlinkage void __x86_indirect_thunk_r ## reg(void); +INDIRECT_THUNK(8) +INDIRECT_THUNK(9) +INDIRECT_THUNK(10) +INDIRECT_THUNK(11) +INDIRECT_THUNK(12) +INDIRECT_THUNK(13) +INDIRECT_THUNK(14) +INDIRECT_THUNK(15) +#endif +INDIRECT_THUNK(ax) +INDIRECT_THUNK(bx) +INDIRECT_THUNK(cx) +INDIRECT_THUNK(dx) +INDIRECT_THUNK(si) +INDIRECT_THUNK(di) +INDIRECT_THUNK(bp) +INDIRECT_THUNK(sp) +#endif /* CONFIG_RETPOLINE */
arch/x86/include/asm/cpufeatures.h +2 -0
@@ -203,6 +203,8 @@#define X86_FEATURE_PROC_FEEDBACK ( 7*32+ 9)/* AMD ProcFeedbackInterface */ #define X86_FEATURE_SME ( 7*32+10)/* AMD Secure Memory Encryption */ #define X86_FEATURE_PTI ( 7*32+11)/* Kernel Page Table Isolation enabled */ +#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_INTEL_PPIN ( 7*32+14)/* Intel Processor Inventory Number */ #define X86_FEATURE_INTEL_PT ( 7*32+15)/* Intel Processor Trace */ #define X86_FEATURE_AVX512_4VNNIW ( 7*32+16)/* AVX-512 Neural Network Instructions */
arch/x86/include/asm/nospec-branch.h new file +128 -0
128 lines not on this page · raw message
arch/x86/kernel/cpu/common.c +4 -0
@@ -905,6 +905,10 @@ static void __init early_identify_cpu(stsetup_force_cpu_bug (X86_BUG_SPECTRE_V1 );setup_force_cpu_bug (X86_BUG_SPECTRE_V2 ); +#ifdef CONFIG_RETPOLINE +setup_force_cpu_cap (X86_FEATURE_RETPOLINE ); +#endif +fpu__init_system (c);#ifdef CONFIG_X86_32
arch/x86/lib/Makefile +1 -0
@@ -26,6 +26,7 @@ lib-y += memcpy_$(BITS).o lib-$(CONFIG_RWSEM_XCHGADD_ALGORITHM) += rwsem.o lib-$(CONFIG_INSTRUCTION_DECODER) += insn.o inat.o lib-$(CONFIG_RANDOMIZE_BASE) += kaslr.o +lib-$(CONFIG_RETPOLINE) += retpoline.o obj-y += msr.o msr-reg.o msr-reg-export.o hweight.o
arch/x86/lib/retpoline.S new file +48 -0
48 lines not on this page · raw message
Greg Kroah-Hartman
maintainerPATCH 105/118 x86/spectre: Add boot time option to select Spectre v2 mitigation
In reply to Greg Kroah-Hartman4.14-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Woodhouse <[email protected]>
commit da285121560e769cc31797bba6422eea71d473e0 upstream.
Add a spectre_v2= option to select the mitigation used for the indirect branch speculation vulnerability.
Currently, the only option available is retpoline, in its various forms. This will be expanded to cover the new IBRS/IBPB microcode features.
The RETPOLINE_AMD feature relies on a serializing LFENCE for speculation control. For AMD hardware, only set RETPOLINE_AMD if LFENCE is a serializing instruction, which is indicated by the LFENCE_RDTSC feature.
[ tglx: Folded back the LFENCE/AMD fixes and reworked it so IBRS
integration becomes simple ]
--- Documentation/admin-guide/kernel-parameters.txt | 28 ++++ arch/x86/include/asm/nospec-branch.h | 10 + arch/x86/kernel/cpu/bugs.c | 158 +++++++++++++++++++++++- arch/x86/kernel/cpu/common.c | 4 4 files changed, 195 insertions(+), 5 deletions(-)
Documentation/admin-guide/kernel-parameters.txt +28 -0
@@ -2599,6 +2599,11 @@ nosmt [KNL,S390] Disable symmetric multithreading (SMT). Equivalent to smt=1. + nospectre_v2 [X86] Disable all mitigations for the Spectre variant 2 + (indirect branch prediction) vulnerability. System may + allow data leaks with this option, which is equivalent + to spectre_v2=off. + noxsave [BUGS=X86] Disables x86 extended register state save and restore using xsave. The kernel will fallback to enabling legacy floating-point and sse state.
@@ -3908,6 +3913,29 @@ sonypi.*= [HW] Sony Programmable I/O Control Device driver See Documentation/laptops/sonypi.txt + spectre_v2= [X86] Control mitigation of Spectre variant 2 + (indirect branch speculation) vulnerability. + + on - unconditionally enable + off - unconditionally disable + auto - kernel detects whether your CPU model is + vulnerable + + Selecting 'on' will, and 'auto' may, choose a + mitigation method at run time according to the + CPU, the available microcode, the setting of the + CONFIG_RETPOLINE configuration option, and the + compiler with which the kernel was built. + + Specific mitigations can also be selected manually: + + retpoline - replace indirect branches + retpoline,generic - google's original retpoline + retpoline,amd - AMD-specific minimal thunk + + Not specifying this option is equivalent to + spectre_v2=auto. + spia_io_base= [HW,MTD] spia_fio_base= spia_pedr=
arch/x86/include/asm/nospec-branch.h +10 -0
@@ -124,5 +124,15 @@# define THUNK_TARGET (addr) [thunk_target] "rm" (addr)#endif +/* The Spectre V2 mitigation variants */ +enum spectre_v2_mitigation { +SPECTRE_V2_NONE , +SPECTRE_V2_RETPOLINE_MINIMAL , +SPECTRE_V2_RETPOLINE_MINIMAL_AMD , +SPECTRE_V2_RETPOLINE_GENERIC , +SPECTRE_V2_RETPOLINE_AMD , +SPECTRE_V2_IBRS , +}; +#endif /* __ASSEMBLY__ */ #endif /* __NOSPEC_BRANCH_H__ */
arch/x86/kernel/cpu/bugs.c +157 -1
187 lines not on this page · raw message
arch/x86/kernel/cpu/common.c +0 -4
@@ -905,10 +905,6 @@ static void __init early_identify_cpu(stsetup_force_cpu_bug (X86_BUG_SPECTRE_V1 );setup_force_cpu_bug (X86_BUG_SPECTRE_V2 ); -#ifdef CONFIG_RETPOLINE -setup_force_cpu_cap (X86_FEATURE_RETPOLINE ); -#endif -fpu__init_system (c);#ifdef CONFIG_X86_32
Greg Kroah-Hartman
maintainerPATCH 106/118 x86/retpoline/crypto: Convert crypto assembler indirect jumps
In reply to Greg Kroah-Hartman4.14-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Woodhouse <[email protected]>
commit 9697fa39efd3fc3692f2949d4045f393ec58450b upstream.
Convert all indirect jumps in crypto assembler code to use non-speculative sequences when CONFIG_RETPOLINE is enabled.
--- arch/x86/crypto/aesni-intel_asm.S | 5 +++-- arch/x86/crypto/camellia-aesni-avx-asm_64.S | 3 ++- arch/x86/crypto/camellia-aesni-avx2-asm_64.S | 3 ++- arch/x86/crypto/crc32c-pcl-intel-asm_64.S | 3 ++- 4 files changed, 9 insertions(+), 5 deletions(-)
arch/x86/crypto/aesni-intel_asm.S +3 -2
@@ -32,6 +32,7 @@ #include <linux/linkage.h> #include <asm/inst.h> #include <asm/frame.h> +#include <asm/nospec-branch.h> /* * The following macros are used to move an (un)aligned 16 byte value to/from
@@ -2884,7 +2885,7 @@ ENTRY(aesni_xts_crypt8) pxor INC, STATE4 movdqu IV, 0x30(OUTP) - call *%r11 + CALL_NOSPEC %r11 movdqu 0x00(OUTP), INC pxor INC, STATE1
@@ -2929,7 +2930,7 @@ ENTRY(aesni_xts_crypt8) _aesni_gf128mul_x_ble() movups IV, (IVP) - call *%r11 + CALL_NOSPEC %r11 movdqu 0x40(OUTP), INC pxor INC, STATE1
arch/x86/crypto/camellia-aesni-avx-asm_64.S +2 -1
@@ -17,6 +17,7 @@ #include <linux/linkage.h> #include <asm/frame.h> +#include <asm/nospec-branch.h> #define CAMELLIA_TABLE_BYTE_LEN 272
@@ -1227,7 +1228,7 @@ camellia_xts_crypt_16way: vpxor 14 * 16(%rax), %xmm15, %xmm14; vpxor 15 * 16(%rax), %xmm15, %xmm15; - call *%r9; + CALL_NOSPEC %r9; addq $(16 * 16), %rsp;
arch/x86/crypto/camellia-aesni-avx2-asm_64.S +2 -1
@@ -12,6 +12,7 @@ #include <linux/linkage.h> #include <asm/frame.h> +#include <asm/nospec-branch.h> #define CAMELLIA_TABLE_BYTE_LEN 272
@@ -1343,7 +1344,7 @@ camellia_xts_crypt_32way: vpxor 14 * 32(%rax), %ymm15, %ymm14; vpxor 15 * 32(%rax), %ymm15, %ymm15; - call *%r9; + CALL_NOSPEC %r9; addq $(16 * 32), %rsp;
arch/x86/crypto/crc32c-pcl-intel-asm_64.S +2 -1
@@ -45,6 +45,7 @@ #include <asm/inst.h> #include <linux/linkage.h> +#include <asm/nospec-branch.h> ## ISCSI CRC 32 Implementation with crc32 and pclmulqdq Instruction
@@ -172,7 +173,7 @@ continue_block: movzxw (bufp, %rax, 2), len lea crc_array(%rip), bufp lea (bufp, len, 1), bufp - jmp *bufp + JMP_NOSPEC bufp ################################################################ ## 2a) PROCESS FULL BLOCKS:
Greg Kroah-Hartman
maintainerPATCH 107/118 x86/retpoline/entry: Convert entry assembler indirect jumps
In reply to Greg Kroah-Hartman4.14-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Woodhouse <[email protected]>
commit 2641f08bb7fc63a636a2b18173221d7040a3512e upstream.
Convert indirect jumps in core 32/64bit entry assembler code to use non-speculative sequences when CONFIG_RETPOLINE is enabled.
Don't use CALL_NOSPEC in entry_SYSCALL_64_fastpath because the return address after the 'call' instruction must be *precisely* at the .Lentry_SYSCALL_64_after_fastpath label for stub_ptregs_64 to work, and the use of alternatives will mess that up unless we play horrid games to prepend with NOPs and make the variants the same length. It's not worth it; in the case where we ALTERNATIVE out the retpoline, the first instruction at __x86.indirect_thunk.rax is going to be a bare jmp *%rax anyway.
--- arch/x86/entry/entry_32.S | 5 +++-- arch/x86/entry/entry_64.S | 12 +++++++++--- 2 files changed, 12 insertions(+), 5 deletions(-)
arch/x86/entry/entry_32.S +3 -2
@@ -44,6 +44,7 @@ #include <asm/asm.h> #include <asm/smap.h> #include <asm/frame.h> +#include <asm/nospec-branch.h> .section .entry.text, "ax"
@@ -290,7 +291,7 @@ ENTRY(ret_from_fork) /* kernel thread */ 1: movl %edi, %eax - call *%ebx + CALL_NOSPEC %ebx /* * A kernel thread is allowed to return here after successfully * calling do_execve(). Exit to userspace to complete the execve()
@@ -919,7 +920,7 @@ common_exception: movl %ecx, %es TRACE_IRQS_OFF movl %esp, %eax # pt_regs pointer - call *%edi + CALL_NOSPEC %edi jmp ret_from_exception END(common_exception)
arch/x86/entry/entry_64.S +9 -3
@@ -37,6 +37,7 @@ #include <asm/pgtable_types.h> #include <asm/export.h> #include <asm/frame.h> +#include <asm/nospec-branch.h> #include <linux/err.h> #include "calling.h"
@@ -187,7 +188,7 @@ ENTRY(entry_SYSCALL_64_trampoline) */ pushq %rdi movq $entry_SYSCALL_64_stage2, %rdi - jmp *%rdi + JMP_NOSPEC %rdi END(entry_SYSCALL_64_trampoline) .popsection
@@ -266,7 +267,12 @@ entry_SYSCALL_64_fastpath: * It might end up jumping to the slow path. If it jumps, RAX * and all argument registers are clobbered. */ +#ifdef CONFIG_RETPOLINE + movq sys_call_table(, %rax, 8), %rax + call __x86_indirect_thunk_rax +#else call *sys_call_table(, %rax, 8) +#endif .Lentry_SYSCALL_64_after_fastpath_call: movq %rax, RAX(%rsp)
@@ -438,7 +444,7 @@ ENTRY(stub_ptregs_64) jmp entry_SYSCALL64_slow_path 1: - jmp *%rax /* Called from C */ + JMP_NOSPEC %rax /* Called from C */ END(stub_ptregs_64) .macro ptregs_stub func
@@ -517,7 +523,7 @@ ENTRY(ret_from_fork) 1: /* kernel thread */ movq %r12, %rdi - call *%rbx + CALL_NOSPEC %rbx /* * A kernel thread is allowed to return here after successfully * calling do_execve(). Exit to userspace to complete the execve()
Greg Kroah-Hartman
maintainerPATCH 108/118 x86/retpoline/ftrace: Convert ftrace assembler indirect jumps
In reply to Greg Kroah-Hartman4.14-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Woodhouse <[email protected]>
commit 9351803bd803cdbeb9b5a7850b7b6f464806e3db upstream.
Convert all indirect jumps in ftrace assembler code to use non-speculative sequences when CONFIG_RETPOLINE is enabled.
--- arch/x86/kernel/ftrace_32.S | 6 ++++-- arch/x86/kernel/ftrace_64.S | 8 ++++---- 2 files changed, 8 insertions(+), 6 deletions(-)
arch/x86/kernel/ftrace_32.S +4 -2
@@ -8,6 +8,7 @@ #include <asm/segment.h> #include <asm/export.h> #include <asm/ftrace.h> +#include <asm/nospec-branch.h> #ifdef CC_USING_FENTRY # define function_hook __fentry__
@@ -197,7 +198,8 @@ ftrace_stub: movl 0x4(%ebp), %edx subl $MCOUNT_INSN_SIZE, %eax - call *ftrace_trace_function + movl ftrace_trace_function, %ecx + CALL_NOSPEC %ecx popl %edx popl %ecx
@@ -241,5 +243,5 @@ return_to_handler: movl %eax, %ecx popl %edx popl %eax - jmp *%ecx + JMP_NOSPEC %ecx #endif
arch/x86/kernel/ftrace_64.S +4 -4
@@ -7,7 +7,7 @@ #include <asm/ptrace.h> #include <asm/ftrace.h> #include <asm/export.h> - +#include <asm/nospec-branch.h> .code64 .section .entry.text, "ax"
@@ -286,8 +286,8 @@ trace: * ip and parent ip are used and the list function is called when * function tracing is enabled. */ - call *ftrace_trace_function - + movq ftrace_trace_function, %r8 + CALL_NOSPEC %r8 restore_mcount_regs jmp fgraph_trace
@@ -329,5 +329,5 @@ GLOBAL(return_to_handler) movq 8(%rsp), %rdx movq (%rsp), %rax addq $24, %rsp - jmp *%rdi + JMP_NOSPEC %rdi #endif
Greg Kroah-Hartman
maintainerPATCH 109/118 x86/retpoline/hyperv: Convert assembler indirect jumps
In reply to Greg Kroah-Hartman4.14-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Woodhouse <[email protected]>
commit e70e5892b28c18f517f29ab6e83bd57705104b31 upstream.
Convert all indirect jumps in hyperv inline asm code to use non-speculative sequences when CONFIG_RETPOLINE is enabled.
--- arch/x86/include/asm/mshyperv.h | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-)
arch/x86/include/asm/mshyperv.h +10 -8
@@ -7,6 +7,7 @@#include <linux/nmi.h> #include <asm/io.h> #include <asm/hyperv.h> +#include <asm/nospec-branch.h> /* * The below CPUID leaves are present if VersionAndFeatures.HypervisorPresent
@@ -186,10 +187,11 @@ static inline u64 hv_do_hypercall(u64 coreturn U64_MAX ; __asm__ __volatile__("mov %4, %%r8\n" -"call *%5" +CALL_NOSPEC : "=a" (hv_status), ASM_CALL_CONSTRAINT,"+c" (control),"+d" (input_address) - :"r" (output_address),"m" (hv_hypercall_pg) + : "r" (output_address), + THUNK_TARGET(hv_hypercall_pg) :"cc" ,"memory" ,"r8" ,"r9" ,"r10" ,"r11" );#else u32 input_address_hi =upper_32_bits (input_address);
@@ -200,13 +202,13 @@ static inline u64 hv_do_hypercall(u64 coif (!hv_hypercall_pg)return U64_MAX ; - __asm__ __volatile__("call *%7" + __asm__ __volatile__(CALL_NOSPEC : "=A" (hv_status), "+c" (input_address_lo), ASM_CALL_CONSTRAINT : "A" (control), "b" (input_address_hi), "D"(output_address_hi), "S"(output_address_lo), -"m" (hv_hypercall_pg) + THUNK_TARGET(hv_hypercall_pg) : "cc", "memory");#endif /* !x86_64 */ return hv_status;
@@ -227,10 +229,10 @@ static inline u64 hv_do_fast_hypercall8(#ifdef CONFIG_X86_64 { - __asm__ __volatile__("call *%4" + __asm__ __volatile__(CALL_NOSPEC : "=a" (hv_status), ASM_CALL_CONSTRAINT, "+c" (control), "+d" (input1) - :"m" (hv_hypercall_pg) + : THUNK_TARGET(hv_hypercall_pg) : "cc", "r8", "r9", "r10", "r11"); }#else
@@ -238,13 +240,13 @@ static inline u64 hv_do_fast_hypercall8(u32 input1_hi =upper_32_bits (input1);u32 input1_lo =lower_32_bits (input1); - __asm__ __volatile__ ("call *%5" + __asm__ __volatile__ (CALL_NOSPEC : "=A"(hv_status), "+c"(input1_lo), ASM_CALL_CONSTRAINT : "A" (control), "b" (input1_hi), -"m" (hv_hypercall_pg) + THUNK_TARGET(hv_hypercall_pg) : "cc", "edi", "esi"); }#endif
Greg Kroah-Hartman
maintainerPATCH 110/118 x86/retpoline/xen: Convert Xen hypercall indirect jumps
In reply to Greg Kroah-Hartman4.14-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Woodhouse <[email protected]>
commit ea08816d5b185ab3d09e95e393f265af54560350 upstream.
Convert indirect call in Xen hypercall to use non-speculative sequence, when CONFIG_RETPOLINE is enabled.
--- arch/x86/include/asm/xen/hypercall.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
arch/x86/include/asm/xen/hypercall.h +3 -2
@@ -44,6 +44,7 @@#include <asm/page.h> #include <asm/pgtable.h> #include <asm/smap.h> +#include <asm/nospec-branch.h> #include <xen/interface/xen.h> #include <xen/interface/sched.h>
@@ -217,9 +218,9 @@ privcmd_call(unsigned call,__HYPERCALL_5ARG (a1, a2, a3, a4, a5);stac (); - asmvolatile ("call *%[call]" + asmvolatile (CALL_NOSPEC : __HYPERCALL_5PARAM - : [call]"a" (&hypercall_page[call]) + : [thunk_target] "a" (&hypercall_page[call]) : __HYPERCALL_CLOBBER5);clac ();
Greg Kroah-Hartman
maintainerPATCH 111/118 x86/retpoline/checksum32: Convert assembler indirect jumps
In reply to Greg Kroah-Hartman4.14-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Woodhouse <[email protected]>
commit 5096732f6f695001fa2d6f1335a2680b37912c69 upstream.
Convert all indirect jumps in 32bit checksum assembler code to use non-speculative sequences when CONFIG_RETPOLINE is enabled.
--- arch/x86/lib/checksum_32.S | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
arch/x86/lib/checksum_32.S +4 -3
@@ -29,7 +29,8 @@ #include <asm/errno.h> #include <asm/asm.h> #include <asm/export.h> - +#include <asm/nospec-branch.h> + /* * computes a partial checksum, e.g. for TCP/UDP fragments */
@@ -156,7 +157,7 @@ ENTRY(csum_partial) negl %ebx lea 45f(%ebx,%ebx,2), %ebx testl %esi, %esi - jmp *%ebx + JMP_NOSPEC %ebx # Handle 2-byte-aligned regions 20: addw (%esi), %ax
@@ -439,7 +440,7 @@ ENTRY(csum_partial_copy_generic) andl $-32,%edx lea 3f(%ebx,%ebx), %ebx testl %esi, %esi - jmp *%ebx + JMP_NOSPEC %ebx 1: addl $64,%esi addl $64,%edi SRC(movb -32(%edx),%bl) ; SRC(movb (%edx),%bl)
Greg Kroah-Hartman
maintainerPATCH 112/118 x86/retpoline/irq32: Convert assembler indirect jumps
In reply to Greg Kroah-Hartman4.14-stable review patch. If anyone has any objections, please let me know.
------------------
From: Andi Kleen <[email protected]>
commit 7614e913db1f40fff819b36216484dc3808995d4 upstream.
Convert all indirect jumps in 32bit irq inline asm code to use non speculative sequences.
--- arch/x86/kernel/irq_32.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
arch/x86/kernel/irq_32.c +5 -4
@@ -20,6 +20,7 @@#include <linux/mm.h> #include <asm/apic.h> +#include <asm/nospec-branch.h> #ifdef CONFIG_DEBUG_STACKOVERFLOW
@@ -55,11 +56,11 @@ DEFINE_PER_CPU(struct irq_stack *, softistatic void call_on_stack (void *func,void *stack) { asmvolatile ("xchgl %%ebx,%%esp \n" -"call *%%edi \n" +CALL_NOSPEC "movl %%ebx,%%esp \n" :"=b" (stack) :"0" (stack), -"D" (func) + [thunk_target]"D" (func) :"memory" ,"cc" ,"edx" ,"ecx" ,"eax" ); }
@@ -95,11 +96,11 @@ static inline int execute_on_irq_stack(icall_on_stack (print_stack_overflow, isp); asmvolatile ("xchgl %%ebx,%%esp \n" -"call *%%edi \n" +CALL_NOSPEC "movl %%ebx,%%esp \n" :"=a" (arg1),"=b" (isp) :"0" (desc),"1" (isp), -"D" (desc->handle_irq) + [thunk_target]"D" (desc->handle_irq) :"memory" ,"cc" ,"ecx" );return 1 ; }
Greg Kroah-Hartman
maintainerPATCH 113/118 x86/retpoline: Fill return stack buffer on vmexit
In reply to Greg Kroah-Hartman4.14-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Woodhouse <[email protected]>
commit 117cc7a908c83697b0b737d15ae1eb5943afe35b upstream.
In accordance with the Intel and AMD documentation, we need to overwrite all entries in the RSB on exiting a guest, to prevent malicious branch target predictions from affecting the host kernel. This is needed both for retpoline and for IBRS.
[ak: numbers again for the RSB stuffing labels]
--- arch/x86/include/asm/nospec-branch.h | 78 ++++++++++++++++++++++++++++++++++- arch/x86/kvm/svm.c | 4 + arch/x86/kvm/vmx.c | 4 + 3 files changed, 85 insertions(+), 1 deletion(-)
arch/x86/include/asm/nospec-branch.h +77 -1
@@ -7,6 +7,48 @@#include <asm/alternative-asm.h> #include <asm/cpufeatures.h> +/* +* Fill the CPU return stack buffer. +* +* Each entry in the RSB, if used for a speculative 'ret', contains an +* infinite 'pause; jmp' loop to capture speculative execution. +* +* This is required in various cases for retpoline and IBRS-based +* mitigations for the Spectre variant 2 vulnerability. Sometimes to +* eliminate potentially bogus entries from the RSB, and sometimes +* purely to ensure that it doesn't get empty, which on some CPUs would +* allow predictions from other (unwanted!) sources to be used. +* +* We define a CPP macro such that it can be used from both .S files and +* inline assembly. It's possible to do a .macro and then include that +* from C via asm(".include <asm/nospec-branch.h>") but let's not go there. +*/ + +#define RSB_CLEAR_LOOPS 32/* To forcibly overwrite all entries */ +#define RSB_FILL_LOOPS 16/* To avoid underflow */ + +/* +* Google experimented with loop-unrolling and this turned out to be +* the optimal version — two calls, each with their own speculation +* trap should their return address end up getting used, in a loop. +*/ +#define __FILL_RETURN_BUFFER(reg, nr, sp) \ + mov $(nr/2), reg; \ +771: \ + call 772f; \ +773: /* speculation trap */ \ + pause; \ + jmp 773b; \ +772: \ + call 774f; \ +775: /* speculation trap */ \ + pause; \ + jmp 775b; \ +774: \ + dec reg; \ + jnz 771b; \ + add $(BITS_PER_LONG/8) * nr, sp; +#ifdef __ASSEMBLY__/*
@@ -76,6 +118,20 @@#endif .endm + /* + * A simpler FILL_RETURN_BUFFER macro. Don't make people use the CPP + * monstrosity above, manually. + */ +.macro FILL_RETURN_BUFFER reg:req nr:req ftr:req +#ifdef CONFIG_RETPOLINE +ANNOTATE_NOSPEC_ALTERNATIVE + ALTERNATIVE "jmp .Lskip_rsb_\@", \ + __stringify(__FILL_RETURN_BUFFER(\reg,\nr,%_ASM_SP)) \ + \ftr +.Lskip_rsb_\@: +#endif +.endm +#else /* __ASSEMBLY__ */ #define ANNOTATE_NOSPEC_ALTERNATIVE \
@@ -119,7 +175,7 @@ X86_FEATURE_RETPOLINE)# define THUNK_TARGET (addr) [thunk_target] "rm" (addr) -#else /* No retpoline */ +#else /* No retpoline for C / inline asm */ # define CALL_NOSPEC "call *%[thunk_target]\n"# define THUNK_TARGET (addr) [thunk_target] "rm" (addr)#endif
@@ -134,5 +190,25 @@ enum spectre_v2_mitigation { SPECTRE_V2_IBRS, }; +/* +* On VMEXIT we must ensure that no RSB predictions learned in the guest +* can be followed in the host, by overwriting the RSB completely. Both +* retpoline and IBRS mitigations for Spectre v2 need this; only on future +* CPUs with IBRS_ATT *might* it be avoided. +*/ +static inline void vmexit_fill_RSB (void ) +{ +#ifdef CONFIG_RETPOLINE +unsigned long loops =RSB_CLEAR_LOOPS /2 ; + + asm volatile (ANNOTATE_NOSPEC_ALTERNATIVE + ALTERNATIVE("jmp 910f", + __stringify(__FILL_RETURN_BUFFER(%0, RSB_CLEAR_LOOPS, %1)), + X86_FEATURE_RETPOLINE) + "910:" + : "=&r" (loops), ASM_CALL_CONSTRAINT + : "r" (loops) : "memory" ); +#endif +}#endif /* __ASSEMBLY__ */ #endif /* __NOSPEC_BRANCH_H__ */
arch/x86/kvm/svm.c +4 -0
@@ -45,6 +45,7 @@#include <asm/debugreg.h> #include <asm/kvm_para.h> #include <asm/irq_remapping.h> +#include <asm/nospec-branch.h> #include <asm/virtext.h> #include "trace.h"
@@ -5013,6 +5014,9 @@ static void svm_vcpu_run(struct kvm_vcpu#endif ); +/* Eliminate branch target predictions from guest mode */ +vmexit_fill_RSB (); +#ifdef CONFIG_X86_64 wrmsrl (MSR_GS_BASE , svm->host.gs_base);#else
arch/x86/kvm/vmx.c +4 -0
@@ -50,6 +50,7 @@#include <asm/apic.h> #include <asm/irq_remapping.h> #include <asm/mmu_context.h> +#include <asm/nospec-branch.h> #include "trace.h" #include "pmu.h"
@@ -9483,6 +9484,9 @@ static void __noclone vmx_vcpu_run(struc#endif ); +/* Eliminate branch target predictions from guest mode */ +vmexit_fill_RSB (); +/* MSR_IA32_DEBUGCTLMSR is zeroed on vmexit. Restore it if needed */ if (debugctlmsr)update_debugctlmsr (debugctlmsr);
Greg Kroah-Hartman
maintainerPATCH 114/118 selftests/x86: Add test_vsyscall
In reply to Greg Kroah-Hartman4.14-stable review patch. If anyone has any objections, please let me know.
------------------
From: Andy Lutomirski <[email protected]>
commit 352909b49ba0d74929b96af6dfbefc854ab6ebb5 upstream.
This tests that the vsyscall entries do what they're expected to do. It also confirms that attempts to read the vsyscall page behave as expected.
If changes are made to the vsyscall code or its memory map handling, running this test in all three of vsyscall=none, vsyscall=emulate, and vsyscall=native are helpful.
(Because it's easy, this also compares the vsyscall results to their
vDSO equivalents.)
Note to KAISER backporters: please test this under all three vsyscall modes. Also, in the emulate and native modes, make sure that test_vsyscall_64 agrees with the command line or config option as to which mode you're in. It's quite easy to mess up the kernel such that native mode accidentally emulates or vice versa.
Greg, etc: please backport this to all your Meltdown-patched kernels. It'll help make sure the patches didn't regress vsyscalls.
--- tools/testing/selftests/x86/Makefile | 2 tools/testing/selftests/x86/test_vsyscall.c | 500 ++++++++++++++++++++++++++++ 2 files changed, 501 insertions(+), 1 deletion(-)
tools/testing/selftests/x86/Makefile +1 -1
@@ -7,7 +7,7 @@ include ../lib.mk TARGETS_C_BOTHBITS := single_step_syscall sysret_ss_attrs syscall_nt ptrace_syscall test_mremap_vdso \ check_initial_reg_state sigreturn ldt_gdt iopl mpx-mini-test ioperm \ - protection_keys test_vdso + protection_keys test_vdso test_vsyscall TARGETS_C_32BIT_ONLY := entry_from_vm86 syscall_arg_fault test_syscall_vdso unwind_vdso \ test_FCMOV test_FCOMI test_FISTTP \ vdso_restorer
tools/testing/selftests/x86/test_vsyscall.c new file +500 -0
500 lines not on this page · raw message
Greg Kroah-Hartman
maintainerPATCH 115/118 x86/pti: Fix !PCID and sanitize defines
In reply to Greg Kroah-Hartman4.14-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thomas Gleixner <[email protected]>
commit f10ee3dcc9f0aba92a5c4c064628be5200765dc2 upstream.
The switch to the user space page tables in the low level ASM code sets unconditionally bit 12 and bit 11 of CR3. Bit 12 is switching the base address of the page directory to the user part, bit 11 is switching the PCID to the PCID associated with the user page tables.
This fails on a machine which lacks PCID support because bit 11 is set in CR3. Bit 11 is reserved when PCID is inactive.
While the Intel SDM claims that the reserved bits are ignored when PCID is disabled, the AMD APM states that they should be cleared.
This went unnoticed as the AMD APM was not checked when the code was developed and reviewed and test systems with Intel CPUs never failed to boot. The report is against a Centos 6 host where the guest fails to boot, so it's not yet clear whether this is a virt issue or can happen on real hardware too, but thats irrelevant as the AMD APM clearly ask for clearing the reserved bits.
Make sure that on non PCID machines bit 11 is not set by the page table switching code.
Andy suggested to rename the related bits and masks so they are clearly describing what they should be used for, which is done as well for clarity.
That split could have been done with alternatives but the macro hell is horrible and ugly. This can be done on top if someone cares to remove the extra orq. For now it's a straight forward fix.
--- arch/x86/entry/calling.h | 36 +++++++++++++++++---------------- arch/x86/include/asm/processor-flags.h | 2 - arch/x86/include/asm/tlbflush.h | 6 ++--- 3 files changed, 23 insertions(+), 21 deletions(-)
arch/x86/entry/calling.h +19 -17
@@ -198,8 +198,11 @@ For 32-bit we have the following convent* PAGE_TABLE_ISOLATION PGDs are 8k. Flip bit 12 to switch between the two * halves: */ -#define PTI_SWITCH_PGTABLES_MASK (1<<PAGE_SHIFT) -#define PTI_SWITCH_MASK (PTI_SWITCH_PGTABLES_MASK|(1<<X86_CR3_PTI_SWITCH_BIT)) +#define PTI_USER_PGTABLE_BIT PAGE_SHIFT +#define PTI_USER_PGTABLE_MASK (1 << PTI_USER_PGTABLE_BIT) +#define PTI_USER_PCID_BIT X86_CR3_PTI_PCID_USER_BIT +#define PTI_USER_PCID_MASK (1 << PTI_USER_PCID_BIT) +#define PTI_USER_PGTABLE_AND_PCID_MASK (PTI_USER_PCID_MASK | PTI_USER_PGTABLE_MASK) .macro SET_NOFLUSH_BIT reg:req bts $X86_CR3_PCID_NOFLUSH_BIT, \reg
@@ -208,7 +211,7 @@ For 32-bit we have the following convent .macro ADJUST_KERNEL_CR3 reg:req ALTERNATIVE "", "SET_NOFLUSH_BIT \reg", X86_FEATURE_PCID /* Clear PCID and "PAGE_TABLE_ISOLATION bit", point CR3 at kernel pagetables: */ - andq $(~PTI_SWITCH_MASK), \reg + andq $(~PTI_USER_PGTABLE_AND_PCID_MASK), \reg .endm .macro SWITCH_TO_KERNEL_CR3 scratch_reg:req
@@ -239,15 +242,19 @@ For 32-bit we have the following convent/* Flush needed, clear the bit */ btr \scratch_reg, THIS_CPU_user_pcid_flush_mask movq \scratch_reg2, \scratch_reg - jmp .Lwrcr3_\@ + jmp .Lwrcr3_pcid_\@ .Lnoflush_\@: movq \scratch_reg2, \scratch_reg SET_NOFLUSH_BIT \scratch_reg +.Lwrcr3_pcid_\@: +/* Flip the ASID to the user version */ + orq $(PTI_USER_PCID_MASK), \scratch_reg + .Lwrcr3_\@: -/* Flip the PGD and ASID to the user version */ - orq $(PTI_SWITCH_MASK), \scratch_reg +/* Flip the PGD to the user version */ + orq $(PTI_USER_PGTABLE_MASK), \scratch_reg mov \scratch_reg, %cr3 .Lend_\@: .endm
@@ -263,17 +270,12 @@ For 32-bit we have the following convent movq %cr3, \scratch_reg movq \scratch_reg, \save_reg /* -* Is the "switch mask" all zero? That means that both of -* these are zero: -* -* 1. The user/kernel PCID bit, and -* 2. The user/kernel "bit" that points CR3 to the -* bottom half of the 8k PGD -* -* That indicates a kernel CR3 value, not a user CR3. + * Test the user pagetable bit. If set, then the user page tables + * are active. If clear CR3 already has the kernel page table + * active. */ - testq $(PTI_SWITCH_MASK), \scratch_reg - jz .Ldone_\@ + bt $PTI_USER_PGTABLE_BIT, \scratch_reg + jnc .Ldone_\@ ADJUST_KERNEL_CR3 \scratch_reg movq \scratch_reg, %cr3
@@ -290,7 +292,7 @@ For 32-bit we have the following convent* KERNEL pages can always resume with NOFLUSH as we do * explicit flushes. */ - bt $X86_CR3_PTI_SWITCH_BIT, \save_reg + bt $PTI_USER_PGTABLE_BIT, \save_reg jnc .Lnoflush_\@/*
arch/x86/include/asm/processor-flags.h +1 -1
@@ -40,7 +40,7 @@#define CR3_NOFLUSH BIT_ULL(63)#ifdef CONFIG_PAGE_TABLE_ISOLATION -# define X86_CR3_PTI_SWITCH_BIT 11 +# define X86_CR3_PTI_PCID_USER_BIT 11#endif #else
arch/x86/include/asm/tlbflush.h +3 -3
@@ -81,13 +81,13 @@ static inline u16 kern_pcid(u16 asid)* Make sure that the dynamic ASID space does not confict with the * bit we are using to switch between user and kernel ASIDs. */ -BUILD_BUG_ON (TLB_NR_DYN_ASIDS >= (1 <<X86_CR3_PTI_SWITCH_BIT )); +BUILD_BUG_ON (TLB_NR_DYN_ASIDS >= (1 <<X86_CR3_PTI_PCID_USER_BIT ));/* * The ASID being passed in here should have respected the * MAX_ASID_AVAILABLE and thus never have the switch bit set. */ -VM_WARN_ON_ONCE (asid & (1 <<X86_CR3_PTI_SWITCH_BIT )); +VM_WARN_ON_ONCE (asid & (1 <<X86_CR3_PTI_PCID_USER_BIT ));#endif /* * The dynamically-assigned ASIDs that get passed in are small
@@ -112,7 +112,7 @@ static inline u16 user_pcid(u16 asid) {u16 ret =kern_pcid (asid);#ifdef CONFIG_PAGE_TABLE_ISOLATION - ret |=1 <<X86_CR3_PTI_SWITCH_BIT ; + ret |=1 <<X86_CR3_PTI_PCID_USER_BIT ;#endif return ret; }
Greg Kroah-Hartman
maintainerPATCH 116/118 security/Kconfig: Correct the Documentation reference for PTI
In reply to Greg Kroah-Hartman4.14-stable review patch. If anyone has any objections, please let me know.
------------------
From: W. Trevor King <[email protected]>
commit a237f762681e2a394ca67f21df2feb2b76a3609b upstream.
When the config option for PTI was added a reference to documentation was added as well. But the documentation did not exist at that point. The final documentation has a different file name.
Fix it up to point to the proper file.
--- security/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
security/Kconfig +1 -1
@@ -63,7 +63,7 @@ config PAGE_TABLE_ISOLATION ensuring that the majority of kernel addresses are not mapped into userspace. - See Documentation/x86/pagetable-isolation.txt for more details. + See Documentation/x86/pti.txt for more details. config SECURITY_INFINIBAND bool "Infiniband Security Hooks"
--
To unsubscribe from this list: send the line "unsubscribe linux-security-module" in the body of a message to majordomo at vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Greg Kroah-Hartman
maintainerPATCH 117/118 x86,perf: Disable intel_bts when PTI
In reply to Greg Kroah-Hartman4.14-stable review patch. If anyone has any objections, please let me know.
------------------
From: Peter Zijlstra <[email protected]>
commit 99a9dc98ba52267ce5e062b52de88ea1f1b2a7d8 upstream.
The intel_bts driver does not use the 'normal' BTS buffer which is exposed through the cpu_entry_area but instead uses the memory allocated for the perf AUX buffer.
This obviously comes apart when using PTI because then the kernel mapping; which includes that AUX buffer memory; disappears. Fixing this requires to expose a mapping which is visible in all context and that's not trivial.
As a quick fix disable this driver when PTI is enabled to prevent malfunction.
--- arch/x86/events/intel/bts.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+)
arch/x86/events/intel/bts.c +18 -0
@@ -582,6 +582,24 @@ static __init int bts_init(void)if (!boot_cpu_has (X86_FEATURE_DTES64 ) || !x86_pmu.bts)return -ENODEV ; +if (boot_cpu_has (X86_FEATURE_PTI )) { +/* +* BTS hardware writes through a virtual memory map we must +* either use the kernel physical map, or the user mapping of +* the AUX buffer. +* +* However, since this driver supports per-CPU and per-task inherit +* we cannot use the user mapping since it will not be availble +* if we're not running the owning process. +* +* With PTI we can't use the kernal map either, because its not +* there when we run userspace. +* +* For now, disable this driver when using PTI. +*/ +return -ENODEV ; + } + bts_pmu.capabilities =PERF_PMU_CAP_AUX_NO_SG |PERF_PMU_CAP_ITRACE |PERF_PMU_CAP_EXCLUSIVE ; bts_pmu.task_ctx_nr = perf_sw_context;
Greg Kroah-Hartman
maintainerPATCH 118/118 x86/retpoline: Remove compile time warning
In reply to Greg Kroah-Hartman4.14-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thomas Gleixner <[email protected]>
commit b8b9ce4b5aec8de9e23cabb0a26b78641f9ab1d6 upstream.
Remove the compile time warning when CONFIG_RETPOLINE=y and the compiler does not have retpoline support. Linus rationale for this is:
It's wrong because it will just make people turn off RETPOLINE, and the asm updates - and return stack clearing - that are independent of the compiler are likely the most important parts because they are likely the ones easiest to target.
And it's annoying because most people won't be able to do anything about it. The number of people building their own compiler? Very small. So if their distro hasn't got a compiler yet (and pretty much nobody does), the warning is just annoying crap.
It is already properly reported as part of the sysfs interface. The compile-time warning only encourages bad things.
--- arch/x86/Makefile | 2 -- 1 file changed, 2 deletions(-)
arch/x86/Makefile +0 -2
@@ -240,8 +240,6 @@ ifdef CONFIG_RETPOLINE RETPOLINE_CFLAGS += $(call cc-option,-mindirect-branch=thunk-extern -mindirect-branch-register) ifneq ($(RETPOLINE_CFLAGS),) KBUILD_CFLAGS += $(RETPOLINE_CFLAGS) -DRETPOLINE - else - $(warning CONFIG_RETPOLINE=y, but not supported by the compiler. Toolchain update recommended.) endif endif
Quoted 4 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 4.14.14 release. There are 118 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Applied to 4.14.13 & built on 3 machines with different old CPUs (Core2Duo, i5/i7 SandyBridge), current gcc 7.2.0 still without retpoline magic (so syscalls only). Ensured CONFIG_RETPOLINE is enabled.
No regressions, no filesystems on fire, no spontaneous reboots.
Also gave this a syscall-heavy workout with iperf, still pushing >10 GB/s locally just as before (within expected deviation). perf bench shows some expected impact though, ~0.2-0.3 µs for scheduling.
cheers,
Holger
Greg Kroah-Hartman
maintainerQuoted 10 lines · Holger Hoffst�tte
Quoted 4 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 4.14.14 release. There are 118 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Applied to 4.14.13 & built on 3 machines with different old CPUs (Core2Duo, i5/i7 SandyBridge), current gcc 7.2.0 still without retpoline magic (so syscalls only). Ensured
CONFIG_RETPOLINEis enabled.
Quoted 5 lines
No regressions, no filesystems on fire, no spontaneous reboots.
Also gave this a syscall-heavy workout with iperf, still pushing >10 GB/s locally just as before (within expected deviation). perf bench shows some expected impact though, ~0.2-0.3 �s for scheduling.
Great, thanks for testing, much appreciated.
greg k-h
After updating from 4.4 to 4.14, I found that my ASUSTeK M5A99X EVO with an AMD FX(tm)-4300 was only showing 1 core instead of 4.
I tracked it down to this bug:
https://bugzilla.kernel.org/show_bug.cgi?id=194501
Cherry-picking 2b85b3d22920db7473e5fed5719e7955c0ec323e applied cleanly and all cores were then present
Could we have this patch included too, please.
Thanks
Signature · 4 lines
Alan J. Wylie https://www.wylie.me.uk/ Dance like no-one's watching. / Encrypt like everyone is. Security is inversely proportional to convenience
Greg Kroah-Hartman
maintainerQuoted 11 lines · Alan J. Wylie
After updating from 4.4 to 4.14, I found that my ASUSTeK M5A99X EVO with an AMD FX(tm)-4300 was only showing 1 core instead of 4.
I tracked it down to this bug:
https://bugzilla.kernel.org/show_bug.cgi?id=194501
Cherry-picking
2b85b3d22920db7473e5fed5719e7955c0ec323eapplied cleanly and all cores were then present
That commit showed up in 4.11-rc3, why would you need this on 4.14? It shouldn't even apply, right?
Quoted 1 line
Could we have this patch included too, please.
Do you also have problems with Linus's tree?
thanks,
greg k-h
Quoted 2 lines · at 18:40 on Mon 15-Jan-2018 Greg Kroah-Hartman ([email protected])…
That commit showed up in 4.11-rc3, why would you need this on 4.14? It shouldn't even apply, right?
Profuse apologies for this - I had mistakenly checked out a 4.10 kernel rather than 4.14.
Thanks for correcting my mistake. I need more coffee and sleep. Shift work isn't agreeing with me.
Regards
Alan
Signature · 4 lines
Alan J. Wylie https://www.wylie.me.uk/ Dance like no-one's watching. / Encrypt like everyone is. Security is inversely proportional to convenience
stable-rc/linux-4.14.y boot: 140 boots: 3 failed, 134 passed with 3 offline (v4.14.13-119-gb32d455a94d0)
stable-rc/linux-4.14.y boot: 140 boots: 3 failed, 134 passed with 3 offline (v4.14.13-119-gb32d455a94d0)
Full Boot Summary: https://kernelci.org/boot/all/job/stable-rc/branch/linux-4.14.y/kernel/v4.14.13-119-gb32d455a94d0/
Full Build Summary: https://kernelci.org/build/stable-rc/branch/linux-4.14.y/kernel/v4.14.13-119-gb32d455a94d0/
Tree: stable-rc
Branch: linux-4.14.y
Git Describe: v4.14.13-119-gb32d455a94d0
Git Commit: b32d455a94d078c78756fd637bad8d46050c1163
Git URL: http://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git
Tested: 79 unique boards, 23 SoC families, 17 builds out of 185
Boot Regressions Detected:
arm:
multi_v7_defconfig:
mt7623n-bananapi-bpi-r2:
lab-baylibre-seattle: failing since 1 day (last pass: v4.14.13-32-g8317937bacb7 - first fail: v4.14.13-75-g8289047d7506)
sunxi_defconfig:
sun8i-a83t-allwinner-h8homlet-v2:
lab-free-electrons: new failure (last pass: v4.14.13-75-g8289047d7506)Boot Failures Detected:
arm:
multi_v7_defconfig
mt7623n-bananapi-bpi-r2: 1 failed lab
mvebu_v5_defconfig
kirkwood-openblocks_a7_rootfs:nfs: 1 failed lab
sunxi_defconfig
sun8i-a83t-allwinner-h8homlet-v2: 1 failed lab
Offline Platforms:
arm:
multi_v7_defconfig:
exynos5420-arndale-octa: 1 offline lab
tegra124-jetson-tk1: 1 offline lab
exynos_defconfig:
exynos5420-arndale-octa: 1 offline lab
---
For more info write to <[email protected]>
Quoted 5 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 4.14.14 release. There are 118 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Quoted 8 lines
Responses should be made by Wed Jan 17 12:33:32 UTC 2018. Anything received after that time might be too late.
The whole patch series can be found in one patch at:
kernel.org/pub/linux/kernel/v4.x/stable-review/patch-4.14.14-rc1.gzor in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.gitlinux-4.14.y
and the diffstat can be found below.
Results from Linaro’s test farm.
No regressions on arm64, arm and x86_64.
Summary
------------------------------------------------------------------------
kernel: 4.14.14-rc1
git repo: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git
git branch: linux-4.14.y
git commit: 03153128f7d26492581ded52990c6f71e9d53afb
git describe: v4.14.13-119-g03153128f7d2
Test details: https://qa-reports.linaro.org/lkft/linux-stable-rc-4.14-oe/build/v4.14.13-119-g03153128f7d2
No regressions (compared to build v4.14.13-119-gb32d455a94d0)
Boards, architectures and test suites:
-------------------------------------
hi6220-hikey - arm64
* boot - pass: 19,
* kselftest - skip: 16, pass: 46,
* libhugetlbfs - skip: 1, pass: 90,
* ltp-cap_bounds-tests - pass: 2,
* ltp-containers-tests - pass: 64,
* ltp-fcntl-locktests-tests - pass: 2,
* ltp-filecaps-tests - pass: 2,
* ltp-fs_bind-tests - pass: 2,
* ltp-fs_perms_simple-tests - pass: 19,
* ltp-fsx-tests - pass: 2,
* ltp-hugetlb-tests - skip: 1, pass: 21,
* ltp-io-tests - pass: 3,
* ltp-ipc-tests - pass: 9,
* ltp-math-tests - pass: 11,
* ltp-nptl-tests - pass: 2,
* ltp-pty-tests - pass: 4,
* ltp-sched-tests - pass: 14,
* ltp-securebits-tests - pass: 4,
* ltp-syscalls-tests - skip: 121, pass: 983,
* ltp-timers-tests - pass: 12,
juno-r2 - arm64
* boot - pass: 20,
* kselftest - skip: 17, pass: 45,
* libhugetlbfs - skip: 1, pass: 90,
* ltp-cap_bounds-tests - pass: 2,
* ltp-containers-tests - pass: 64,
* ltp-fcntl-locktests-tests - pass: 2,
* ltp-filecaps-tests - pass: 2,
* ltp-fs-tests - pass: 60,
* ltp-fs_bind-tests - pass: 2,
* ltp-fs_perms_simple-tests - pass: 19,
* ltp-fsx-tests - pass: 2,
* ltp-hugetlb-tests - pass: 22,
* ltp-io-tests - pass: 3,
* ltp-ipc-tests - pass: 9,
* ltp-math-tests - pass: 11,
* ltp-nptl-tests - pass: 2,
* ltp-pty-tests - pass: 4,
* ltp-sched-tests - pass: 14,
* ltp-securebits-tests - pass: 4,
* ltp-syscalls-tests - skip: 121, pass: 987,
* ltp-timers-tests - pass: 12,
x15 - arm
* boot - pass: 20,
* kselftest - skip: 19, pass: 42,
* libhugetlbfs - skip: 1, pass: 87,
* ltp-cap_bounds-tests - pass: 2,
* ltp-containers-tests - pass: 64,
* ltp-fcntl-locktests-tests - pass: 2,
* ltp-filecaps-tests - pass: 2,
* ltp-fs-tests - pass: 60,
* ltp-fs_bind-tests - pass: 2,
* ltp-fs_perms_simple-tests - pass: 19,
* ltp-fsx-tests - pass: 2,
* ltp-hugetlb-tests - skip: 2, pass: 20,
* ltp-io-tests - pass: 3,
* ltp-ipc-tests - pass: 9,
* ltp-math-tests - pass: 11,
* ltp-nptl-tests - pass: 2,
* ltp-pty-tests - pass: 4,
* ltp-sched-tests - skip: 1, pass: 13,
* ltp-securebits-tests - pass: 4,
* ltp-syscalls-tests - skip: 66, pass: 1037,
* ltp-timers-tests - pass: 12,
x86_64
* boot - pass: 20,
* kselftest - skip: 17, pass: 57, fail: 1
* libhugetlbfs - skip: 1, pass: 90,
* ltp-cap_bounds-tests - pass: 2,
* ltp-containers-tests - pass: 64,
* ltp-fcntl-locktests-tests - pass: 2,
* ltp-filecaps-tests - pass: 2,
* ltp-fs-tests - skip: 1, pass: 61,
* ltp-fs_bind-tests - pass: 2,
* ltp-fs_perms_simple-tests - pass: 19,
* ltp-fsx-tests - pass: 2,
* ltp-hugetlb-tests - pass: 22,
* ltp-io-tests - pass: 3,
* ltp-ipc-tests - pass: 9,
* ltp-math-tests - pass: 11,
* ltp-nptl-tests - pass: 2,
* ltp-pty-tests - pass: 4,
* ltp-sched-tests - skip: 1, pass: 9,
* ltp-securebits-tests - pass: 4,
* ltp-syscalls-tests - skip: 116, pass: 1016,
* ltp-timers-tests - pass: 12,
Greg Kroah-Hartman
maintainerQuoted 9 lines · Dan Rue
Quoted 8 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 4.14.14 release. There are 118 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Wed Jan 17 12:33:32 UTC 2018. Anything received after that time might be too late.
Quoted 8 lines
Quoted 5 lines
The whole patch series can be found in one patch at:
kernel.org/pub/linux/kernel/v4.x/stable-review/patch-4.14.14-rc1.gzor in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.gitlinux-4.14.y
and the diffstat can be found below.Results from Linaro’s test farm.
No regressions on arm64, arm andx86_64.
Great, thanks for testing.
greg k-h
Quoted 8 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 4.14.14 release. There are 118 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Wed Jan 17 12:33:32 UTC 2018. Anything received after that time might be too late.
Build results:
total: 145 pass: 145 fail: 0 Qemu test results: total: 126 pass: 126 fail: 0
Details are available at http://kerneltests.org/builders.
Guenter
Greg Kroah-Hartman
maintainerQuoted 10 lines · Guenter Roeck
Quoted 8 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 4.14.14 release. There are 118 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Wed Jan 17 12:33:32 UTC 2018. Anything received after that time might be too late.
Quoted 6 lines
Build results:
total: 145 pass: 145 fail: 0 Qemu test results: total: 126 pass: 126 fail: 0Details are available at http://kerneltests.org/builders.
Thanks for testing all of these and letting me know.
greg k-h
Quoted 9 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 4.14.14 release. There are 118 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Wed Jan 17 12:33:32 UTC 2018. Anything received after that time might be too late.
The whole patch series can be found in one patch at:
Quoted 9 lines
kernel.org/pub/linux/kernel/v4.x/stable-review/patch-4.14.14-rc1.gzor in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.gitlinux-4.14.y
and the diffstat can be found below.thanks,
greg k-h
Compiled and booted on my test system. No dmesg regressions.
thanks,
-- Shuah
Greg Kroah-Hartman
maintainerQuoted 15 lines · Shuah Khan
Quoted 14 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 4.14.14 release. There are 118 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Wed Jan 17 12:33:32 UTC 2018. Anything received after that time might be too late.
The whole patch series can be found in one patch at:
kernel.org/pub/linux/kernel/v4.x/stable-review/patch-4.14.14-rc1.gzor in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.gitlinux-4.14.y
and the diffstat can be found below.
Quoted 6 lines
Quoted 4 lines
thanks,
greg k-h
Compiled and booted on my test system. No dmesg regressions.
Wonderful, thanks for testing all of these and letting me know.
greg k-h