4.4.112-stable review
Subsystems (4)
Greg Kroah-Hartman
maintainercover 4.4.112-stable review
This is the start of the stable review cycle for the 4.4.112 release. There are 87 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:11 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.4.112-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.4.y
and the diffstat can be found below.
thanks,
greg k-h
-------------
Pseudo-Shortlog of commits:
Greg Kroah-Hartman <[email protected]>
Linux 4.4.112-rc1
Andy Lutomirski <[email protected]>
selftests/x86: Add test_vsyscall
David Woodhouse <[email protected]>
x86/alternatives: Add missing '\n' at end of ALTERNATIVE inline asm
Borislav Petkov <[email protected]>
x86/alternatives: Fix optimize_nops() checking
David Woodhouse <[email protected]>
sysfs/cpu: Fix typos in vulnerability documentation
Thomas Gleixner <[email protected]>
x86/cpu: Implement CPU vulnerabilites sysfs functions
Thomas Gleixner <[email protected]>
sysfs/cpu: Add vulnerability folder
Dave Hansen <[email protected]>
x86/Documentation: Add PTI description
Benjamin Poirier <[email protected]>
e1000e: Fix e1000_check_for_copper_link_ich8lan return value.
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: remove kernel addresses from usb device and urb debug msgs
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
Nicholas Bellinger <[email protected]>
target: Avoid early CMD_T_PRE_EXECUTE failures during ABORT_TASK
Nicholas Bellinger <[email protected]>
iscsi-target: Make TASK_REASSIGN use proper se_cmd->cmd_kref
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
Alexei Starovoitov <[email protected]>
bpf: adjust insn_aux_data when patching insns
Alexei Starovoitov <[email protected]>
bpf: refactor fixup_bpf_calls()
Alexei Starovoitov <[email protected]>
bpf: move fixup_bpf_calls() function
Jakub Kicinski <[email protected]>
bpf: don't (ab)use instructions to store state
Daniel Borkmann <[email protected]>
bpf: add bpf_patch_insn_single helper
Lepton Wu <[email protected]>
kaiser: Set _PAGE_NX only if supported
Dan Carpenter <[email protected]>
drm/vmwgfx: Potential off by one in vmw_view_add()
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
Ilya Dryomov <[email protected]>
rbd: set max_segments to USHRT_MAX
Eric Biggers <[email protected]>
crypto: algapi - fix NULL dereference in crypto_remove_spawns()
Eric Dumazet <[email protected]>
ipv6: fix possible mem leaks in ipv6_make_skb()
Jerome Brunet <[email protected]>
net: stmmac: enable EEE in MII, GMII or RGMII only
Sergei Shtylyov <[email protected]>
sh_eth: fix SH7757 GEther initialization
Sergei Shtylyov <[email protected]>
sh_eth: fix TSU resource handling
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()
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
Pavel Tatashin <[email protected]>
x86/pti/efi: broken conversion from efi to kernel page table
Greg Kroah-Hartman <[email protected]>
Revert "userfaultfd: selftest: vm: allow to build in vm/ directory"
Ben Hutchings <[email protected]>
xhci: Fix ring leak in failure path of xhci_alloc_virt_device()
Ani Sinha <[email protected]>
sysrq: Fix warning in sysrq generated crash.
Jiri Slaby <[email protected]>
hwrng: core - sleep interruptible in read
Jiri Kosina <[email protected]>
x86/mm/pat, /dev/mem: Remove superfluous error message
Eric Dumazet <[email protected]>
cx82310_eth: use skb_cow_head() to deal with cloned skbs
Eric Dumazet <[email protected]>
smsc75xx: use skb_cow_head() to deal with cloned skbs
Eric Dumazet <[email protected]>
sr9700: use skb_cow_head() to deal with cloned skbs
Eric Dumazet <[email protected]>
lan78xx: use skb_cow_head() to deal with cloned skbs
hayeswang <[email protected]>
r8152: adjust ALDPS function
hayeswang <[email protected]>
r8152: use test_and_clear_bit
hayeswang <[email protected]>
r8152: fix the wake event
Ulf Hansson <[email protected]>
usb: musb: ux500: Fix NULL pointer dereference at system PM
Oliver Neukum <[email protected]>
usbvision fix overflow of interfaces array
Davidlohr Bueso <[email protected]>
locking/mutex: Allow next waiter lockless wakeup
Jianyu Zhan <[email protected]>
futex: Replace barrier() in unqueue_me() with READ_ONCE()
Jeff Layton <[email protected]>
locks: don't check for race with close when setting OFD lock
Dan Streetman <[email protected]>
zswap: don't param_set_charp while holding spinlock
Dan Streetman <[email protected]>
mm/zswap: use workqueue to destroy pool
Andrey Ryabinin <[email protected]>
mm/page-writeback: fix dirty_ratelimit calculation
Joonsoo Kim <[email protected]>
mm/compaction: pass only pageblock aligned range to pageblock_pfn_to_page
Joonsoo Kim <[email protected]>
mm/compaction: fix invalid free_pfn and compact_cached_free_pfn
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: Remove incorrect snd_BUG_ON() usages
Jean-Philippe Brucker <[email protected]>
iommu/arm-smmu-v3: Don't free page table ops twice
Vikas C Sajjan <[email protected]>
x86/acpi: Handle SCI interrupts above legacy space gracefully
Andy Lutomirski <[email protected]>
x86/vsdo: Fix build on PARAVIRT_CLOCK=y, KVM_GUEST=n
Jim Mattson <[email protected]>
kvm: vmx: Scrub hardware GPRs at VM-exit
Andrey Ryabinin <[email protected]>
net/mac80211/debugfs.c: prevent build failure with CONFIG_UBSAN=y
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: Disable RDMA access by the initiator
Wolfgang Grandegger <[email protected]>
can: gs_usb: fix return value of the "set_bittiming" callback
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/kernel-parameters.txt | 21 +- Documentation/x86/pti.txt | 186 ++++++++ Makefile | 4 +- arch/arm/kvm/mmio.c | 6 +- arch/mips/kernel/process.c | 12 + arch/mips/kernel/ptrace.c | 147 ++++-- arch/x86/Kconfig | 1 + arch/x86/include/asm/alternative.h | 4 +- arch/x86/include/asm/kaiser.h | 10 + arch/x86/include/asm/pvclock.h | 2 +- arch/x86/kernel/acpi/boot.c | 61 ++- arch/x86/kernel/alternative.c | 7 +- arch/x86/kernel/cpu/bugs.c | 29 ++ arch/x86/kernel/cpu/microcode/intel.c | 14 +- arch/x86/kvm/svm.c | 19 + arch/x86/kvm/vmx.c | 26 +- arch/x86/kvm/x86.c | 8 +- arch/x86/mm/kaiser.c | 2 + arch/x86/mm/pat.c | 5 +- arch/x86/realmode/init.c | 4 +- arch/x86/realmode/rm/trampoline_64.S | 3 +- crypto/algapi.c | 12 + drivers/base/Kconfig | 3 + drivers/base/cpu.c | 48 ++ drivers/block/rbd.c | 2 +- drivers/char/hw_random/core.c | 6 +- drivers/char/mem.c | 6 +- drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c | 2 + drivers/infiniband/ulp/srpt/ib_srpt.c | 3 +- drivers/iommu/arm-smmu-v3.c | 8 +- drivers/md/dm-bufio.c | 7 +- drivers/media/usb/usbvision/usbvision-video.c | 7 + drivers/net/can/usb/gs_usb.c | 2 +- drivers/net/ethernet/intel/e1000e/ich8lan.c | 11 +- drivers/net/ethernet/renesas/sh_eth.c | 29 +- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 6 + drivers/net/usb/cx82310_eth.c | 7 +- drivers/net/usb/lan78xx.c | 9 +- drivers/net/usb/r8152.c | 132 +++--- drivers/net/usb/smsc75xx.c | 8 +- drivers/net/usb/sr9700.c | 9 +- drivers/staging/android/ashmem.c | 2 + drivers/target/iscsi/iscsi_target.c | 20 +- drivers/target/target_core_tmr.c | 9 + drivers/target/target_core_transport.c | 2 + drivers/tty/sysrq.c | 6 + drivers/usb/host/xhci-mem.c | 3 +- drivers/usb/misc/usb3503.c | 2 + drivers/usb/mon/mon_bin.c | 8 +- drivers/usb/musb/ux500.c | 7 +- drivers/usb/serial/cp210x.c | 2 + drivers/usb/storage/unusual_uas.h | 7 + drivers/usb/usbip/usbip_common.c | 17 +- fs/locks.c | 16 +- include/linux/bpf.h | 2 + include/linux/cpu.h | 7 + include/linux/filter.h | 3 + include/linux/phy.h | 11 + include/linux/sh_eth.h | 1 - include/target/target_core_base.h | 1 + include/trace/events/kvm.h | 7 +- kernel/bpf/arraymap.c | 37 +- kernel/bpf/core.c | 71 +++ kernel/bpf/syscall.c | 54 --- kernel/bpf/verifier.c | 217 ++++++--- kernel/futex.c | 8 +- kernel/locking/mutex.c | 5 +- mm/compaction.c | 50 ++- mm/page-writeback.c | 11 +- mm/zswap.c | 24 +- net/8021q/vlan.c | 7 +- net/bluetooth/l2cap_core.c | 20 +- net/core/sock_diag.c | 2 +- net/ipv6/ip6_output.c | 4 +- net/ipv6/ip6_tunnel.c | 9 +- net/mac80211/debugfs.c | 7 +- net/rds/rdma.c | 4 + sound/core/oss/pcm_oss.c | 41 +- sound/core/oss/pcm_plugin.c | 14 +- sound/core/pcm_lib.c | 4 +- sound/drivers/aloop.c | 98 ++-- tools/testing/selftests/vm/Makefile | 4 - tools/testing/selftests/x86/test_vsyscall.c | 500 +++++++++++++++++++++ 84 files changed, 1758 insertions(+), 470 deletions(-)
Greg Kroah-Hartman
maintainerPATCH 1/87 dm bufio: fix shrinker scans when (nr_to_scan < retain_target)
4.4-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 | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/md/dm-bufio.c +5 -2
@@ -1527,7 +1527,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++) {
@@ -1564,6 +1565,7 @@ dm_bufio_shrink_count(struct shrinker *s {struct dm_bufio_client *c;unsigned long count; +unsigned long retain_target; c = container_of(shrink, struct dm_bufio_client, shrinker);if (sc->gfp_mask & __GFP_FS)
@@ -1572,8 +1574,9 @@ dm_bufio_shrink_count(struct shrinker *sreturn 0 ; count = c->n_buffers[LIST_CLEAN ] + c->n_buffers[LIST_DIRTY ]; + retain_target =get_retain_buffers (c);dm_bufio_unlock (c); -return count; +return (count < retain_target) ?0 : (count - retain_target); }/*
Greg Kroah-Hartman
maintainerPATCH 2/87 KVM: Fix stack-out-of-bounds read in write_mmio
In reply to Greg Kroah-Hartman4.4-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/arm/kvm/mmio.c | 6 +++--- arch/x86/kvm/x86.c | 8 ++++---- include/trace/events/kvm.h | 7 +++++-- 3 files changed, 12 insertions(+), 9 deletions(-)
arch/arm/kvm/mmio.c +3 -3
@@ -113,7 +113,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); }
@@ -189,14 +189,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);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);
arch/x86/kvm/x86.c +4 -4
@@ -4114,7 +4114,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;
@@ -4362,7 +4362,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 ; }
@@ -4384,14 +4384,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
@@ -204,7 +204,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(
@@ -218,7 +218,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",
Greg Kroah-Hartman
maintainerPATCH 3/87 can: gs_usb: fix return value of the "set_bittiming" callback
In reply to Greg Kroah-Hartman4.4-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
@@ -430,7 +430,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 7/87 MIPS: Guard against any partial write attempt with PTRACE_SETREGSET
In reply to Greg Kroah-Hartman4.4-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
@@ -536,7 +536,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,
@@ -544,6 +552,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 8/87 MIPS: Consistently handle buffer counter with PTRACE_SETREGSET
In reply to Greg Kroah-Hartman4.4-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
@@ -524,7 +524,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 9/87 MIPS: Fix an FCSR access API regression with NT_PRFPREG and MSA
In reply to Greg Kroah-Hartman4.4-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
@@ -442,7 +442,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,
@@ -450,13 +450,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,
@@ -478,20 +479,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; }
@@ -499,7 +509,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,
@@ -507,13 +517,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,
@@ -538,6 +549,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
@@ -550,18 +563,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 10/87 MIPS: Also verify sizeof `elf_fpreg_t with PTRACE_SETREGSET
In reply to Greg Kroah-Hartman4.4-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
@@ -467,6 +467,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 12/87 net/mac80211/debugfs.c: prevent build failure with CONFIG_UBSAN=y
In reply to Greg Kroah-Hartman4.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Andrey Ryabinin <[email protected]>
commit 68920c973254c5b71a684645c5f6f82d6732c5d6 upstream.
With upcoming CONFIG_UBSAN the following BUILD_BUG_ON in net/mac80211/debugfs.c starts to trigger:
BUILD_BUG_ON(hw_flag_names[NUM_IEEE80211_HW_FLAGS] != (void *)0x1);
It seems, that compiler instrumentation causes some code deoptimizations. Because of that GCC is not being able to resolve condition in BUILD_BUG_ON() at compile time.
We could make size of hw_flag_names array unspecified and replace the condition in BUILD_BUG_ON() with following:
ARRAY_SIZE(hw_flag_names) != NUM_IEEE80211_HW_FLAGS
That will have the same effect as before (adding new flag without updating array will trigger build failure) except it doesn't fail with CONFIG_UBSAN. As a bonus this patch slightly decreases size of hw_flag_names array.
---
Hi,
The only stable tree which is missing this fix is 4.4. 4.1 doesn't have 30686bf7f5b3 ("mac80211: convert HW flags to unsigned long bitmap") which makes gcc unhappy with allmodconfig. 4.9 contains the fix.
Thanks,
Daniel
net/mac80211/debugfs.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)
net/mac80211/debugfs.c +2 -5
@@ -91,7 +91,7 @@ static const struct file_operations rese };#endif -static const char *hw_flag_names[NUM_IEEE80211_HW_FLAGS +1 ] = { +static const char *hw_flag_names[] = { #define FLAG(F) [IEEE80211_HW_##F] = #F FLAG(HAS_RATE_CONTROL), FLAG(RX_INCLUDES_FCS),
@@ -125,9 +125,6 @@ static const char *hw_flag_names[NUM_IEEFLAG (TDLS_WIDER_BW ),FLAG (SUPPORTS_AMSDU_IN_AMPDU ),FLAG (BEACON_TX_STATUS ), - -/* keep last for the build bug below */ - (void *)0x1 #undef FLAG };
@@ -147,7 +144,7 @@ static ssize_t hwflags_read(struct file/* fail compilation if somebody adds or removes * a flag without updating the name array above */ -BUILD_BUG_ON (hw_flag_names[NUM_IEEE80211_HW_FLAGS ] != (void *)0x1 ); +BUILD_BUG_ON (ARRAY_SIZE (hw_flag_names) !=NUM_IEEE80211_HW_FLAGS );for (i =0 ; i <NUM_IEEE80211_HW_FLAGS ; i++) {if (test_bit (i, local->hw.flags))
Greg Kroah-Hartman
maintainerPATCH 14/87 x86/vsdo: Fix build on PARAVIRT_CLOCK=y, KVM_GUEST=n
In reply to Greg Kroah-Hartman4.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Andy Lutomirski <[email protected]>
commit 8705d603edd49f1cff165cd3b7998f4c7f098d27 upstream.
arch/x86/built-in.o: In function `arch_setup_additional_pages':
(.text+0x587): undefined reference to `pvclock_pvti_cpu0_va'
KVM_GUEST selects PARAVIRT_CLOCK, so we can make pvclock_pvti_cpu0_va depend on KVM_GUEST.
--- arch/x86/include/asm/pvclock.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/include/asm/pvclock.h +1 -1
@@ -4,7 +4,7 @@#include <linux/clocksource.h> #include <asm/pvclock-abi.h> -#ifdef CONFIG_PARAVIRT_CLOCK +#ifdef CONFIG_KVM_GUEST extern struct pvclock_vsyscall_time_info *pvclock_pvti_cpu0_va (void );#else static inline struct pvclock_vsyscall_time_info *pvclock_pvti_cpu0_va (void )
Greg Kroah-Hartman
maintainerPATCH 15/87 x86/acpi: Handle SCI interrupts above legacy space gracefully
In reply to Greg Kroah-Hartman4.4-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
@@ -408,6 +408,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) {
@@ -452,7 +480,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 18/87 ALSA: pcm: Add missing error checks in OSS emulation plugin builder
In reply to Greg Kroah-Hartman4.4-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
@@ -591,18 +591,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 19/87 ALSA: pcm: Abort properly at pending signal in OSS read/write loops
In reply to Greg Kroah-Hartman4.4-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
@@ -1416,6 +1416,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;
@@ -1501,6 +1505,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 20/87 ALSA: pcm: Allow aborting mutex lock at OSS read/write loops
In reply to Greg Kroah-Hartman4.4-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
@@ -1369,8 +1369,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)
@@ -1414,18 +1417,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; }
@@ -1473,8 +1476,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 );
@@ -1505,16 +1511,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 21/87 ALSA: aloop: Release cable upon open error path
In reply to Greg Kroah-Hartman4.4-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 22/87 ALSA: aloop: Fix inconsistent format due to incomplete rule
In reply to Greg Kroah-Hartman4.4-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 23/87 ALSA: aloop: Fix racy hw constraints adjustment
In reply to Greg Kroah-Hartman4.4-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 24/87 x86/acpi: Reduce code duplication in mp_override_legacy_irq()
In reply to Greg Kroah-Hartman4.4-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
@@ -321,13 +321,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. */
@@ -337,14 +336,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!
@@ -352,16 +343,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 25/87 mm/compaction: fix invalid free_pfn and compact_cached_free_pfn
In reply to Greg Kroah-Hartman4.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Joonsoo Kim <[email protected]>
commit 623446e4dc45b37740268165107cc63abb3022f0 upstream.
free_pfn and compact_cached_free_pfn are the pointer that remember restart position of freepage scanner. When they are reset or invalid, we set them to zone_end_pfn because freepage scanner works in reverse direction. But, because zone range is defined as [zone_start_pfn, zone_end_pfn), zone_end_pfn is invalid to access. Therefore, we should not store it to free_pfn and compact_cached_free_pfn. Instead, we need to store zone_end_pfn - 1 to them. There is one more thing we should consider. Freepage scanner scan reversely by pageblock unit. If free_pfn and compact_cached_free_pfn are set to middle of pageblock, it regards that sitiation as that it already scans front part of pageblock so we lose opportunity to scan there. To fix-up, this patch do round_down() to guarantee that reset position will be pageblock aligned.
Note that thanks to the current pageblock_pfn_to_page() implementation, actual access to zone_end_pfn doesn't happen until now. But, following patch will change pageblock_pfn_to_page() so this patch is needed from now on.
--- mm/compaction.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
mm/compaction.c +5 -4
@@ -200,7 +200,8 @@ static void reset_cached_positions(struc { zone->compact_cached_migrate_pfn[0 ] = zone->zone_start_pfn; zone->compact_cached_migrate_pfn[1 ] = zone->zone_start_pfn; - zone->compact_cached_free_pfn =zone_end_pfn (zone); + zone->compact_cached_free_pfn = +round_down (zone_end_pfn (zone) -1 , pageblock_nr_pages); }/*
@@ -1358,11 +1359,11 @@ static int compact_zone(struct zone *zon*/ cc->migrate_pfn = zone->compact_cached_migrate_pfn[sync]; cc->free_pfn = zone->compact_cached_free_pfn; -if (cc->free_pfn < start_pfn || cc->free_pfn > end_pfn) { - cc->free_pfn = end_pfn & ~(pageblock_nr_pages-1 ); +if (cc->free_pfn < start_pfn || cc->free_pfn >= end_pfn) { + cc->free_pfn =round_down (end_pfn -1 , pageblock_nr_pages); zone->compact_cached_free_pfn = cc->free_pfn; } -if (cc->migrate_pfn < start_pfn || cc->migrate_pfn > end_pfn) { +if (cc->migrate_pfn < start_pfn || cc->migrate_pfn >= end_pfn) { cc->migrate_pfn = start_pfn; zone->compact_cached_migrate_pfn[0 ] = cc->migrate_pfn; zone->compact_cached_migrate_pfn[1 ] = cc->migrate_pfn;
Greg Kroah-Hartman
maintainerPATCH 26/87 mm/compaction: pass only pageblock aligned range to pageblock_pfn_to_page
In reply to Greg Kroah-Hartman4.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Joonsoo Kim <[email protected]>
commit e1409c325fdc1fef7b3d8025c51892355f065d15 upstream.
pageblock_pfn_to_page() is used to check there is valid pfn and all pages in the pageblock is in a single zone. If there is a hole in the pageblock, passing arbitrary position to pageblock_pfn_to_page() could cause to skip whole pageblock scanning, instead of just skipping the hole page. For deterministic behaviour, it's better to always pass pageblock aligned range to pageblock_pfn_to_page(). It will also help further optimization on pageblock_pfn_to_page() in the following patch.
--- mm/compaction.c | 41 ++++++++++++++++++++++++++++++----------- 1 file changed, 30 insertions(+), 11 deletions(-)
mm/compaction.c +30 -11
@@ -553,13 +553,17 @@ unsigned long isolate_freepages_range(struct compact_control *cc, unsigned long start_pfn, unsigned long end_pfn) { - unsigned long isolated, pfn, block_end_pfn; + unsigned long isolated, pfn, block_start_pfn, block_end_pfn;LIST_HEAD (freelist); pfn = start_pfn; + block_start_pfn = pfn & ~(pageblock_nr_pages -1 ); +if (block_start_pfn < cc->zone->zone_start_pfn) + block_start_pfn = cc->zone->zone_start_pfn; block_end_pfn =ALIGN (pfn +1 , pageblock_nr_pages);for (; pfn < end_pfn; pfn += isolated, + block_start_pfn = block_end_pfn, block_end_pfn += pageblock_nr_pages) {/* Protect pfn from changing by isolate_freepages_block */ unsigned long isolate_start_pfn = pfn;
@@ -572,11 +576,13 @@ isolate_freepages_range(struct compact_c* scanning range to right one. */ if (pfn >= block_end_pfn) { + block_start_pfn = pfn & ~(pageblock_nr_pages -1 ); block_end_pfn =ALIGN (pfn +1 , pageblock_nr_pages); block_end_pfn =min (block_end_pfn, end_pfn); } -if (!pageblock_pfn_to_page (pfn, block_end_pfn, cc->zone)) +if (!pageblock_pfn_to_page (block_start_pfn, + block_end_pfn, cc->zone))break ; isolated = isolate_freepages_block(cc, &isolate_start_pfn,
@@ -862,18 +868,23 @@ unsigned long isolate_migratepages_range(struct compact_control *cc, unsigned long start_pfn, unsigned long end_pfn) { - unsigned long pfn, block_end_pfn; + unsigned long pfn, block_start_pfn, block_end_pfn;/* Scan block by block. First and last block may be incomplete */ pfn = start_pfn; + block_start_pfn = pfn & ~(pageblock_nr_pages -1 ); +if (block_start_pfn < cc->zone->zone_start_pfn) + block_start_pfn = cc->zone->zone_start_pfn; block_end_pfn =ALIGN (pfn +1 , pageblock_nr_pages); for (; pfn < end_pfn; pfn = block_end_pfn, + block_start_pfn = block_end_pfn, block_end_pfn += pageblock_nr_pages) { block_end_pfn = min(block_end_pfn, end_pfn); - if (!pageblock_pfn_to_page(pfn, block_end_pfn, cc->zone)) + if (!pageblock_pfn_to_page(block_start_pfn, + block_end_pfn, cc->zone)) continue; pfn = isolate_migratepages_block(cc, pfn, block_end_pfn,
@@ -1091,7 +1102,9 @@ int sysctl_compact_unevictable_allowed _static isolate_migrate_t isolate_migratepages (struct zone *zone,struct compact_control *cc) { -unsigned long low_pfn, end_pfn; +unsigned long block_start_pfn; +unsigned long block_end_pfn; +unsigned long low_pfn;unsigned long isolate_start_pfn;struct page *page; const isolate_mode_t isolate_mode =
@@ -1103,16 +1116,21 @@ static isolate_migrate_t isolate_migrate* initialized by compact_zone() */ low_pfn = cc->migrate_pfn; + block_start_pfn = cc->migrate_pfn & ~(pageblock_nr_pages -1 ); +if (block_start_pfn < zone->zone_start_pfn) + block_start_pfn = zone->zone_start_pfn;/* Only scan within a pageblock boundary */ - end_pfn =ALIGN (low_pfn +1 , pageblock_nr_pages); + block_end_pfn =ALIGN (low_pfn +1 , pageblock_nr_pages);/* * Iterate over whole pageblocks until we find the first suitable. * Do not cross the free scanner. */ -for (; end_pfn <= cc->free_pfn; - low_pfn = end_pfn, end_pfn += pageblock_nr_pages) { +for (; block_end_pfn <= cc->free_pfn; + low_pfn = block_end_pfn, + block_start_pfn = block_end_pfn, + block_end_pfn += pageblock_nr_pages) {/* * This can potentially iterate a massively long zone with
@@ -1123,7 +1141,8 @@ static isolate_migrate_t isolate_migrate && compact_should_abort(cc))break ; - page =pageblock_pfn_to_page (low_pfn, end_pfn, zone); + page =pageblock_pfn_to_page (block_start_pfn, block_end_pfn, + zone);if (!page)continue ;
@@ -1142,8 +1161,8 @@ static isolate_migrate_t isolate_migrate/* Perform the isolation */ isolate_start_pfn = low_pfn; - low_pfn =isolate_migratepages_block (cc, low_pfn, end_pfn, - isolate_mode); + low_pfn =isolate_migratepages_block (cc, low_pfn, + block_end_pfn, isolate_mode);if (!low_pfn || cc->contended) {acct_isolated (zone, cc);
Greg Kroah-Hartman
maintainerPATCH 27/87 mm/page-writeback: fix dirty_ratelimit calculation
In reply to Greg Kroah-Hartman4.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Andrey Ryabinin <[email protected]>
commit d59b1087a98e402ed9a7cc577f4da435f9a555f5 upstream.
Calculation of dirty_ratelimit sometimes is not correct. E.g. initial values of dirty_ratelimit == INIT_BW and step == 0, lead to the following result:
UBSAN: Undefined behaviour in ../mm/page-writeback.c:1286:7 shift exponent 25600 is too large for 64-bit type 'long unsigned int'
The fix is straightforward - make step 0 if the shift exponent is too big.
--- mm/page-writeback.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)
mm/page-writeback.c +6 -5
@@ -1162,6 +1162,7 @@ static void wb_update_dirty_ratelimit(stunsigned long balanced_dirty_ratelimit;unsigned long step;unsigned long x; +unsigned long shift;/* * The dirty rate will match the writeout rate in long term, except
@@ -1286,11 +1287,11 @@ static void wb_update_dirty_ratelimit(st* rate itself is constantly fluctuating. So decrease the track speed * when it gets close to the target. Helps eliminate pointless tremors. */ - step >>= dirty_ratelimit / (2 * step +1 ); -/* -* Limit the tracking speed to avoid overshooting. -*/ - step = (step +7 ) /8 ; + shift = dirty_ratelimit / (2 * step +1 ); +if (shift <BITS_PER_LONG ) + step =DIV_ROUND_UP (step >> shift,8 ); +else + step =0 ;if (dirty_ratelimit < balanced_dirty_ratelimit) dirty_ratelimit += step;
Greg Kroah-Hartman
maintainerPATCH 28/87 mm/zswap: use workqueue to destroy pool
In reply to Greg Kroah-Hartman4.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dan Streetman <[email protected]>
commit 200867af4dedfe7cb707f96773684de1d1fd21e6 upstream.
Add a work_struct to struct zswap_pool, and change __zswap_pool_empty to use the workqueue instead of using call_rcu().
When zswap destroys a pool no longer in use, it uses call_rcu() to perform the destruction/freeing. Since that executes in softirq context, it must not sleep. However, actually destroying the pool involves freeing the per-cpu compressors (which requires locking the cpu_add_remove_lock mutex) and freeing the zpool, for which the implementation may sleep (e.g. zsmalloc calls kmem_cache_destroy, which locks the slab_mutex). So if either mutex is currently taken, or any other part of the compressor or zpool implementation sleeps, it will result in a BUG().
It's not easy to reproduce this when changing zswap's params normally. In testing with a loaded system, this does not fail:
$ cd /sys/module/zswap/parameters $ echo lz4 > compressor ; echo zsmalloc > zpool
nor does this:
$ while true ; do
Quoted 5 lines
echo lzo > compressor ; echo zbud > zpool
sleep 1
echo lz4 > compressor ; echo zsmalloc > zpool
sleep 1
done
although it's still possible either of those might fail, depending on whether anything else besides zswap has locked the mutexes.
However, changing a parameter with no delay immediately causes the schedule while atomic BUG:
$ while true ; do
Quoted 2 lines
echo lzo > compressor ; echo lz4 > compressor
done
This is essentially the same as Yu Zhao's proposed patch to zsmalloc, but moved to zswap, to cover compressor and zpool freeing.
--- mm/zswap.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
mm/zswap.c +8 -4
@@ -123,7 +123,7 @@ struct zswap_pool {struct crypto_comp *__percpu *tfm;struct kref kref;struct list_head list; -struct rcu_head rcu_head; +struct work_struct work;struct notifier_block notifier;char tfm_name[CRYPTO_MAX_ALG_NAME ]; };
@@ -667,9 +667,11 @@ static int __must_check zswap_pool_get(sreturn kref_get_unless_zero (&pool->kref); } -static void __zswap_pool_release (struct rcu_head *head) +static void __zswap_pool_release (struct work_struct *work) { -struct zswap_pool *pool =container_of (head,typeof (*pool), rcu_head); +struct zswap_pool *pool =container_of (work,typeof (*pool), work); + +synchronize_rcu ();/* nobody should have been able to get a kref... */ WARN_ON (kref_get_unless_zero (&pool->kref));
@@ -689,7 +691,9 @@ static void __zswap_pool_empty(struct krWARN_ON (pool ==zswap_pool_current ());list_del_rcu (&pool->list); -call_rcu (&pool->rcu_head, __zswap_pool_release); + +INIT_WORK (&pool->work, __zswap_pool_release); +schedule_work (&pool->work);spin_unlock (&zswap_pools_lock); }
Greg Kroah-Hartman
maintainerPATCH 29/87 zswap: dont param_set_charp while holding spinlock
In reply to Greg Kroah-Hartman4.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dan Streetman <[email protected]>
commit fd5bb66cd934987e49557455b6497fc006521940 upstream.
Change the zpool/compressor param callback function to release the zswap_pools_lock spinlock before calling param_set_charp, since that function may sleep when it calls kmalloc with GFP_KERNEL.
While this problem has existed for a while, I wasn't able to trigger it using a tight loop changing either/both the zpool and compressor params; I think it's very unlikely to be an issue on the stable kernels, especially since most zswap users will change the compressor and/or zpool from sysfs only one time each boot - or zero times, if they add the params to the kernel boot.
--- mm/zswap.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
mm/zswap.c +8 -4
@@ -752,18 +752,22 @@ static int __zswap_param_set(const char pool =zswap_pool_find_get (type, compressor);if (pool) {zswap_pool_debug ("using existing" , pool); +WARN_ON (pool ==zswap_pool_current ());list_del_rcu (&pool->list); - }else { -spin_unlock (&zswap_pools_lock); - pool =zswap_pool_create (type, compressor); -spin_lock (&zswap_pools_lock); } +spin_unlock (&zswap_pools_lock); + +if (!pool) + pool =zswap_pool_create (type, compressor); +if (pool) ret =param_set_charp (s, kp);else ret = -EINVAL ; +spin_lock (&zswap_pools_lock); +if (!ret) { put_pool =zswap_pool_current ();list_add_rcu (&pool->list, &zswap_pools);
Greg Kroah-Hartman
maintainerPATCH 31/87 futex: Replace barrier() in unqueue_me() with READ_ONCE()
In reply to Greg Kroah-Hartman4.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jianyu Zhan <[email protected]>
commit 29b75eb2d56a714190a93d7be4525e617591077a upstream.
Commit e91467ecd1ef ("bug in futex unqueue_me") introduced a barrier() in unqueue_me() to prevent the compiler from rereading the lock pointer which might change after a check for NULL.
Replace the barrier() with a READ_ONCE() for the following reasons:
1) READ_ONCE() is a weaker form of barrier() that affects only the specific load operation, while barrier() is a general compiler level memory barrier. READ_ONCE() was not available at the time when the barrier was added.
2) Aside of that READ_ONCE() is descriptive and self explainatory while a barrier without comment is not clear to the casual reader.
No functional change.
[ tglx: Massaged changelog ]
--- kernel/futex.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
kernel/futex.c +6 -2
@@ -1939,8 +1939,12 @@ static int unqueue_me(struct futex_q *q)/* In the common case we don't take the spinlock, which is nice. */ retry: - lock_ptr = q->lock_ptr; -barrier (); +/* +* q->lock_ptr can change between this read and the following spin_lock. +* Use READ_ONCE to forbid the compiler from reloading q->lock_ptr and +* optimizing lock_ptr out of the logic below. +*/ + lock_ptr =READ_ONCE (q->lock_ptr);if (lock_ptr !=NULL ) {spin_lock (lock_ptr);/*
Greg Kroah-Hartman
maintainerPATCH 33/87 usbvision fix overflow of interfaces array
In reply to Greg Kroah-Hartman4.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Oliver Neukum <[email protected]>
commit 588afcc1c0e45358159090d95bf7b246fb67565f upstream.
This fixes the crash reported in:
http://seclists.org/bugtraq/2015/Oct/35
The interface number needs a sanity check.
--- drivers/media/usb/usbvision/usbvision-video.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/media/usb/usbvision/usbvision-video.c +7 -0
@@ -1461,6 +1461,13 @@ static int usbvision_probe(struct usb_inprintk (KERN_INFO "%s: %s found\n" , __func__, usbvision_device_data[model].model_string); +/* +* this is a security check. +* an exploit using an incorrect bInterfaceNumber is known +*/ +if (ifnum >=USB_MAXINTERFACES || !dev->actconfig->interface[ifnum]) +return -ENODEV ; +if (usbvision_device_data[model].interface >=0 ) interface = &dev->actconfig->interface[usbvision_device_data[model].interface]->altsetting[0 ];else if (ifnum < dev->actconfig->desc.bNumInterfaces)
Greg Kroah-Hartman
maintainerPATCH 34/87 usb: musb: ux500: Fix NULL pointer dereference at system PM
In reply to Greg Kroah-Hartman4.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ulf Hansson <[email protected]>
commit 79c5623f1cb85f33403eb9f1e45124e9f56181f8 upstream.
The commit 7d32cdef5356 ("usb: musb: fail with error when no DMA controller set"), caused the core platform driver to correctly return an error code when fail probing.
Unfurtante it also caused bug for a NULL pointer dereference, during system suspend for the ux500 driver. The reason is a lacking validation of the corresponding ->driver_data pointer, which won't be set when the musb core driver fails to probe (or haven't yet been probed).
--- drivers/usb/musb/ux500.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/usb/musb/ux500.c +5 -2
@@ -348,7 +348,9 @@ static int ux500_suspend(struct device *struct ux500_glue *glue =dev_get_drvdata (dev);struct musb *musb =glue_to_musb (glue); -usb_phy_set_suspend (musb->xceiv,1 ); +if (musb) +usb_phy_set_suspend (musb->xceiv,1 ); +clk_disable_unprepare (glue->clk);return 0 ;
@@ -366,7 +368,8 @@ static int ux500_resume(struct device *dreturn ret; } -usb_phy_set_suspend (musb->xceiv,0 ); +if (musb) +usb_phy_set_suspend (musb->xceiv,0 );return 0 ; }
Greg Kroah-Hartman
maintainerPATCH 35/87 r8152: fix the wake event
In reply to Greg Kroah-Hartman4.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: hayeswang <[email protected]>
commit 5ee3c60c8d3b88cab6496c9b7d49a01576dd9cf9 upstream.
When the autosuspend is enabled and occurs before system suspend, we should wake the device before running system syspend. Then, we could change the wake event for system suspend. Otherwise, the device would resume the system when receiving any packet.
--- drivers/net/usb/r8152.c | 40 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-)
drivers/net/usb/r8152.c +39 -1
@@ -25,12 +25,13 @@#include <uapi/linux/mdio.h> #include <linux/mdio.h> #include <linux/usb/cdc.h> +#include <linux/suspend.h> /* Information for net-next */ #define NETNEXT_VERSION "08"/* Information for net */ -#define NET_VERSION "2" +#define NET_VERSION "3"#define DRIVER_VERSION "v1." NETNEXT_VERSION "." NET_VERSION#define DRIVER_AUTHOR "Realtek linux nic maintainers <[email protected]>"
@@ -604,6 +605,9 @@ struct r8152 {struct delayed_work schedule;struct mii_if_info mii;struct mutex control;/* use for hw setting */ +#ifdef CONFIG_PM_SLEEP +struct notifier_block pm_notifier; +#endif struct rtl_ops {void (*init)(struct r8152 *);
@@ -3060,6 +3064,33 @@ out1:usb_autopm_put_interface (tp->intf); } +#ifdef CONFIG_PM_SLEEP +static int rtl_notifier (struct notifier_block *nb,unsigned long action, +void *data) +{ + struct r8152 *tp = container_of(nb, struct r8152, pm_notifier); + +switch (action) { +case PM_HIBERNATION_PREPARE : +case PM_SUSPEND_PREPARE : +usb_autopm_get_interface (tp->intf); +break ; + +case PM_POST_HIBERNATION : +case PM_POST_SUSPEND : +usb_autopm_put_interface (tp->intf); +break ; + +case PM_POST_RESTORE : +case PM_RESTORE_PREPARE : +default : +break ; + } + +return NOTIFY_DONE ; +} +#endif +static int rtl8152_open (struct net_device *netdev) {struct r8152 *tp =netdev_priv (netdev);
@@ -3102,6 +3133,10 @@ static int rtl8152_open(struct net_devicmutex_unlock (&tp->control);usb_autopm_put_interface (tp->intf); +#ifdef CONFIG_PM_SLEEP + tp->pm_notifier.notifier_call = rtl_notifier; +register_pm_notifier (&tp->pm_notifier); +#endif out:return res;
@@ -3112,6 +3147,9 @@ static int rtl8152_close(struct net_devistruct r8152 *tp =netdev_priv (netdev);int res =0 ; +#ifdef CONFIG_PM_SLEEP +unregister_pm_notifier (&tp->pm_notifier); +#endif napi_disable (&tp->napi);clear_bit (WORK_ENABLE , &tp->flags);usb_kill_urb (tp->intr_urb);
Greg Kroah-Hartman
maintainerPATCH 36/87 r8152: use test_and_clear_bit
In reply to Greg Kroah-Hartman4.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: hayeswang <[email protected]>
commit 216a8349d3a0dd1bc2afbcc821e374c8f929bd62 upstream.
Replace test_bit() followed by clear_bit() with test_and_clear_bit().
--- drivers/net/usb/r8152.c | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-)
drivers/net/usb/r8152.c +6 -14
@@ -1947,7 +1947,6 @@ static void _rtl8152_set_rx_mode(struct__le32 tmp[2 ];u32 ocp_data; -clear_bit (RTL8152_SET_RX_MODE , &tp->flags);netif_stop_queue (netdev); ocp_data =ocp_read_dword (tp,MCU_TYPE_PLA ,PLA_RCR ); ocp_data &= ~RCR_ACPT_ALL ;
@@ -2433,8 +2432,6 @@ static void rtl_phy_reset(struct r8152 *u16 data;int i; -clear_bit (PHY_RESET , &tp->flags); - data =r8152_mdio_read (tp,MII_BMCR );/* don't reset again before the previous one complete */
@@ -2893,10 +2890,9 @@ static int rtl8152_set_speed(struct r815r8152_mdio_write (tp,MII_ADVERTISE , anar);r8152_mdio_write (tp,MII_BMCR , bmcr); -if (test_bit (PHY_RESET , &tp->flags)) { +if (test_and_clear_bit (PHY_RESET , &tp->flags)) {int i; -clear_bit (PHY_RESET , &tp->flags);for (i =0 ; i <50 ; i++) {msleep (20 );if ((r8152_mdio_read (tp,MII_BMCR ) &BMCR_RESET ) ==0 )
@@ -2905,7 +2901,6 @@ static int rtl8152_set_speed(struct r815 } out: -return ret; }
@@ -2992,7 +2987,6 @@ static void set_carrier(struct r8152 *tpstruct net_device *netdev = tp->netdev;u8 speed; -clear_bit (RTL8152_LINK_CHG , &tp->flags); speed =rtl8152_get_speed (tp);if (speed &LINK_STATUS ) {
@@ -3042,20 +3036,18 @@ static void rtl_work_func_t(struct work_ goto out1; } -if (test_bit (RTL8152_LINK_CHG , &tp->flags)) +if (test_and_clear_bit (RTL8152_LINK_CHG , &tp->flags))set_carrier (tp); -if (test_bit (RTL8152_SET_RX_MODE , &tp->flags)) +if (test_and_clear_bit (RTL8152_SET_RX_MODE , &tp->flags))_rtl8152_set_rx_mode (tp->netdev);/* don't schedule napi before linking */ -if (test_bit (SCHEDULE_NAPI , &tp->flags) && -netif_carrier_ok (tp->netdev)) { -clear_bit (SCHEDULE_NAPI , &tp->flags); +if (test_and_clear_bit (SCHEDULE_NAPI , &tp->flags) && +netif_carrier_ok (tp->netdev))napi_schedule (&tp->napi); - } -if (test_bit (PHY_RESET , &tp->flags)) +if (test_and_clear_bit (PHY_RESET , &tp->flags))rtl_phy_reset (tp);mutex_unlock (&tp->control);
Greg Kroah-Hartman
maintainerPATCH 37/87 r8152: adjust ALDPS function
In reply to Greg Kroah-Hartman4.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: hayeswang <[email protected]>
commit cda9fb01dc3cafd718b2865b447e869bf6624ddd upstream.
Replace disable_aldps() and enable_aldps() with aldps_en().
--- drivers/net/usb/r8152.c | 72 ++++++++++++++++++++++-------------------------- 1 file changed, 34 insertions(+), 38 deletions(-)
drivers/net/usb/r8152.c +34 -38
@@ -2461,23 +2461,23 @@ static void r8153_teredo_off(struct r815ocp_write_dword (tp,MCU_TYPE_PLA ,PLA_TEREDO_TIMER ,0 ); } -static void r8152b_disable_aldps (struct r8152 *tp) +static void r8152_aldps_en (struct r8152 *tp,bool enable) { -ocp_reg_write (tp,OCP_ALDPS_CONFIG ,ENPDNPS |LINKENA |DIS_SDSAVE ); -msleep (20 ); -} - -static inline void r8152b_enable_aldps (struct r8152 *tp) -{ -ocp_reg_write (tp,OCP_ALDPS_CONFIG ,ENPWRSAVE |ENPDNPS | -LINKENA |DIS_SDSAVE ); +if (enable) { +ocp_reg_write (tp,OCP_ALDPS_CONFIG ,ENPWRSAVE |ENPDNPS | +LINKENA |DIS_SDSAVE ); + }else { +ocp_reg_write (tp,OCP_ALDPS_CONFIG ,ENPDNPS |LINKENA | +DIS_SDSAVE ); +msleep (20 ); + } }static void rtl8152_disable (struct r8152 *tp) { -r8152b_disable_aldps (tp); +r8152_aldps_en (tp, false);rtl_disable (tp); -r8152b_enable_aldps (tp); +r8152_aldps_en (tp, true); }static void r8152b_hw_phy_cfg (struct r8152 *tp)
@@ -2789,30 +2789,26 @@ static void r8153_enter_oob(struct r8152ocp_write_dword (tp,MCU_TYPE_PLA ,PLA_RCR , ocp_data); } -static void r8153_disable_aldps (struct r8152 *tp) +static void r8153_aldps_en (struct r8152 *tp,bool enable) {u16 data; data =ocp_reg_read (tp,OCP_POWER_CFG ); - data &= ~EN_ALDPS ; -ocp_reg_write (tp,OCP_POWER_CFG , data); -msleep (20 ); -} - -static void r8153_enable_aldps (struct r8152 *tp) -{ -u16 data; - - data =ocp_reg_read (tp,OCP_POWER_CFG ); - data |=EN_ALDPS ; -ocp_reg_write (tp,OCP_POWER_CFG , data); +if (enable) { + data |=EN_ALDPS ; +ocp_reg_write (tp,OCP_POWER_CFG , data); + }else { + data &= ~EN_ALDPS ; +ocp_reg_write (tp,OCP_POWER_CFG , data); +msleep (20 ); + } }static void rtl8153_disable (struct r8152 *tp) { -r8153_disable_aldps (tp); +r8153_aldps_en (tp, false);rtl_disable (tp); -r8153_enable_aldps (tp); +r8153_aldps_en (tp, true);usb_enable_lpm (tp->udev); }
@@ -2909,9 +2905,9 @@ static void rtl8152_up(struct r8152 *tp)if (test_bit (RTL8152_UNPLUG , &tp->flags))return ; -r8152b_disable_aldps (tp); +r8152_aldps_en (tp, false);r8152b_exit_oob (tp); -r8152b_enable_aldps (tp); +r8152_aldps_en (tp, true); }static void rtl8152_down (struct r8152 *tp)
@@ -2922,9 +2918,9 @@ static void rtl8152_down(struct r8152 *t }r8152_power_cut_en (tp, false); -r8152b_disable_aldps (tp); +r8152_aldps_en (tp, false);r8152b_enter_oob (tp); -r8152b_enable_aldps (tp); +r8152_aldps_en (tp, true); }static void rtl8153_up (struct r8152 *tp)
@@ -2933,9 +2929,9 @@ static void rtl8153_up(struct r8152 *tp)return ;r8153_u1u2en (tp, false); -r8153_disable_aldps (tp); +r8153_aldps_en (tp, false);r8153_first_init (tp); -r8153_enable_aldps (tp); +r8153_aldps_en (tp, true);r8153_u2p3en (tp, true);r8153_u1u2en (tp, true);usb_enable_lpm (tp->udev);
@@ -2951,9 +2947,9 @@ static void rtl8153_down(struct r8152 *tr8153_u1u2en (tp, false);r8153_u2p3en (tp, false);r8153_power_cut_en (tp, false); -r8153_disable_aldps (tp); +r8153_aldps_en (tp, false);r8153_enter_oob (tp); -r8153_enable_aldps (tp); +r8153_aldps_en (tp, true); }static bool rtl8152_in_nway (struct r8152 *tp)
@@ -3280,7 +3276,7 @@ static void r8152b_init(struct r8152 *tpif (test_bit (RTL8152_UNPLUG , &tp->flags))return ; -r8152b_disable_aldps (tp); +r8152_aldps_en (tp, false);if (tp->version ==RTL_VER_01 ) { ocp_data =ocp_read_word (tp,MCU_TYPE_PLA ,PLA_LED_FEATURE );
@@ -3302,7 +3298,7 @@ static void r8152b_init(struct r8152 *tpocp_write_word (tp,MCU_TYPE_PLA ,PLA_GPHY_INTR_IMR , ocp_data);r8152b_enable_eee (tp); -r8152b_enable_aldps (tp); +r8152_aldps_en (tp, true);r8152b_enable_fc (tp);rtl_tally_reset (tp);
@@ -3320,7 +3316,7 @@ static void r8153_init(struct r8152 *tp)if (test_bit (RTL8152_UNPLUG , &tp->flags))return ; -r8153_disable_aldps (tp); +r8153_aldps_en (tp, false);r8153_u1u2en (tp, false);for (i =0 ; i <500 ; i++) {
@@ -3409,7 +3405,7 @@ static void r8153_init(struct r8152 *tp) EEE_SPDWN_EN);r8153_enable_eee (tp); -r8153_enable_aldps (tp); +r8153_aldps_en (tp, true);r8152b_enable_fc (tp);rtl_tally_reset (tp);r8153_u2p3en (tp, true);
Greg Kroah-Hartman
maintainerPATCH 39/87 sr9700: use skb_cow_head() to deal with cloned skbs
In reply to Greg Kroah-Hartman4.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Dumazet <[email protected]>
commit d532c1082f68176363ed766d09bf187616e282fe upstream.
We need to ensure there is enough headroom to push extra header, but we also need to check if we are allowed to change headers.
skb_cow_head() is the proper helper to deal with this.
--- drivers/net/usb/sr9700.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-)
drivers/net/usb/sr9700.c +2 -7
@@ -456,14 +456,9 @@ static struct sk_buff *sr9700_tx_fixup(s len = skb->len; -if (skb_headroom (skb) <SR_TX_OVERHEAD ) { -struct sk_buff *skb2; - - skb2 =skb_copy_expand (skb,SR_TX_OVERHEAD ,0 , flags); +if (skb_cow_head (skb,SR_TX_OVERHEAD )) {dev_kfree_skb_any (skb); - skb = skb2; -if (!skb) -return NULL ; +return NULL ; }__skb_push (skb,SR_TX_OVERHEAD );
Greg Kroah-Hartman
maintainerPATCH 41/87 cx82310_eth: use skb_cow_head() to deal with cloned skbs
In reply to Greg Kroah-Hartman4.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Dumazet <[email protected]>
commit a9e840a2081ed28c2b7caa6a9a0041c950b3c37d upstream.
We need to ensure there is enough headroom to push extra header, but we also need to check if we are allowed to change headers.
skb_cow_head() is the proper helper to deal with this.
--- drivers/net/usb/cx82310_eth.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)
drivers/net/usb/cx82310_eth.c +2 -5
@@ -293,12 +293,9 @@ static struct sk_buff *cx82310_tx_fixup( {int len = skb->len; -if (skb_headroom (skb) <2 ) { -struct sk_buff *skb2 =skb_copy_expand (skb,2 ,0 , flags); +if (skb_cow_head (skb,2 )) {dev_kfree_skb_any (skb); - skb = skb2; -if (!skb) -return NULL ; +return NULL ; }skb_push (skb,2 );
Greg Kroah-Hartman
maintainerPATCH 43/87 hwrng: core - sleep interruptible in read
In reply to Greg Kroah-Hartman4.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiri Slaby <[email protected]>
commit 1ab87298cb59b649d8d648d25dc15b36ab865f5a upstream.
hwrng kthread can be waiting via hwrng_fillfn for some data from a rng like virtio-rng:
hwrng D ffff880093e17798 0 382 2 0x00000000
...
Call Trace: [<ffffffff817339c6>] wait_for_completion_killable+0x96/0x210 [<ffffffffa00aa1b7>] virtio_read+0x57/0xf0 [virtio_rng] [<ffffffff814f4a35>] hwrng_fillfn+0x75/0x130 [<ffffffff810aa243>] kthread+0xf3/0x110
And when some user program tries to read the /dev node in this state, we get:
rngd D ffff880093e17798 0 762 1 0x00000004
...
Call Trace: [<ffffffff817351ac>] mutex_lock_nested+0x15c/0x3e0 [<ffffffff814f478e>] rng_dev_read+0x6e/0x240 [<ffffffff81231958>] __vfs_read+0x28/0xe0 [<ffffffff81232393>] vfs_read+0x83/0x130
And this is indeed unkillable. So use mutex_lock_interruptible instead of mutex_lock in rng_dev_read and exit immediatelly when interrupted. And possibly return already read data, if any (as POSIX allows).
v2: use ERESTARTSYS instead of EINTR
--- drivers/char/hw_random/core.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/char/hw_random/core.c +5 -1
@@ -238,7 +238,10 @@ static ssize_t rng_dev_read(struct file goto out; } -mutex_lock (&reading_mutex); +if (mutex_lock_interruptible (&reading_mutex)) { + err = -ERESTARTSYS ; + goto out_put; + }if (!data_avail) { bytes_read = rng_get_data(rng, rng_buffer, rng_buffer_size(),
@@ -288,6 +291,7 @@ out: out_unlock_reading:mutex_unlock (&reading_mutex); +out_put:put_rng (rng); goto out; }
Greg Kroah-Hartman
maintainerPATCH 46/87 Revert "userfaultfd: selftest: vm: allow to build in vm/ directory"
In reply to Greg Kroah-Hartman4.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Greg Kroah-Hartman <[email protected]>
This reverts commit b5213e1e9f25ccde958aa6364815ee87fef91100 which was commit 46aa6a302b53f543f8e8b8e1714dc5e449ad36a6 upstream.
This is being reverted because the affected commit this was trying to fix, a8ba798bc8ec ("selftests: enable O and KBUILD_OUTPUT"), was never backported to the 4.4-stable tree.
--- tools/testing/selftests/vm/Makefile | 4 ---- 1 file changed, 4 deletions(-)
tools/testing/selftests/vm/Makefile +0 -4
@@ -1,9 +1,5 @@ # Makefile for vm selftests -ifndef OUTPUT - OUTPUT := $(shell pwd) -endif - CFLAGS = -Wall -I ../../../../usr/include $(EXTRA_CFLAGS) BINARIES = compaction_test BINARIES += hugepage-mmap
Greg Kroah-Hartman
maintainerPATCH 47/87 x86/pti/efi: broken conversion from efi to kernel page table
In reply to Greg Kroah-Hartman4.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pavel Tatashin <[email protected]>
In entry_64.S we have code like this:
/* Unconditionally use kernel CR3 for do_nmi() */
/* %rax is saved above, so OK to clobber here */
ALTERNATIVE "jmp 2f", "movq %cr3, %rax", X86_FEATURE_KAISER
/* If PCID enabled, NOFLUSH now and NOFLUSH on return */
ALTERNATIVE "", "bts $63, %rax", X86_FEATURE_PCID
pushq %rax
/* mask off "user" bit of pgd address and 12 PCID bits: */
andq $(~(X86_CR3_PCID_ASID_MASK | KAISER_SHADOW_PGD_OFFSET)), %rax
movq %rax, %cr32:
/* paranoidentry do_nmi, 0; without TRACE_IRQS_OFF */
call do_nmiWith this instruction:
andq $(~(X86_CR3_PCID_ASID_MASK | KAISER_SHADOW_PGD_OFFSET)), %rax
We unconditionally switch from whatever our CR3 was to kernel page table. But, in arch/x86/platform/efi/efi_64.c We temporarily set a different page table, that does not have the kernel page table with 0x1000 offset from it.
Look in efi_thunk() and efi_thunk_set_virtual_address_map().
So, while CR3 points to the other page table, we get an NMI interrupt, and clear 0x1000 from CR3, resulting in a bogus CR3 if the 0x1000 bit was set.
The efi page table comes from realmode/rm/trampoline_64.S:
arch/x86/realmode/rm/trampoline_64.S
141 .bss
142 .balign PAGE_SIZE
143 GLOBAL(trampoline_pgd) .space PAGE_SIZE
Notice: alignment is PAGE_SIZE, so after applying KAISER_SHADOW_PGD_OFFSET which equal to PAGE_SIZE, we can get a different page table.
But, even if we fix alignment, here the trampoline binary is later copied into dynamically allocated memory in reserve_real_mode(), so we need to fix that place as well.
--- arch/x86/include/asm/kaiser.h | 10 ++++++++++ arch/x86/realmode/init.c | 4 +++- arch/x86/realmode/rm/trampoline_64.S | 3 ++- 3 files changed, 15 insertions(+), 2 deletions(-)
arch/x86/include/asm/kaiser.h +10 -0
@@ -19,6 +19,16 @@#define KAISER_SHADOW_PGD_OFFSET 0x1000 +#ifdef CONFIG_PAGE_TABLE_ISOLATION +/* +* A page table address must have this alignment to stay the same when +* KAISER_SHADOW_PGD_OFFSET mask is applied +*/ +#define KAISER_KERNEL_PGD_ALIGNMENT (KAISER_SHADOW_PGD_OFFSET << 1) +#else +#define KAISER_KERNEL_PGD_ALIGNMENT PAGE_SIZE +#endif +#ifdef __ASSEMBLY__#ifdef CONFIG_PAGE_TABLE_ISOLATION
arch/x86/realmode/init.c +3 -1
@@ -4,6 +4,7 @@#include <asm/cacheflush.h> #include <asm/pgtable.h> #include <asm/realmode.h> +#include <asm/kaiser.h> struct real_mode_header *real_mode_header;u32 *trampoline_cr4_features;
@@ -15,7 +16,8 @@ void __init reserve_real_mode(void)size_t size =PAGE_ALIGN (real_mode_blob_end - real_mode_blob);/* Has to be under 1M so we can execute real-mode AP code. */ - mem =memblock_find_in_range (0 ,1 <<20 , size,PAGE_SIZE ); + mem =memblock_find_in_range (0 ,1 <<20 , size, +KAISER_KERNEL_PGD_ALIGNMENT );if (!mem)panic ("Cannot allocate trampoline\n" );
arch/x86/realmode/rm/trampoline_64.S +2 -1
@@ -30,6 +30,7 @@ #include <asm/msr.h> #include <asm/segment.h> #include <asm/processor-flags.h> +#include <asm/kaiser.h> #include "realmode.h" .text
@@ -139,7 +140,7 @@ tr_gdt: tr_gdt_end: .bss - .balign PAGE_SIZE + .balign KAISER_KERNEL_PGD_ALIGNMENT GLOBAL(trampoline_pgd) .space PAGE_SIZE .balign 8
Greg Kroah-Hartman
maintainerPATCH 49/87 ip6_tunnel: disable dst caching if tunnel is dual-stack
In reply to Greg Kroah-Hartman4.4-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
@@ -1083,10 +1083,11 @@ static int ip6_tnl_xmit2(struct sk_buffmemcpy (&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 51/87 RDS: Heap OOB write in rds_message_alloc_sgs()
In reply to Greg Kroah-Hartman4.4-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
@@ -517,6 +517,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 52/87 RDS: null pointer dereference in rds_atomic_free_op
In reply to Greg Kroah-Hartman4.4-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
@@ -869,6 +869,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 53/87 sh_eth: fix TSU resource handling
In reply to Greg Kroah-Hartman4.4-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
@@ -3176,10 +3176,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 54/87 sh_eth: fix SH7757 GEther initialization
In reply to Greg Kroah-Hartman4.4-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
@@ -3205,8 +3205,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
@@ -16,7 +16,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 55/87 net: stmmac: enable EEE in MII, GMII or RGMII only
In reply to Greg Kroah-Hartman4.4-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 ++++++ include/linux/phy.h | 11 +++++++++++ 2 files changed, 17 insertions(+)
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +6 -0
@@ -272,8 +272,14 @@ bool stmmac_eee_init(struct stmmac_priv {char *phy_bus_name = priv->plat->phy_bus_name;unsigned long flags; +int interface = priv->plat->interface;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. */
include/linux/phy.h +11 -0
@@ -683,6 +683,17 @@ static inline bool phy_is_internal(struc }/** +* phy_interface_mode_is_rgmii - Convenience function for testing if a +* PHY interface mode is RGMII (all variants) +* @mode: the phy_interface_t enum +*/ +static inline bool phy_interface_mode_is_rgmii (phy_interface_t mode) +{ +return mode >=PHY_INTERFACE_MODE_RGMII && + mode <=PHY_INTERFACE_MODE_RGMII_TXID ; +}; + +/** * phy_interface_is_rgmii - Convenience function for testing if a PHY interface * is RGMII (all variants) * @phydev: the phy_device struct
Greg Kroah-Hartman
maintainerPATCH 56/87 ipv6: fix possible mem leaks in ipv6_make_skb()
In reply to Greg Kroah-Hartman4.4-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 | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
net/ipv6/ip6_output.c +3 -1
@@ -1785,8 +1785,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, hlimit, tclass, opt, rt, fl6); -if (err) +if (err) { +ip6_cork_release (&cork, &v6_cork);return ERR_PTR (err); + }if (dontfrag <0 ) dontfrag =inet6_sk (sk)->dontfrag;
Greg Kroah-Hartman
maintainerPATCH 57/87 crypto: algapi - fix NULL dereference in crypto_remove_spawns()
In reply to Greg Kroah-Hartman4.4-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
@@ -168,6 +168,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 58/87 rbd: set max_segments to USHRT_MAX
In reply to Greg Kroah-Hartman4.4-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
@@ -3767,7 +3767,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 60/87 KVM: x86: Add memory barrier on vmcs field lookup
In reply to Greg Kroah-Hartman4.4-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
@@ -828,8 +828,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 61/87 drm/vmwgfx: Potential off by one in vmw_view_add()
In reply to Greg Kroah-Hartman4.4-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
@@ -2678,6 +2678,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 62/87 kaiser: Set _PAGE_NX only if supported
In reply to Greg Kroah-Hartman4.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Lepton Wu <[email protected]>
This finally resolve crash if loaded under qemu + haxm. Haitao Shan pointed out that the reason of that crash is that NX bit get set for page tables. It seems we missed checking if _PAGE_NX is supported in kaiser_add_user_map
--- arch/x86/mm/kaiser.c | 2 ++ 1 file changed, 2 insertions(+)
arch/x86/mm/kaiser.c +2 -0
@@ -198,6 +198,8 @@ static int kaiser_add_user_map(const voi* requires that not to be #defined to 0): so mask it off here. */ flags &= ~_PAGE_GLOBAL; +if (!(__supported_pte_mask & _PAGE_NX)) + flags &= ~_PAGE_NX;for (; address < end_addr; address +=PAGE_SIZE ) { target_address =get_pa_from_mapping (address);
Greg Kroah-Hartman
maintainerPATCH 63/87 bpf: add bpf_patch_insn_single helper
In reply to Greg Kroah-Hartman4.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Daniel Borkmann <[email protected]>
commit c237ee5eb33bf19fe0591c04ff8db19da7323a83 upstream.
Move the functionality to patch instructions out of the verifier code and into the core as the new bpf_patch_insn_single() helper will be needed later on for blinding as well. No changes in functionality.
--- include/linux/filter.h | 3 ++ kernel/bpf/core.c | 71 +++++++++++++++++++++++++++++++++++++++++++++++++ kernel/bpf/verifier.c | 53 ++++++------------------------------ 3 files changed, 83 insertions(+), 44 deletions(-)
include/linux/filter.h +3 -0
@@ -466,6 +466,9 @@ u64 __bpf_call_base(u64 r1, u64 r2, u64void bpf_int_jit_compile (struct bpf_prog *fp);bool bpf_helper_changes_skb_data (void *func); +struct bpf_prog *bpf_patch_insn_single (struct bpf_prog *prog,u32 off, +const struct bpf_insn *patch,u32 len); +#ifdef CONFIG_BPF_JIT typedef void (*bpf_jit_fill_hole_t )(void *area,unsigned int size);
kernel/bpf/core.c +71 -0
77 lines not on this page · raw message
kernel/bpf/verifier.c +9 -44
83 lines not on this page · raw message
Greg Kroah-Hartman
maintainerPATCH 64/87 bpf: dont (ab)use instructions to store state
In reply to Greg Kroah-Hartman4.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jakub Kicinski <[email protected]>
commit 3df126f35f88dc76eea33769f85a3c3bb8ce6c6b upstream.
Storing state in reserved fields of instructions makes it impossible to run verifier on programs already marked as read-only. Allocate and use an array of per-instruction state instead.
While touching the error path rename and move existing jump target.
--- kernel/bpf/verifier.c | 67 +++++++++++++++++++++++++++++--------------------- 1 file changed, 39 insertions(+), 28 deletions(-)
kernel/bpf/verifier.c +39 -28
@@ -186,6 +186,10 @@ struct verifier_stack_elem {struct verifier_stack_elem *next; }; +struct bpf_insn_aux_data { +enum bpf_reg_type ptr_type;/* pointer type for load/store insns */ +}; +#define MAX_USED_MAPS 64/* max number of maps accessed by one eBPF program */ /* single container for all structs
@@ -200,6 +204,7 @@ struct verifier_env {struct bpf_map *used_maps[MAX_USED_MAPS ];/* array of map's used by eBPF program */ u32 used_map_cnt;/* number of used maps */ bool allow_ptr_leaks; +struct bpf_insn_aux_data *insn_aux_data;/* array of per-insn state */ };/* verbose verifier prints what it's seeing
@@ -1784,7 +1789,7 @@ static int do_check(struct verifier_envreturn err; }else if (class ==BPF_LDX ) { -enum bpf_reg_type src_reg_type; +enum bpf_reg_type *prev_src_type, src_reg_type;/* check for reserved fields is already done */
@@ -1813,16 +1818,18 @@ static int do_check(struct verifier_envcontinue ; } -if (insn->imm ==0 ) { + prev_src_type = &env->insn_aux_data[insn_idx].ptr_type; + +if (*prev_src_type ==NOT_INIT ) {/* saw a valid insn * dst_reg = *(u32 *)(src_reg + off) -* use reserved 'imm' field to mark this insn +* save type to validate intersecting paths */ - insn->imm = src_reg_type; + *prev_src_type = src_reg_type; - }else if (src_reg_type != insn->imm && + }else if (src_reg_type != *prev_src_type && (src_reg_type ==PTR_TO_CTX || - insn->imm ==PTR_TO_CTX )) { + *prev_src_type ==PTR_TO_CTX )) {/* ABuser program is trying to use the same insn * dst_reg = *(u32*) (src_reg + off) * with different pointer types:
@@ -1835,7 +1842,7 @@ static int do_check(struct verifier_env } }else if (class ==BPF_STX ) { -enum bpf_reg_type dst_reg_type; +enum bpf_reg_type *prev_dst_type, dst_reg_type;if (BPF_MODE (insn->code) ==BPF_XADD ) { err =check_xadd (env, insn);
@@ -1863,11 +1870,13 @@ static int do_check(struct verifier_envif (err)return err; -if (insn->imm ==0 ) { - insn->imm = dst_reg_type; - }else if (dst_reg_type != insn->imm && + prev_dst_type = &env->insn_aux_data[insn_idx].ptr_type; + +if (*prev_dst_type ==NOT_INIT ) { + *prev_dst_type = dst_reg_type; + }else if (dst_reg_type != *prev_dst_type && (dst_reg_type ==PTR_TO_CTX || - insn->imm ==PTR_TO_CTX )) { + *prev_dst_type ==PTR_TO_CTX )) {verbose ("same insn cannot be used with different pointers\n" );return -EINVAL ; }
@@ -2104,17 +2113,17 @@ static void convert_pseudo_ld_imm64(strustatic int convert_ctx_accesses (struct verifier_env *env) {struct bpf_insn *insn = env->prog->insnsi; -int insn_cnt = env->prog->len; +const int insn_cnt = env->prog->len;struct bpf_insn insn_buf[16 ];struct bpf_prog *new_prog;enum bpf_access_type type; -int i; +int i, delta =0 ;if (!env->prog->aux->ops->convert_ctx_access)return 0 ;for (i =0 ; i < insn_cnt; i++, insn++) { -u32 insn_delta, cnt; +u32 cnt;if (insn->code == (BPF_LDX |BPF_MEM |BPF_W )) type =BPF_READ ;
@@ -2123,11 +2132,8 @@ static int convert_ctx_accesses(struct velse continue ; -if (insn->imm !=PTR_TO_CTX ) { -/* clear internal mark */ - insn->imm =0 ; +if (env->insn_aux_data[i].ptr_type !=PTR_TO_CTX )continue ; - } cnt = env->prog->aux->ops-> convert_ctx_access(type, insn->dst_reg, insn->src_reg,
@@ -2137,18 +2143,16 @@ static int convert_ctx_accesses(struct vreturn -EINVAL ; } - new_prog =bpf_patch_insn_single (env->prog, i, insn_buf, cnt); + new_prog =bpf_patch_insn_single (env->prog, i + delta, insn_buf, + cnt);if (!new_prog)return -ENOMEM ; - insn_delta = cnt -1 ; + delta += cnt -1 ;/* keep walking new program and skip insns we just inserted */ env->prog = new_prog; - insn = new_prog->insnsi + i + insn_delta; - - insn_cnt += insn_delta; - i += insn_delta; + insn = new_prog->insnsi + i + delta; }return 0 ;
@@ -2192,6 +2196,11 @@ int bpf_check(struct bpf_prog **prog, unif (!env)return -ENOMEM ; + env->insn_aux_data =vzalloc (sizeof (struct bpf_insn_aux_data ) * + (*prog)->len); + ret = -ENOMEM ; +if (!env->insn_aux_data) + goto err_free_env; env->prog = *prog;/* grab the mutex to protect few globals used by verifier */
@@ -2210,12 +2219,12 @@ int bpf_check(struct bpf_prog **prog, un/* log_* values have to be sane */ if (log_size <128 || log_size >UINT_MAX >>8 || log_level ==0 || log_ubuf ==NULL ) - goto free_env; + goto err_unlock; ret = -ENOMEM ; log_buf =vmalloc (log_size);if (!log_buf) - goto free_env; + goto err_unlock; }else { log_level =0 ; }
@@ -2284,14 +2293,16 @@ skip_full_check: free_log_buf:if (log_level)vfree (log_buf); -free_env:if (!env->prog->aux->used_maps)/* if we didn't copy map pointers into bpf_prog_info, release * them now. Otherwise free_bpf_prog_info() will release them. */ release_maps (env); *prog = env->prog; -kfree (env); +err_unlock:mutex_unlock (&bpf_verifier_lock); +vfree (env->insn_aux_data); +err_free_env: +kfree (env);return ret; }
Greg Kroah-Hartman
maintainerPATCH 66/87 bpf: refactor fixup_bpf_calls()
In reply to Greg Kroah-Hartman4.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alexei Starovoitov <[email protected]>
commit 79741b3bdec01a8628368fbcfccc7d189ed606cb upstream.
reduce indent and make it iterate over instructions similar to convert_ctx_accesses(). Also convert hard BUG_ON into soft verifier error.
--- kernel/bpf/verifier.c | 74 ++++++++++++++++++++++---------------------------- 1 file changed, 34 insertions(+), 40 deletions(-)
kernel/bpf/verifier.c +34 -40
@@ -2158,57 +2158,51 @@ static int convert_ctx_accesses(struct vreturn 0 ; } -/* fixup insn->imm field of bpf_call instructions: -* if (insn->imm == BPF_FUNC_map_lookup_elem) -* insn->imm = bpf_map_lookup_elem - __bpf_call_base; -* else if (insn->imm == BPF_FUNC_map_update_elem) -* insn->imm = bpf_map_update_elem - __bpf_call_base; -* else ... +/* fixup insn->imm field of bpf_call instructions * * this function is called after eBPF program passed verification */ -static void fixup_bpf_calls (struct bpf_prog *prog) +static int fixup_bpf_calls (struct verifier_env *env) { +struct bpf_prog *prog = env->prog; +struct bpf_insn *insn = prog->insnsi;const struct bpf_func_proto *fn; +const int insn_cnt = prog->len;int i; -for (i =0 ; i < prog->len; i++) { -struct bpf_insn *insn = &prog->insnsi[i]; - -if (insn->code == (BPF_JMP |BPF_CALL )) { -/* we reach here when program has bpf_call instructions -* and it passed bpf_check(), means that -* ops->get_func_proto must have been supplied, check it +for (i =0 ; i < insn_cnt; i++, insn++) { +if (insn->code != (BPF_JMP |BPF_CALL )) +continue ; + +if (insn->imm == BPF_FUNC_get_route_realm) + prog->dst_needed =1 ; +if (insn->imm == BPF_FUNC_get_prandom_u32) +bpf_user_rnd_init_once (); +if (insn->imm == BPF_FUNC_tail_call) { +/* mark bpf_tail_call as different opcode to avoid +* conditional branch in the interpeter for every normal +* call and to prevent accidental JITing by JIT compiler +* that doesn't support bpf_tail_call yet */ -BUG_ON (!prog->aux->ops->get_func_proto); - -if (insn->imm == BPF_FUNC_get_route_realm) - prog->dst_needed =1 ; -if (insn->imm == BPF_FUNC_get_prandom_u32) -bpf_user_rnd_init_once (); -if (insn->imm == BPF_FUNC_tail_call) { -/* mark bpf_tail_call as different opcode -* to avoid conditional branch in -* interpeter for every normal call -* and to prevent accidental JITing by -* JIT compiler that doesn't support -* bpf_tail_call yet -*/ - insn->imm =0 ; - insn->code |=BPF_X ; -continue ; - } + insn->imm =0 ; + insn->code |=BPF_X ; +continue ; + } - fn = prog->aux->ops->get_func_proto (insn->imm); -/* all functions that have prototype and verifier allowed -* programs to call them, must be real in-kernel functions -*/ -BUG_ON (!fn->func); - insn->imm = fn->func - __bpf_call_base; + fn = prog->aux->ops->get_func_proto (insn->imm); +/* all functions that have prototype and verifier allowed +* programs to call them, must be real in-kernel functions +*/ +if (!fn->func) { +verbose ("kernel subsystem misconfigured func %d\n" , + insn->imm); +return -EFAULT ; } + insn->imm = fn->func - __bpf_call_base; } -} +return 0 ; +}static void free_states (struct verifier_env *env) {
@@ -2309,7 +2303,7 @@ skip_full_check: ret =convert_ctx_accesses (env);if (ret ==0 ) -fixup_bpf_calls (env->prog); + ret =fixup_bpf_calls (env);if (log_level && log_len >= log_size -1 ) {BUG_ON (log_len >= log_size);
Greg Kroah-Hartman
maintainerPATCH 67/87 bpf: adjust insn_aux_data when patching insns
In reply to Greg Kroah-Hartman4.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alexei Starovoitov <[email protected]>
commit 8041902dae5299c1f194ba42d14383f734631009 upstream.
convert_ctx_accesses() replaces single bpf instruction with a set of instructions. Adjust corresponding insn_aux_data while patching. It's needed to make sure subsequent 'for(all insn)' loops have matching insn and insn_aux_data.
--- kernel/bpf/verifier.c | 40 +++++++++++++++++++++++++++++++++++++--- 1 file changed, 37 insertions(+), 3 deletions(-)
kernel/bpf/verifier.c +37 -3
@@ -2107,6 +2107,41 @@ static void convert_pseudo_ld_imm64(stru insn->src_reg =0 ; } +/* single env->prog->insni[off] instruction was replaced with the range +* insni[off, off + cnt). Adjust corresponding insn_aux_data by copying +* [0, off) and [off, end) to new locations, so the patched range stays zero +*/ +static int adjust_insn_aux_data (struct verifier_env *env,u32 prog_len, +u32 off,u32 cnt) +{ +struct bpf_insn_aux_data *new_data, *old_data = env->insn_aux_data; + +if (cnt ==1 ) +return 0 ; + new_data =vzalloc (sizeof (struct bpf_insn_aux_data ) * prog_len); +if (!new_data) +return -ENOMEM ; +memcpy (new_data, old_data,sizeof (struct bpf_insn_aux_data ) * off); +memcpy (new_data + off + cnt -1 , old_data + off, +sizeof (struct bpf_insn_aux_data ) * (prog_len - off - cnt +1 )); + env->insn_aux_data = new_data; +vfree (old_data); +return 0 ; +} + +static struct bpf_prog *bpf_patch_insn_data (struct verifier_env *env,u32 off, +const struct bpf_insn *patch,u32 len) +{ +struct bpf_prog *new_prog; + + new_prog =bpf_patch_insn_single (env->prog, off, patch, len); +if (!new_prog) +return NULL ; +if (adjust_insn_aux_data (env, new_prog->len, off, len)) +return NULL ; +return new_prog; +} +/* convert load instructions that access fields of 'struct __sk_buff' * into sequence of instructions that access fields of 'struct sk_buff' */
@@ -2132,7 +2167,7 @@ static int convert_ctx_accesses(struct velse continue ; -if (env->insn_aux_data[i].ptr_type !=PTR_TO_CTX ) +if (env->insn_aux_data[i + delta].ptr_type !=PTR_TO_CTX )continue ; cnt = env->prog->aux->ops->
@@ -2143,8 +2178,7 @@ static int convert_ctx_accesses(struct vreturn -EINVAL ; } - new_prog =bpf_patch_insn_single (env->prog, i + delta, insn_buf, - cnt); + new_prog =bpf_patch_insn_data (env, i + delta, insn_buf, cnt);if (!new_prog)return -ENOMEM ;
Greg Kroah-Hartman
maintainerPATCH 69/87 bpf, array: fix overflow in max_entries and undefined behavior in index_mask
In reply to Greg Kroah-Hartman4.4-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 | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-)
kernel/bpf/arraymap.c +15 -2
@@ -23,6 +23,7 @@ static struct bpf_map *array_map_alloc(uu32 elem_size, array_size, index_mask, max_entries;bool unpriv = !capable (CAP_SYS_ADMIN );struct bpf_array *array; +u64 mask64;/* check sanity of attributes */ if (attr->max_entries == 0 || attr->key_size != 4 ||
@@ -38,13 +39,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 ); + }/* check round_up into zero and u32 overflow */ if (elem_size == 0 ||
Greg Kroah-Hartman
maintainerPATCH 71/87 target: Avoid early CMD_T_PRE_EXECUTE failures during ABORT_TASK
In reply to Greg Kroah-Hartman4.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nicholas Bellinger <[email protected]>
commit 1c21a48055a67ceb693e9c2587824a8de60a217c upstream.
This patch fixes bug where early se_cmd exceptions that occur before backend execution can result in use-after-free if/when a subsequent ABORT_TASK occurs for the same tag.
Since an early se_cmd exception will have had se_cmd added to se_session->sess_cmd_list via target_get_sess_cmd(), it will not have CMD_T_COMPLETE set by the usual target_complete_cmd() backend completion path.
This causes a subsequent ABORT_TASK + __target_check_io_state() to signal ABORT_TASK should proceed. As core_tmr_abort_task() executes, it will bring the outstanding se_cmd->cmd_kref count down to zero releasing se_cmd, after se_cmd has already been queued with error status into fabric driver response path code.
To address this bug, introduce a CMD_T_PRE_EXECUTE bit that is set at target_get_sess_cmd() time, and cleared immediately before backend driver dispatch in target_execute_cmd() once CMD_T_ACTIVE is set.
Then, check CMD_T_PRE_EXECUTE within __target_check_io_state() to determine when an early exception has occured, and avoid aborting this se_cmd since it will have already been queued into fabric driver response path code.
--- drivers/target/target_core_tmr.c | 9 +++++++++ drivers/target/target_core_transport.c | 2 ++ include/target/target_core_base.h | 1 + 3 files changed, 12 insertions(+)
drivers/target/target_core_tmr.c +9 -0
@@ -133,6 +133,15 @@ static bool __target_check_io_state(struspin_unlock (&se_cmd->t_state_lock);return false; } +if (se_cmd->transport_state &CMD_T_PRE_EXECUTE ) { +if (se_cmd->scsi_status) { +pr_debug ("Attempted to abort io tag: %llu early failure" +" status: 0x%02x\n" , se_cmd->tag, + se_cmd->scsi_status); +spin_unlock (&se_cmd->t_state_lock); +return false; + } + }if (sess->sess_tearing_down || se_cmd->cmd_wait_set) {pr_debug ("Attempted to abort io tag: %llu already shutdown," " skipping\n" , se_cmd->tag);
drivers/target/target_core_transport.c +2 -0
@@ -1933,6 +1933,7 @@ void target_execute_cmd(struct se_cmd *c } cmd->t_state =TRANSPORT_PROCESSING ; + cmd->transport_state &= ~CMD_T_PRE_EXECUTE ; cmd->transport_state |=CMD_T_ACTIVE |CMD_T_BUSY |CMD_T_SENT ;spin_unlock_irq (&cmd->t_state_lock);
@@ -2572,6 +2573,7 @@ int target_get_sess_cmd(struct se_cmd *s ret = -ESHUTDOWN ; goto out; } + se_cmd->transport_state |=CMD_T_PRE_EXECUTE ;list_add_tail (&se_cmd->se_cmd_list, &se_sess->sess_cmd_list); out:spin_unlock_irqrestore (&se_sess->sess_cmd_lock, flags);
include/target/target_core_base.h +1 -0
@@ -496,6 +496,7 @@ struct se_cmd {#define CMD_T_BUSY (1 << 9)#define CMD_T_TAS (1 << 10)#define CMD_T_FABRIC_STOP (1 << 11) +#define CMD_T_PRE_EXECUTE (1 << 12)spinlock_t t_state_lock;struct kref cmd_kref;struct completion t_transport_stop_comp;
Greg Kroah-Hartman
maintainerPATCH 72/87 USB: serial: cp210x: add IDs for LifeScan OneTouch Verio IQ
In reply to Greg Kroah-Hartman4.4-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
@@ -120,6 +120,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 73/87 USB: serial: cp210x: add new device ID ELV ALC 8xxx
In reply to Greg Kroah-Hartman4.4-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
@@ -171,6 +171,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 74/87 usb: misc: usb3503: make sure reset is low for at least 100us
In reply to Greg Kroah-Hartman4.4-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 75/87 USB: fix usbmon BUG trigger
In reply to Greg Kroah-Hartman4.4-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
@@ -1001,7 +1001,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 :
@@ -1228,12 +1230,16 @@ static int mon_bin_vma_fault(struct vm_aunsigned 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/87 uas: ignore UAS for Norelsys NS1068(X) chips
In reply to Greg Kroah-Hartman4.4-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
@@ -155,6 +155,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 80/87 e1000e: Fix e1000_check_for_copper_link_ich8lan return value.
In reply to Greg Kroah-Hartman4.4-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
@@ -1362,6 +1362,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) {
@@ -1377,7 +1380,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
@@ -1585,10 +1588,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 81/87 x86/Documentation: Add PTI description
In reply to Greg Kroah-Hartman4.4-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/kernel-parameters.txt | 21 ++-- Documentation/x86/pti.txt | 186 ++++++++++++++++++++++++++++++++++++ 2 files changed, 200 insertions(+), 7 deletions(-)
Documentation/kernel-parameters.txt +14 -7
@@ -2523,8 +2523,6 @@ bytes respectively. Such letter suffixes nojitter [IA-64] Disables jitter checking for ITC timers. - nopti [X86-64] Disable KAISER isolation of kernel from user. - no-kvmclock [X86,KVM] Disable paravirtualized KVM clock driver no-kvmapf [X86,KVM] Disable paravirtualized asynchronous page
@@ -3056,11 +3054,20 @@ bytes respectively. Such letter suffixes pt. [PARIDE] See Documentation/blockdev/paride.txt. - pti= [X86_64] - Control KAISER 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 85/87 x86/alternatives: Fix optimize_nops() checking
In reply to Greg Kroah-Hartman4.4-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
@@ -339,9 +339,12 @@ done: static void __init_or_module 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 11/87 MIPS: Disallow outsized PTRACE_SETREGSET NT_PRFPREG regset accesses
In reply to Greg Kroah-Hartman4.4-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
@@ -570,6 +570,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 13/87 kvm: vmx: Scrub hardware GPRs at VM-exit
In reply to Greg Kroah-Hartman4.4-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
@@ -3856,6 +3856,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
@@ -8623,6 +8623,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"
@@ -8639,12 +8640,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 4/87 IB/srpt: Disable RDMA access by the initiator
In reply to Greg Kroah-Hartman4.4-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
@@ -957,8 +957,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 5/87 MIPS: Validate PR_SET_FP_MODE prctl(2) requests against the ABI of the task
In reply to Greg Kroah-Hartman4.4-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
@@ -664,6 +664,18 @@ int mips_set_process_fp_mode(struct taskunsigned long switch_count;struct task_struct *t; +/* 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 6/87 MIPS: Factor out NT_PRFPREG regset access helpers
In reply to Greg Kroah-Hartman4.4-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
@@ -439,25 +439,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)
@@ -467,27 +478,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)
@@ -498,6 +536,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 30/87 locks: dont check for race with close when setting OFD lock
In reply to Greg Kroah-Hartman4.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jeff Layton <[email protected]>
commit 0752ba807b04ccd69cb4bc8bbf829a80ee208a3c upstream.
We don't clean out OFD locks on close(), so there's no need to check for a race with them here. They'll get cleaned out at the same time that flock locks are.
--- fs/locks.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-)
fs/locks.c +10 -6
@@ -2220,10 +2220,12 @@ int fcntl_setlk(unsigned int fd, struct error =do_lock_file_wait (filp, cmd, file_lock);/* -* Attempt to detect a close/fcntl race and recover by -* releasing the lock that was just acquired. +* Attempt to detect a close/fcntl race and recover by releasing the +* lock that was just acquired. There is no need to do that when we're +* unlocking though, or for OFD locks. */ -if (!error && file_lock->fl_type !=F_UNLCK ) { +if (!error && file_lock->fl_type !=F_UNLCK && + !(file_lock->fl_flags &FL_OFDLCK )) {/* * We need that spin_lock here - it prevents reordering between * update of i_flctx->flc_posix and check for it done in
@@ -2362,10 +2364,12 @@ int fcntl_setlk64(unsigned int fd, struc error =do_lock_file_wait (filp, cmd, file_lock);/* -* Attempt to detect a close/fcntl race and recover by -* releasing the lock that was just acquired. +* Attempt to detect a close/fcntl race and recover by releasing the +* lock that was just acquired. There is no need to do that when we're +* unlocking though, or for OFD locks. */ -if (!error && file_lock->fl_type !=F_UNLCK ) { +if (!error && file_lock->fl_type !=F_UNLCK && + !(file_lock->fl_flags &FL_OFDLCK )) {/* * We need that spin_lock here - it prevents reordering between * update of i_flctx->flc_posix and check for it done in
Greg Kroah-Hartman
maintainerPATCH 32/87 locking/mutex: Allow next waiter lockless wakeup
In reply to Greg Kroah-Hartman4.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Davidlohr Bueso <[email protected]>
commit 1329ce6fbbe4536592dfcfc8d64d61bfeb598fe6 upstream.
Make use of wake-queues and enable the wakeup to occur after releasing the wait_lock. This is similar to what we do with rtmutex top waiter, slightly shortening the critical region and allow other waiters to acquire the wait_lock sooner. In low contention cases it can also help the recently woken waiter to find the wait_lock available (fastpath) when it continues execution.
--- kernel/locking/mutex.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
kernel/locking/mutex.c +3 -2
@@ -719,6 +719,7 @@ static inline void __mutex_unlock_common_slowpath(struct mutex *lock, int nested) {unsigned long flags; +WAKE_Q (wake_q);/* * As a performance measurement, release the lock before doing other
@@ -746,11 +747,11 @@ __mutex_unlock_common_slowpath(struct mu struct mutex_waiter, list);debug_mutex_wake_waiter (lock, waiter); - -wake_up_process (waiter->task); +wake_q_add (&wake_q, waiter->task); }spin_unlock_mutex (&lock->wait_lock, flags); +wake_up_q (&wake_q); }/*
Greg Kroah-Hartman
maintainerPATCH 16/87 iommu/arm-smmu-v3: Dont free page table ops twice
In reply to Greg Kroah-Hartman4.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jean-Philippe Brucker <[email protected]>
commit 57d72e159b60456c8bb281736c02ddd3164037aa upstream.
Kasan reports a double free when finalise_stage_fn fails: the io_pgtable ops are freed by arm_smmu_domain_finalise and then again by arm_smmu_domain_free. Prevent this by leaving pgtbl_ops empty on failure.
--- drivers/iommu/arm-smmu-v3.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/iommu/arm-smmu-v3.c +5 -3
@@ -1541,13 +1541,15 @@ static int arm_smmu_domain_finalise(strureturn -ENOMEM ; arm_smmu_ops.pgsize_bitmap = pgtbl_cfg.pgsize_bitmap; - smmu_domain->pgtbl_ops = pgtbl_ops; ret =finalise_stage_fn (smmu_domain, &pgtbl_cfg); -if (IS_ERR_VALUE (ret)) +if (IS_ERR_VALUE (ret)) {free_io_pgtable_ops (pgtbl_ops); +return ret; + } -return ret; + smmu_domain->pgtbl_ops = pgtbl_ops; +return 0 ; }static struct arm_smmu_group *arm_smmu_group_get (struct device *dev)
Greg Kroah-Hartman
maintainerPATCH 38/87 lan78xx: use skb_cow_head() to deal with cloned skbs
In reply to Greg Kroah-Hartman4.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Dumazet <[email protected]>
commit d4ca73591916b760478d2b04334d5dcadc028e9c upstream.
We need to ensure there is enough headroom to push extra header, but we also need to check if we are allowed to change headers.
skb_cow_head() is the proper helper to deal with this.
--- drivers/net/usb/lan78xx.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-)
drivers/net/usb/lan78xx.c +2 -7
@@ -2050,14 +2050,9 @@ static struct sk_buff *lan78xx_tx_prep(s {u32 tx_cmd_a, tx_cmd_b; -if (skb_headroom (skb) <TX_OVERHEAD ) { -struct sk_buff *skb2; - - skb2 =skb_copy_expand (skb,TX_OVERHEAD ,0 , flags); +if (skb_cow_head (skb,TX_OVERHEAD )) {dev_kfree_skb_any (skb); - skb = skb2; -if (!skb) -return NULL ; +return NULL ; }if (lan78xx_linearize (skb) <0 )
Greg Kroah-Hartman
maintainerPATCH 40/87 smsc75xx: use skb_cow_head() to deal with cloned skbs
In reply to Greg Kroah-Hartman4.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Dumazet <[email protected]>
commit b7c6d2675899cfff0180412c63fc9cbd5bacdb4d upstream.
We need to ensure there is enough headroom to push extra header, but we also need to check if we are allowed to change headers.
skb_cow_head() is the proper helper to deal with this.
--- drivers/net/usb/smsc75xx.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-)
drivers/net/usb/smsc75xx.c +2 -6
@@ -2193,13 +2193,9 @@ static struct sk_buff *smsc75xx_tx_fixup {u32 tx_cmd_a, tx_cmd_b; -if (skb_headroom (skb) <SMSC75XX_TX_OVERHEAD ) { -struct sk_buff *skb2 = -skb_copy_expand (skb,SMSC75XX_TX_OVERHEAD ,0 , flags); +if (skb_cow_head (skb,SMSC75XX_TX_OVERHEAD )) {dev_kfree_skb_any (skb); - skb = skb2; -if (!skb) -return NULL ; +return NULL ; } tx_cmd_a = (u32)(skb->len &TX_CMD_A_LEN ) |TX_CMD_A_FCS ;
Greg Kroah-Hartman
maintainerPATCH 42/87 x86/mm/pat, /dev/mem: Remove superfluous error message
In reply to Greg Kroah-Hartman4.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiri Kosina <[email protected]>
commit 39380b80d72723282f0ea1d1bbf2294eae45013e upstream.
Currently it's possible for broken (or malicious) userspace to flood a kernel log indefinitely with messages a-la
Program dmidecode tried to access /dev/mem between f0000->100000
because range_is_allowed() is case of CONFIG_STRICT_DEVMEM being turned on dumps this information each and every time devmem_is_allowed() fails.
Reportedly userspace that is able to trigger contignuous flow of these messages exists.
It would be possible to rate limit this message, but that'd have a questionable value; the administrator wouldn't get information about all the failing accessess, so then the information would be both superfluous and incomplete at the same time :)
Returning EPERM (which is what is actually happening) is enough indication for userspace what has happened; no need to log this particular error as some sort of special condition.
--- arch/x86/mm/pat.c | 5 +---- drivers/char/mem.c | 6 +----- 2 files changed, 2 insertions(+), 9 deletions(-)
arch/x86/mm/pat.c +1 -4
@@ -750,11 +750,8 @@ static inline int range_is_allowed(unsigreturn 1 ;while (cursor < to) { -if (!devmem_is_allowed (pfn)) { -pr_info ("x86/PAT: Program %s tried to access /dev/mem between [mem %#010Lx-%#010Lx], PAT prevents it\n" , - current->comm, from, to -1 ); +if (!devmem_is_allowed (pfn))return 0 ; - } cursor +=PAGE_SIZE ; pfn++; }
drivers/char/mem.c +1 -5
@@ -70,12 +70,8 @@ static inline int range_is_allowed(unsigu64 cursor = from;while (cursor < to) { -if (!devmem_is_allowed (pfn)) { -printk (KERN_INFO -"Program %s tried to access /dev/mem between %Lx->%Lx.\n" , - current->comm, from, to); +if (!devmem_is_allowed (pfn))return 0 ; - } cursor +=PAGE_SIZE ; pfn++; }
Greg Kroah-Hartman
maintainerPATCH 17/87 ALSA: pcm: Remove incorrect snd_BUG_ON() usages
In reply to Greg Kroah-Hartman4.4-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
@@ -465,7 +465,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
@@ -1664,7 +1664,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);
@@ -1711,7 +1711,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 44/87 sysrq: Fix warning in sysrq generated crash.
In reply to Greg Kroah-Hartman4.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ani Sinha <[email protected]>
commit 984cf355aeaa8f2eda3861b50d0e8d3e3f77e83b upstream.
Commit 984d74a72076a1 ("sysrq: rcu-ify __handle_sysrq") replaced spin_lock_irqsave() calls with rcu_read_lock() calls in sysrq. Since rcu_read_lock() does not disable preemption, faulthandler_disabled() in __do_page_fault() in x86/fault.c returns false. When the code later calls might_sleep() in the pagefault handler, we get the following warning:
BUG: sleeping function called from invalid context at ../arch/x86/mm/fault.c:1187
in_atomic(): 0, irqs_disabled(): 0, pid: 4706, name: bash Preemption disabled at:[<ffffffff81484339>] printk+0x48/0x4a
To fix this, we release the RCU read lock before we crash.
Tested this patch on linux 3.18 by booting off one of our boards.
--- drivers/tty/sysrq.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/tty/sysrq.c +6 -0
@@ -133,6 +133,12 @@ static void sysrq_handle_crash(int key) {char *killer =NULL ; +/* we need to release the RCU read lock here, +* otherwise we get an annoying +* 'BUG: sleeping function called from invalid context' +* complaint from the kernel before the panic. +*/ +rcu_read_unlock (); panic_on_oops =1 ;/* force panic */ wmb (); *killer =1 ;
Greg Kroah-Hartman
maintainerPATCH 45/87 xhci: Fix ring leak in failure path of xhci_alloc_virt_device()
In reply to Greg Kroah-Hartman4.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ben Hutchings <[email protected]>
This is a stable-only fix for the backport of commit 5d9b70f7d52e ("xhci: Don't add a virt_dev to the devs array before it's fully allocated").
In branches that predate commit c5628a2af83a ("xhci: remove endpoint ring cache") there is an additional failure path in xhci_alloc_virt_device() where ring cache allocation fails, in which case we need to free the ring allocated for endpoint 0.
---
This is build-tested only.
Ben.
drivers/usb/host/xhci-mem.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/usb/host/xhci-mem.c +2 -1
@@ -1071,7 +1071,8 @@ int xhci_alloc_virt_device(struct xhci_hreturn 1 ; fail: - +if (dev->eps[0 ].ring) +xhci_ring_free (xhci, dev->eps[0 ].ring);if (dev->in_ctx)xhci_free_container_ctx (xhci, dev->in_ctx);if (dev->out_ctx)
Greg Kroah-Hartman
maintainerPATCH 48/87 8021q: fix a memory leak for VLAN 0 device
In reply to Greg Kroah-Hartman4.4-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 50/87 net: core: fix module type in sock_diag_bind
In reply to Greg Kroah-Hartman4.4-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
@@ -289,7 +289,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 65/87 bpf: move fixup_bpf_calls() function
In reply to Greg Kroah-Hartman4.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alexei Starovoitov <[email protected]>
commit e245c5c6a5656e4d61aa7bb08e9694fd6e5b2b9d upstream.
no functional change.
move fixup_bpf_calls() to verifier.c
it's being refactored in the next patch
--- kernel/bpf/syscall.c | 54 ------------------------------------------------- kernel/bpf/verifier.c | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+), 54 deletions(-)
kernel/bpf/syscall.c +0 -54
@@ -447,57 +447,6 @@ void bpf_register_prog_type(struct bpf_plist_add (&tl->list_node, &bpf_prog_types); } -/* fixup insn->imm field of bpf_call instructions: -* if (insn->imm == BPF_FUNC_map_lookup_elem) -* insn->imm = bpf_map_lookup_elem - __bpf_call_base; -* else if (insn->imm == BPF_FUNC_map_update_elem) -* insn->imm = bpf_map_update_elem - __bpf_call_base; -* else ... -* -* this function is called after eBPF program passed verification -*/ -static void fixup_bpf_calls (struct bpf_prog *prog) -{ -const struct bpf_func_proto *fn; -int i; - -for (i =0 ; i < prog->len; i++) { -struct bpf_insn *insn = &prog->insnsi[i]; - -if (insn->code == (BPF_JMP |BPF_CALL )) { -/* we reach here when program has bpf_call instructions -* and it passed bpf_check(), means that -* ops->get_func_proto must have been supplied, check it -*/ -BUG_ON (!prog->aux->ops->get_func_proto); - -if (insn->imm == BPF_FUNC_get_route_realm) - prog->dst_needed =1 ; -if (insn->imm == BPF_FUNC_get_prandom_u32) -bpf_user_rnd_init_once (); -if (insn->imm == BPF_FUNC_tail_call) { -/* mark bpf_tail_call as different opcode -* to avoid conditional branch in -* interpeter for every normal call -* and to prevent accidental JITing by -* JIT compiler that doesn't support -* bpf_tail_call yet -*/ - insn->imm =0 ; - insn->code |=BPF_X ; -continue ; - } - - fn = prog->aux->ops->get_func_proto (insn->imm); -/* all functions that have prototype and verifier allowed -* programs to call them, must be real in-kernel functions -*/ -BUG_ON (!fn->func); - insn->imm = fn->func - __bpf_call_base; - } - } -} -/* drop refcnt on maps used by eBPF program and free auxilary data */ static void free_used_maps (struct bpf_prog_aux *aux) {
@@ -680,9 +629,6 @@ static int bpf_prog_load(union bpf_attrif (err <0 ) goto free_used_maps; -/* fixup BPF_CALL->imm field */ -fixup_bpf_calls (prog); -/* eBPF program is ready to be JITed */ err =bpf_prog_select_runtime (prog);if (err <0 )
kernel/bpf/verifier.c +55 -0
67 lines not on this page · raw message
Greg Kroah-Hartman
maintainerPATCH 68/87 bpf: prevent out-of-bounds speculation
In reply to Greg Kroah-Hartman4.4-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 | 24 +++++++++++++++++++----- kernel/bpf/verifier.c | 46 ++++++++++++++++++++++++++++++++++++++++++---- 3 files changed, 63 insertions(+), 9 deletions(-)
include/linux/bpf.h +2 -0
@@ -37,6 +37,7 @@ struct bpf_map {u32 value_size;u32 max_entries;u32 pages; +bool unpriv_array;struct user_struct *user;const struct bpf_map_ops *ops;struct work_struct work;
@@ -141,6 +142,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 +19 -5
@@ -20,8 +20,9 @@/* Called from syscall */ static struct bpf_map *array_map_alloc (union bpf_attr *attr) { +u32 elem_size, array_size, index_mask, max_entries; +bool unpriv = !capable (CAP_SYS_ADMIN );struct bpf_array *array; -u32 elem_size, array_size;/* check sanity of attributes */ if (attr->max_entries == 0 || attr->key_size != 4 ||
@@ -36,12 +37,21 @@ 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) +/* round up array size to nearest power of 2, +* since cpu will speculate within index_mask limits +*/ + max_entries = index_mask +1 ; +/* check round_up into zero and u32 overflow */ if (elem_size ==0 || - attr->max_entries > (U32_MAX -PAGE_SIZE -sizeof (*array)) / elem_size) + max_entries > (U32_MAX -PAGE_SIZE -sizeof (*array)) / elem_size)return ERR_PTR (-ENOMEM ); - array_size =sizeof (*array) + attr->max_entries * elem_size; + array_size =sizeof (*array) + max_entries * elem_size;/* allocate all map elements and zero-initialize them */ array =kzalloc (array_size,GFP_USER | __GFP_NOWARN);
@@ -50,6 +60,8 @@ static struct bpf_map *array_map_alloc(uif (!array)return ERR_PTR (-ENOMEM ); } + array->index_mask = index_mask; + array->map.unpriv_array = unpriv;/* copy mandatory map attributes */ array->map.key_size = attr->key_size;
@@ -70,7 +82,7 @@ static void *array_map_lookup_elem(strucif (index >= array->map.max_entries)return NULL ; -return array->value + array->elem_size * index; +return array->value + array->elem_size * (index & array->index_mask); }/* Called from syscall */
@@ -111,7 +123,9 @@ static int array_map_update_elem(struct/* all elements already exist */ return -EEXIST ; -memcpy (array->value + array->elem_size * index, value, map->value_size); +memcpy (array->value + + array->elem_size * (index & array->index_mask), + value, map->value_size);return 0 ; }
kernel/bpf/verifier.c +42 -4
82 lines not on this page · raw message
Greg Kroah-Hartman
maintainerPATCH 70/87 iscsi-target: Make TASK_REASSIGN use proper se_cmd->cmd_kref
In reply to Greg Kroah-Hartman4.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nicholas Bellinger <[email protected]>
commit ae072726f6109bb1c94841d6fb3a82dde298ea85 upstream.
Since commit 59b6986dbf fixed a potential NULL pointer dereference by allocating a se_tmr_req for ISCSI_TM_FUNC_TASK_REASSIGN, the se_tmr_req is currently leaked by iscsit_free_cmd() because no iscsi_cmd->se_cmd.se_tfo was associated.
To address this, treat ISCSI_TM_FUNC_TASK_REASSIGN like any other TMR and call transport_init_se_cmd() + target_get_sess_cmd() to setup iscsi_cmd->se_cmd.se_tfo with se_cmd->cmd_kref of 2.
This will ensure normal release operation once se_cmd->cmd_kref reaches zero and target_release_cmd_kref() is invoked, se_tmr_req will be released via existing target_free_cmd_mem() and core_tmr_release_req() code.
--- drivers/target/iscsi/iscsi_target.c | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-)
drivers/target/iscsi/iscsi_target.c +7 -13
@@ -1759,7 +1759,6 @@ iscsit_handle_task_mgt_cmd(struct iscsi_struct iscsi_tmr_req *tmr_req;struct iscsi_tm *hdr;int out_of_order_cmdsn =0 , ret; -bool sess_ref = false;u8 function, tcm_function =TMR_UNKNOWN ; hdr = (struct iscsi_tm *) buf;
@@ -1801,18 +1800,17 @@ iscsit_handle_task_mgt_cmd(struct iscsi_ buf); } +transport_init_se_cmd (&cmd->se_cmd, &iscsi_ops, + conn->sess->se_sess,0 ,DMA_NONE , +TCM_SIMPLE_TAG , cmd->sense_buffer +2 ); + +target_get_sess_cmd (&cmd->se_cmd, true); +/* * TASK_REASSIGN for ERL=2 / connection stays inside of * LIO-Target $FABRIC_MOD */ if (function !=ISCSI_TM_FUNC_TASK_REASSIGN ) { -transport_init_se_cmd (&cmd->se_cmd, &iscsi_ops, - conn->sess->se_sess,0 ,DMA_NONE , -TCM_SIMPLE_TAG , cmd->sense_buffer +2 ); - -target_get_sess_cmd (&cmd->se_cmd, true); - sess_ref = true; -switch (function) {case ISCSI_TM_FUNC_ABORT_TASK : tcm_function =TMR_ABORT_TASK ;
@@ -1951,12 +1949,8 @@ attach:* For connection recovery, this is also the default action for * TMR TASK_REASSIGN. */ -if (sess_ref) { -pr_debug ("Handle TMR, using sess_ref=true check\n" ); -target_put_sess_cmd (&cmd->se_cmd); - } -iscsit_add_cmd_to_response_queue (cmd, conn, cmd->i_state); +target_put_sess_cmd (&cmd->se_cmd);return 0 ; }EXPORT_SYMBOL (iscsit_handle_task_mgt_cmd);
Greg Kroah-Hartman
maintainerPATCH 76/87 usbip: remove kernel addresses from usb device and urb debug msgs
In reply to Greg Kroah-Hartman4.4-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
@@ -103,7 +103,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++)
@@ -136,12 +136,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);
@@ -249,9 +245,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);
@@ -260,11 +253,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(
@@ -274,8 +265,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 77/87 staging: android: ashmem: fix a race condition in ASHMEM_SET_SIZE ioctl
In reply to Greg Kroah-Hartman4.4-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
@@ -759,10 +759,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 78/87 Bluetooth: Prevent stack info leak from the EFS element.
In reply to Greg Kroah-Hartman4.4-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
@@ -3342,9 +3342,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 :
@@ -3563,16 +3564,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 82/87 sysfs/cpu: Add vulnerability folder
In reply to Greg Kroah-Hartman4.4-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
@@ -271,3 +271,19 @@ Description: Parameters for the CPU cach - WriteBack: data is written only to the cache line and the modified cache line is written to main memory only when it is replaced + +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
@@ -223,6 +223,9 @@ config GENERIC_CPU_DEVICES config GENERIC_CPU_AUTOPROBE bool +config GENERIC_CPU_VULNERABILITIES + bool + config SOC_BUS bool
drivers/base/cpu.c +48 -0
58 lines not on this page · raw message
include/linux/cpu.h +7 -0
@@ -40,6 +40,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 83/87 x86/cpu: Implement CPU vulnerabilites sysfs functions
In reply to Greg Kroah-Hartman4.4-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
@@ -62,6 +62,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
@@ -9,6 +9,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>
@@ -49,3 +50,31 @@ void __init check_bugs(void)fpu__init_check_bugs (); } + +#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 84/87 sysfs/cpu: Fix typos in vulnerability documentation
In reply to Greg Kroah-Hartman4.4-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
@@ -276,7 +276,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
@@ -286,4 +286,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 86/87 x86/alternatives: Add missing \n at end of ALTERNATIVE inline asm
In reply to Greg Kroah-Hartman4.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Woodhouse <[email protected]>
commit b9e705ef7cfaf22db0daab91ad3cd33b0fa32eb9 upstream.
Where an ALTERNATIVE is used in the middle of an inline asm block, this would otherwise lead to the following instruction being appended directly to the trailing ".popsection", and a failed compile.
--- arch/x86/include/asm/alternative.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/x86/include/asm/alternative.h +2 -2
@@ -138,7 +138,7 @@ static inline int alternatives_text_rese".popsection\n" \".pushsection .altinstr_replacement, \"ax\"\n" \ ALTINSTR_REPLACEMENT(newinstr, feature, 1) \ - ".popsection" + ".popsection\n"#define ALTERNATIVE_2 (oldinstr, newinstr1, feature1, newinstr2, feature2)\ OLDINSTR_2(oldinstr, 1, 2) \
@@ -149,7 +149,7 @@ static inline int alternatives_text_rese".pushsection .altinstr_replacement, \"ax\"\n" \ ALTINSTR_REPLACEMENT(newinstr1, feature1, 1) \ ALTINSTR_REPLACEMENT(newinstr2, feature2, 2) \ -".popsection" +".popsection\n" /* * This must be included *after* the definition of ALTERNATIVE due to
Greg Kroah-Hartman
maintainerPATCH 87/87 selftests/x86: Add test_vsyscall
In reply to Greg Kroah-Hartman4.4-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/test_vsyscall.c | 500 ++++++++++++++++++++++++++++ 1 file changed, 500 insertions(+)
tools/testing/selftests/x86/test_vsyscall.c new file +500 -0
@@ -0,0 +1,500 @@ +/* SPDX-License-Identifier: GPL-2.0 */ + +#define _GNU_SOURCE + +#include <stdio.h> +#include <sys/time.h> +#include <time.h> +#include <stdlib.h> +#include <sys/syscall.h> +#include <unistd.h> +#include <dlfcn.h> +#include <string.h> +#include <inttypes.h> +#include <signal.h> +#include <sys/ucontext.h> +#include <errno.h> +#include <err.h> +#include <sched.h> +#include <stdbool.h> +#include <setjmp.h> + +#ifdef __x86_64__ +# define VSYS (x) (x) +#else +# define VSYS (x) 0 +#endif + +#ifndef SYS_getcpu +# ifdef __x86_64__ +# define SYS_getcpu 309 +# else +# define SYS_getcpu 318 +# endif +#endif + +static void sethandler (int sig,void (*handler)(int ,siginfo_t *,void *), +int flags) +{ +struct sigaction sa; +memset (&sa,0 ,sizeof (sa)); + sa.sa_sigaction = handler; + sa.sa_flags =SA_SIGINFO | flags; +sigemptyset (&sa.sa_mask); +if (sigaction (sig, &sa,0 )) +err (1 ,"sigaction" ); +} + +/* vsyscalls and vDSO */ +bool should_read_vsyscall = false; + +typedef long (*gtod_t )(struct timeval *tv,struct timezone *tz); +gtod_t vgtod = (gtod_t )VSYS (0xffffffffff600000 ); +gtod_t vdso_gtod; + +typedef int (*vgettime_t )(clockid_t ,struct timespec *); +vgettime_t vdso_gettime; + +typedef long (*time_func_t )(time_t *t); +time_func_t vtime = (time_func_t )VSYS (0xffffffffff600400 ); +time_func_t vdso_time; + +typedef long (*getcpu_t )(unsigned *,unsigned *,void *); +getcpu_t vgetcpu = (getcpu_t )VSYS (0xffffffffff600800 ); +getcpu_t vdso_getcpu; + +static void init_vdso (void ) +{ +void *vdso =dlopen ("linux-vdso.so.1" ,RTLD_LAZY |RTLD_LOCAL |RTLD_NOLOAD ); +if (!vdso) + vdso =dlopen ("linux-gate.so.1" ,RTLD_LAZY |RTLD_LOCAL |RTLD_NOLOAD ); +if (!vdso) { +printf ("[WARN]\tfailed to find vDSO\n" ); +return ; + } + + vdso_gtod = (gtod_t )dlsym (vdso,"__vdso_gettimeofday" ); +if (!vdso_gtod) +printf ("[WARN]\tfailed to find gettimeofday in vDSO\n" ); + + vdso_gettime = (vgettime_t )dlsym (vdso,"__vdso_clock_gettime" ); +if (!vdso_gettime) +printf ("[WARN]\tfailed to find clock_gettime in vDSO\n" ); + + vdso_time = (time_func_t )dlsym (vdso,"__vdso_time" ); +if (!vdso_time) +printf ("[WARN]\tfailed to find time in vDSO\n" ); + + vdso_getcpu = (getcpu_t )dlsym (vdso,"__vdso_getcpu" ); +if (!vdso_getcpu) { +/* getcpu() was never wired up in the 32-bit vDSO. */ +printf ("[%s]\tfailed to find getcpu in vDSO\n" , +sizeof (long ) ==8 ?"WARN" :"NOTE" ); + } +} + +static int init_vsys (void ) +{ +#ifdef __x86_64__ +int nerrs =0 ; +FILE *maps; +char line[128 ]; +bool found = false; + + maps =fopen ("/proc/self/maps" ,"r" ); +if (!maps) { +printf ("[WARN]\tCould not open /proc/self/maps -- assuming vsyscall is r-x\n" ); + should_read_vsyscall = true; +return 0 ; + } + +while (fgets (line,sizeof (line), maps)) { +char r, x; +void *start, *end; +char name[128 ]; +if (sscanf (line,"%p-%p %c-%cp %*x %*x:%*x %*u %s" , + &start, &end, &r, &x, name) !=5 ) +continue ; + +if (strcmp (name,"[vsyscall]" )) +continue ; + +printf ("\tvsyscall map: %s" , line); + +if (start != (void *)0xffffffffff600000 || + end != (void *)0xffffffffff601000 ) { +printf ("[FAIL]\taddress range is nonsense\n" ); + nerrs++; + } + +printf ("\tvsyscall permissions are %c-%c\n" , r, x); + should_read_vsyscall = (r =='r' ); +if (x !='x' ) { + vgtod =NULL ; + vtime =NULL ; + vgetcpu =NULL ; + } + + found = true; +break ; + } + +fclose (maps); + +if (!found) { +printf ("\tno vsyscall map in /proc/self/maps\n" ); + should_read_vsyscall = false; + vgtod =NULL ; + vtime =NULL ; + vgetcpu =NULL ; + } + +return nerrs; +#else +return 0 ; +#endif +} + +/* syscalls */ +static inline long sys_gtod (struct timeval *tv,struct timezone *tz) +{ +return syscall (SYS_gettimeofday, tv, tz); +} + +static inline int sys_clock_gettime (clockid_t id,struct timespec *ts) +{ +return syscall (SYS_clock_gettime, id, ts); +} + +static inline long sys_time (time_t *t) +{ +return syscall (SYS_time, t); +} + +static inline long sys_getcpu (unsigned * cpu,unsigned * node, +void * cache) +{ +return syscall (SYS_getcpu, cpu, node, cache); +} + +static jmp_buf jmpbuf; + +static void sigsegv (int sig,siginfo_t *info,void *ctx_void) +{ +siglongjmp (jmpbuf,1 ); +} + +static double tv_diff (const struct timeval *a,const struct timeval *b) +{ +return (double )(a->tv_sec - b->tv_sec) + + (double )((int )a->tv_usec - (int )b->tv_usec) *1e-6 ; +} + +static int check_gtod (const struct timeval *tv_sys1, +const struct timeval *tv_sys2, +const struct timezone *tz_sys, +const char *which, +const struct timeval *tv_other, +const struct timezone *tz_other) +{ +int nerrs =0 ; +double d1, d2; + +if (tz_other && (tz_sys->tz_minuteswest != tz_other->tz_minuteswest || tz_sys->tz_dsttime != tz_other->tz_dsttime)) { +printf ("[FAIL] %s tz mismatch\n" , which); + nerrs++; + } + + d1 =tv_diff (tv_other, tv_sys1); + d2 =tv_diff (tv_sys2, tv_other); +printf ("\t%s time offsets: %lf %lf\n" , which, d1, d2); + +if (d1 <0 || d2 <0 ) { +printf ("[FAIL]\t%s time was inconsistent with the syscall\n" , which); + nerrs++; + }else { +printf ("[OK]\t%s gettimeofday()'s timeval was okay\n" , which); + } + +return nerrs; +} + +static int test_gtod (void ) +{ +struct timeval tv_sys1, tv_sys2, tv_vdso, tv_vsys; +struct timezone tz_sys, tz_vdso, tz_vsys; +long ret_vdso =-1 ; +long ret_vsys =-1 ; +int nerrs =0 ; + +printf ("[RUN]\ttest gettimeofday()\n" ); + +if (sys_gtod (&tv_sys1, &tz_sys) !=0 ) +err (1 ,"syscall gettimeofday" ); +if (vdso_gtod) + ret_vdso =vdso_gtod (&tv_vdso, &tz_vdso); +if (vgtod) + ret_vsys =vgtod (&tv_vsys, &tz_vsys); +if (sys_gtod (&tv_sys2, &tz_sys) !=0 ) +err (1 ,"syscall gettimeofday" ); + +if (vdso_gtod) { +if (ret_vdso ==0 ) { + nerrs +=check_gtod (&tv_sys1, &tv_sys2, &tz_sys,"vDSO" , &tv_vdso, &tz_vdso); + }else { +printf ("[FAIL]\tvDSO gettimeofday() failed: %ld\n" , ret_vdso); + nerrs++; + } + } + +if (vgtod) { +if (ret_vsys ==0 ) { + nerrs +=check_gtod (&tv_sys1, &tv_sys2, &tz_sys,"vsyscall" , &tv_vsys, &tz_vsys); + }else { +printf ("[FAIL]\tvsys gettimeofday() failed: %ld\n" , ret_vsys); + nerrs++; + } + } + +return nerrs; +} + +static int test_time (void ) { +int nerrs =0 ; + +printf ("[RUN]\ttest time()\n" ); +long t_sys1, t_sys2, t_vdso =0 , t_vsys =0 ; +long t2_sys1 =-1 , t2_sys2 =-1 , t2_vdso =-1 , t2_vsys =-1 ; + t_sys1 =sys_time (&t2_sys1); +if (vdso_time) + t_vdso =vdso_time (&t2_vdso); +if (vtime) + t_vsys =vtime (&t2_vsys); + t_sys2 =sys_time (&t2_sys2); +if (t_sys1 <0 || t_sys1 != t2_sys1 || t_sys2 <0 || t_sys2 != t2_sys2) { +printf ("[FAIL]\tsyscall failed (ret1:%ld output1:%ld ret2:%ld output2:%ld)\n" , t_sys1, t2_sys1, t_sys2, t2_sys2); + nerrs++; +return nerrs; + } + +if (vdso_time) { +if (t_vdso <0 || t_vdso != t2_vdso) { +printf ("[FAIL]\tvDSO failed (ret:%ld output:%ld)\n" , t_vdso, t2_vdso); + nerrs++; + }else if (t_vdso < t_sys1 || t_vdso > t_sys2) { +printf ("[FAIL]\tvDSO returned the wrong time (%ld %ld %ld)\n" , t_sys1, t_vdso, t_sys2); + nerrs++; + }else { +printf ("[OK]\tvDSO time() is okay\n" ); + } + } + +if (vtime) { +if (t_vsys <0 || t_vsys != t2_vsys) { +printf ("[FAIL]\tvsyscall failed (ret:%ld output:%ld)\n" , t_vsys, t2_vsys); + nerrs++; + }else if (t_vsys < t_sys1 || t_vsys > t_sys2) { +printf ("[FAIL]\tvsyscall returned the wrong time (%ld %ld %ld)\n" , t_sys1, t_vsys, t_sys2); + nerrs++; + }else { +printf ("[OK]\tvsyscall time() is okay\n" ); + } + } + +return nerrs; +} + +static int test_getcpu (int cpu) +{ +int nerrs =0 ; +long ret_sys, ret_vdso =-1 , ret_vsys =-1 ; + +printf ("[RUN]\tgetcpu() on CPU %d\n" , cpu); + +cpu_set_t cpuset; +CPU_ZERO (&cpuset); +CPU_SET (cpu, &cpuset); +if (sched_setaffinity (0 ,sizeof (cpuset), &cpuset) !=0 ) { +printf ("[SKIP]\tfailed to force CPU %d\n" , cpu); +return nerrs; + } + +unsigned cpu_sys, cpu_vdso, cpu_vsys, node_sys, node_vdso, node_vsys; +unsigned node =0 ; +bool have_node = false; + ret_sys =sys_getcpu (&cpu_sys, &node_sys,0 ); +if (vdso_getcpu) + ret_vdso =vdso_getcpu (&cpu_vdso, &node_vdso,0 ); +if (vgetcpu) + ret_vsys =vgetcpu (&cpu_vsys, &node_vsys,0 ); + +if (ret_sys ==0 ) { +if (cpu_sys != cpu) { +printf ("[FAIL]\tsyscall reported CPU %hu but should be %d\n" , cpu_sys, cpu); + nerrs++; + } + + have_node = true; + node = node_sys; + } + +if (vdso_getcpu) { +if (ret_vdso) { +printf ("[FAIL]\tvDSO getcpu() failed\n" ); + nerrs++; + }else { +if (!have_node) { + have_node = true; + node = node_vdso; + } + +if (cpu_vdso != cpu) { +printf ("[FAIL]\tvDSO reported CPU %hu but should be %d\n" , cpu_vdso, cpu); + nerrs++; + }else { +printf ("[OK]\tvDSO reported correct CPU\n" ); + } + +if (node_vdso != node) { +printf ("[FAIL]\tvDSO reported node %hu but should be %hu\n" , node_vdso, node); + nerrs++; + }else { +printf ("[OK]\tvDSO reported correct node\n" ); + } + } + } + +if (vgetcpu) { +if (ret_vsys) { +printf ("[FAIL]\tvsyscall getcpu() failed\n" ); + nerrs++; + }else { +if (!have_node) { + have_node = true; + node = node_vsys; + } + +if (cpu_vsys != cpu) { +printf ("[FAIL]\tvsyscall reported CPU %hu but should be %d\n" , cpu_vsys, cpu); + nerrs++; + }else { +printf ("[OK]\tvsyscall reported correct CPU\n" ); + } + +if (node_vsys != node) { +printf ("[FAIL]\tvsyscall reported node %hu but should be %hu\n" , node_vsys, node); + nerrs++; + }else { +printf ("[OK]\tvsyscall reported correct node\n" ); + } + } + } + +return nerrs; +} + +static int test_vsys_r (void ) +{ +#ifdef __x86_64__ +printf ("[RUN]\tChecking read access to the vsyscall page\n" ); +bool can_read; +if (sigsetjmp (jmpbuf,1 ) ==0 ) { + *(volatile int *)0xffffffffff600000 ; + can_read = true; + }else { + can_read = false; + } + +if (can_read && !should_read_vsyscall) { +printf ("[FAIL]\tWe have read access, but we shouldn't\n" ); +return 1 ; + }else if (!can_read && should_read_vsyscall) { +printf ("[FAIL]\tWe don't have read access, but we should\n" ); +return 1 ; + }else { +printf ("[OK]\tgot expected result\n" ); + } +#endif + +return 0 ; +} + + +#ifdef __x86_64__ +#define X86_EFLAGS_TF (1UL << 8) +static volatile sig_atomic_t num_vsyscall_traps; + +static unsigned long get_eflags (void ) +{ +unsigned long eflags; + asmvolatile ("pushfq\n\tpopq %0" :"=rm" (eflags)); +return eflags; +} + +static void set_eflags (unsigned long eflags) +{ + asmvolatile ("pushq %0\n\tpopfq" : :"rm" (eflags) :"flags" ); +} + +static void sigtrap (int sig,siginfo_t *info,void *ctx_void) +{ +ucontext_t *ctx = (ucontext_t *)ctx_void; +unsigned long ip = ctx->uc_mcontext.gregs[REG_RIP ]; + +if (((ip ^0xffffffffff600000UL ) & ~0xfffUL ) ==0 ) + num_vsyscall_traps++; +} + +static int test_native_vsyscall (void ) +{ +time_t tmp; +bool is_native; + +if (!vtime) +return 0 ; + +printf ("[RUN]\tchecking for native vsyscall\n" ); +sethandler (SIGTRAP , sigtrap,0 ); +set_eflags (get_eflags () |X86_EFLAGS_TF ); +vtime (&tmp); +set_eflags (get_eflags () & ~X86_EFLAGS_TF ); + +/* +* If vsyscalls are emulated, we expect a single trap in the +* vsyscall page -- the call instruction will trap with RIP +* pointing to the entry point before emulation takes over. +* In native mode, we expect two traps, since whatever code +* the vsyscall page contains will be more than just a ret +* instruction. +*/ + is_native = (num_vsyscall_traps >1 ); + +printf ("\tvsyscalls are %s (%d instructions in vsyscall page)\n" , + (is_native ?"native" :"emulated" ), + (int )num_vsyscall_traps); + +return 0 ; +} +#endif + +int main (int argc,char **argv) +{ +int nerrs =0 ; + +init_vdso (); + nerrs +=init_vsys (); + + nerrs +=test_gtod (); + nerrs +=test_time (); + nerrs +=test_getcpu (0 ); + nerrs +=test_getcpu (1 ); + +sethandler (SIGSEGV , sigsegv,0 ); + nerrs +=test_vsys_r (); + +#ifdef __x86_64__ + nerrs +=test_native_vsyscall (); +#endif + +return nerrs ?1 :0 ; +}
Greg Kroah-Hartman
maintainerPATCH 59/87 x86/microcode/intel: Extend BDW late-loading with a revision check
In reply to Greg Kroah-Hartman4.4-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 | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-)
arch/x86/kernel/cpu/microcode/intel.c +11 -3
@@ -994,9 +994,17 @@ static bool is_blacklisted(unsigned int {struct cpuinfo_x86 *c = &cpu_data (cpu); -if (c->x86 ==6 && c->x86_model ==79 ) { -pr_err_once ("late loading on model 79 is disabled.\n" ); -return true; +/* +* 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 ==79 && + 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 false;
Greg Kroah-Hartman
maintainerQuoted 4 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 4.4.112 release. There are 87 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.
Crap, this is broken, let me fix it before everyone starts emailing me how it doesn't build for them.
Sorry about that, I was fixated on getting 4.14 and 4.9 right over the past few days and ignored 4.4 :(
A -rc2 will be required...
greg k-h
Greg Kroah-Hartman
maintainerQuoted 5 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 4.4.112 release. There are 87 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:11 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.4.112-rc1.gzor in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.gitlinux-4.4.y
and the diffstat can be found below.
Well, that was a brown-bag release, let's try -rc2 now!
kernel.org/pub/linux/kernel/v4.x/stable-review/patch-4.4.112-rc1.gz
Hopefully that works better now, please test.
thanks,
greg k-h
stable-rc/linux-4.4.y boot: 114 boots: 1 failed, 111 passed with 2 offline (v4.4.111-88-gaee64ffb2ece)
stable-rc/linux-4.4.y boot: 114 boots: 1 failed, 111 passed with 2 offline (v4.4.111-88-gaee64ffb2ece)
Full Boot Summary: https://kernelci.org/boot/all/job/stable-rc/branch/linux-4.4.y/kernel/v4.4.111-88-gaee64ffb2ece/
Full Build Summary: https://kernelci.org/build/stable-rc/branch/linux-4.4.y/kernel/v4.4.111-88-gaee64ffb2ece/
Tree: stable-rc
Branch: linux-4.4.y
Git Describe: v4.4.111-88-gaee64ffb2ece
Git Commit: aee64ffb2ececdfe86f0a00fb46f28aaad5f3acd
Git URL: http://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git
Tested: 60 unique boards, 19 SoC families, 16 builds out of 178
Boot Regressions Detected:
arm:
at91_dt_defconfig:
at91rm9200ek_rootfs:nfs:
lab-free-electrons: new failure (last pass: v4.4.111-72-g34e9e548f219)Boot Failure Detected:
arm:
at91_dt_defconfig
at91rm9200ek_rootfs:nfs: 1 failed labOffline Platforms:
arm:
multi_v7_defconfig:
exynos5420-arndale-octa: 1 offline lab
exynos_defconfig:
exynos5420-arndale-octa: 1 offline lab
---
For more info write to <[email protected]>
Quoted 367 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 4.4.112 release. There are 87 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:11 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.4.112-rc1.gzor in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.gitlinux-4.4.y
and the diffstat can be found below.thanks,
greg k-h
-------------
Pseudo-Shortlog of commits:Greg Kroah-Hartman <[email protected]>
Linux 4.4.112-rc1Andy Lutomirski <[email protected]>
selftests/x86: Addtest_vsyscallDavid Woodhouse <[email protected]>
x86/alternatives: Add missing '\n' at end of ALTERNATIVE inline asmBorislav Petkov <[email protected]>
x86/alternatives: Fixoptimize_nops()checkingDavid Woodhouse <[email protected]>
sysfs/cpu: Fix typos in vulnerability documentationThomas Gleixner <[email protected]>
x86/cpu: Implement CPU vulnerabilites sysfs functionsThomas Gleixner <[email protected]>
sysfs/cpu: Add vulnerability folderDave Hansen <[email protected]>
x86/Documentation: Add PTI descriptionBenjamin Poirier <[email protected]>
e1000e: Fix e1000_check_for_copper_link_ich8lan return value.Icenowy Zheng <[email protected]>
uas: ignore UAS for Norelsys NS1068(X) chipsBen Seri <[email protected]>
Bluetooth: Prevent stack info leak from the EFS element.Viktor Slavkovic <[email protected]>
staging: android: ashmem: fix a race condition inASHMEM_SET_SIZEioctlShuah Khan <[email protected]>
usbip: remove kernel addresses from usb device and urb debug msgsPete Zaitcev <[email protected]>
USB: fix usbmon BUG triggerStefan Agner <[email protected]>
usb: misc: usb3503: make sure reset is low for at least 100usChristian Holl <[email protected]>
USB: serial: cp210x: add new device ID ELV ALC 8xxxDiego Elio Petten� <[email protected]>
USB: serial: cp210x: add IDs for LifeScan OneTouch Verio IQNicholas Bellinger <[email protected]>
target: Avoid earlyCMD_T_PRE_EXECUTEfailures duringABORT_TASKNicholas Bellinger <[email protected]>
iscsi-target: Make TASK_REASSIGN use proper se_cmd->cmd_krefDaniel Borkmann <[email protected]>
bpf, array: fix overflow inmax_entriesand undefined behavior inindex_maskAlexei Starovoitov <[email protected]>
bpf: prevent out-of-bounds speculationAlexei Starovoitov <[email protected]>
bpf: adjustinsn_aux_datawhen patching insnsAlexei Starovoitov <[email protected]>
bpf: refactorfixup_bpf_calls()Alexei Starovoitov <[email protected]>
bpf: movefixup_bpf_calls()functionJakub Kicinski <[email protected]>
bpf: don't (ab)use instructions to store stateDaniel Borkmann <[email protected]>
bpf: addbpf_patch_insn_singlehelperLepton Wu <[email protected]>
kaiser: Set_PAGE_NXonly if supportedDan Carpenter <[email protected]>
drm/vmwgfx: Potential off by one invmw_view_add()Andrew Honig <[email protected]>
KVM: x86: Add memory barrier on vmcs field lookupJia Zhang <[email protected]>
x86/microcode/intel: Extend BDW late-loading with a revision checkIlya Dryomov <[email protected]>
rbd: setmax_segmentstoUSHRT_MAXEric Biggers <[email protected]>
crypto: algapi - fix NULL dereference incrypto_remove_spawns()Eric Dumazet <[email protected]>
ipv6: fix possible mem leaks inipv6_make_skb()Jerome Brunet <[email protected]>
net: stmmac: enable EEE in MII, GMII or RGMII onlySergei Shtylyov <[email protected]>
sh_eth: fix SH7757 GEther initializationSergei Shtylyov <[email protected]>
sh_eth: fix TSU resource handlingMohamed Ghannam <[email protected]>
RDS: null pointer dereference inrds_atomic_free_opMohamed Ghannam <[email protected]>
RDS: Heap OOB write inrds_message_alloc_sgs()Andrii Vladyka <[email protected]>
net: core: fix module type insock_diag_bindEli Cooper <[email protected]>
ip6_tunnel: disable dst caching if tunnel is dual-stackCong Wang <[email protected]>
8021q: fix a memory leak for VLAN 0 devicePavel Tatashin <[email protected]>
x86/pti/efi: broken conversion from efi to kernel page tableGreg Kroah-Hartman <[email protected]>
Revert "userfaultfd: selftest: vm: allow to build in vm/ directory"Ben Hutchings <[email protected]>
xhci: Fix ring leak in failure path ofxhci_alloc_virt_device()Ani Sinha <[email protected]>
sysrq: Fix warning in sysrq generated crash.Jiri Slaby <[email protected]>
hwrng: core - sleep interruptible in readJiri Kosina <[email protected]>
x86/mm/pat,/dev/mem: Remove superfluous error messageEric Dumazet <[email protected]>
cx82310_eth: useskb_cow_head()to deal with cloned skbsEric Dumazet <[email protected]>
smsc75xx: useskb_cow_head()to deal with cloned skbsEric Dumazet <[email protected]>
sr9700: useskb_cow_head()to deal with cloned skbsEric Dumazet <[email protected]>
lan78xx: useskb_cow_head()to deal with cloned skbshayeswang <[email protected]>
r8152: adjust ALDPS functionhayeswang <[email protected]>
r8152: use test_and_clear_bithayeswang <[email protected]>
r8152: fix the wake eventUlf Hansson <[email protected]>
usb: musb: ux500: Fix NULL pointer dereference at system PMOliver Neukum <[email protected]>
usbvision fix overflow of interfaces arrayDavidlohr Bueso <[email protected]>
locking/mutex: Allow next waiter lockless wakeupJianyu Zhan <[email protected]>
futex: Replacebarrier()inunqueue_me()withREAD_ONCE()Jeff Layton <[email protected]>
locks: don't check for race with close when setting OFD lockDan Streetman <[email protected]>
zswap: don'tparam_set_charpwhile holding spinlockDan Streetman <[email protected]>
mm/zswap: use workqueue to destroy poolAndrey Ryabinin <[email protected]>
mm/page-writeback: fixdirty_ratelimitcalculationJoonsoo Kim <[email protected]>
mm/compaction: pass only pageblock aligned range topageblock_pfn_to_pageJoonsoo Kim <[email protected]>
mm/compaction: fix invalidfree_pfnandcompact_cached_free_pfnVikas C Sajjan <[email protected]>
x86/acpi: Reduce code duplication inmp_override_legacy_irq()Takashi Iwai <[email protected]>
ALSA: aloop: Fix racy hw constraints adjustmentTakashi Iwai <[email protected]>
ALSA: aloop: Fix inconsistent format due to incomplete ruleTakashi Iwai <[email protected]>
ALSA: aloop: Release cable upon open error pathTakashi Iwai <[email protected]>
ALSA: pcm: Allow aborting mutex lock at OSS read/write loopsTakashi Iwai <[email protected]>
ALSA: pcm: Abort properly at pending signal in OSS read/write loopsTakashi Iwai <[email protected]>
ALSA: pcm: Add missing error checks in OSS emulation plugin builderTakashi Iwai <[email protected]>
ALSA: pcm: Remove incorrectsnd_BUG_ON()usagesJean-Philippe Brucker <[email protected]>
iommu/arm-smmu-v3: Don't free page table ops twiceVikas C Sajjan <[email protected]>
x86/acpi: Handle SCI interrupts above legacy space gracefullyAndy Lutomirski <[email protected]>
x86/vsdo: Fix build on PARAVIRT_CLOCK=y, KVM_GUEST=nJim Mattson <[email protected]>
kvm: vmx: Scrub hardware GPRs at VM-exitAndrey Ryabinin <[email protected]>
net/mac80211/debugfs.c: prevent build failure withCONFIG_UBSAN=yMaciej W. Rozycki <[email protected]>
MIPS: Disallow outsizedPTRACE_SETREGSETNT_PRFPREGregset accessesMaciej W. Rozycki <[email protected]>
MIPS: Also verify sizeof `elf_fpreg_t' withPTRACE_SETREGSETMaciej W. Rozycki <[email protected]>
MIPS: Fix an FCSR access API regression withNT_PRFPREGand MSAMaciej W. Rozycki <[email protected]>
MIPS: Consistently handle buffer counter withPTRACE_SETREGSETMaciej W. Rozycki <[email protected]>
MIPS: Guard against any partial write attempt withPTRACE_SETREGSETMaciej W. Rozycki <[email protected]>
MIPS: Factor outNT_PRFPREGregset access helpersMaciej W. Rozycki <[email protected]>
MIPS: ValidatePR_SET_FP_MODEprctl(2) requests against the ABI of the taskBart Van Assche <[email protected]>
IB/srpt: Disable RDMA access by the initiatorWolfgang Grandegger <[email protected]>
can:gs_usb: fix return value of the "set_bittiming" callbackWanpeng Li <[email protected]>
KVM: Fix stack-out-of-bounds read inwrite_mmioSuren Baghdasaryan <[email protected]>
dm bufio: fix shrinker scans when (nr_to_scan<retain_target)-------------
Diffstat:
Documentation/ABI/testing/sysfs-devices-system-cpu | 16 + Documentation/kernel-parameters.txt | 21 +- Documentation/x86/pti.txt | 186 ++++++++ Makefile | 4 +- arch/arm/kvm/mmio.c | 6 +- arch/mips/kernel/process.c | 12 + arch/mips/kernel/ptrace.c | 147 ++++-- arch/x86/Kconfig | 1 + arch/x86/include/asm/alternative.h | 4 +- arch/x86/include/asm/kaiser.h | 10 + arch/x86/include/asm/pvclock.h | 2 +- arch/x86/kernel/acpi/boot.c | 61 ++- arch/x86/kernel/alternative.c | 7 +- arch/x86/kernel/cpu/bugs.c | 29 ++ arch/x86/kernel/cpu/microcode/intel.c | 14 +- arch/x86/kvm/svm.c | 19 + arch/x86/kvm/vmx.c | 26 +- arch/x86/kvm/x86.c | 8 +- arch/x86/mm/kaiser.c | 2 + arch/x86/mm/pat.c | 5 +- arch/x86/realmode/init.c | 4 +- arch/x86/realmode/rm/trampoline_64.S | 3 +- crypto/algapi.c | 12 + drivers/base/Kconfig | 3 + drivers/base/cpu.c | 48 ++ drivers/block/rbd.c | 2 +- drivers/char/hw_random/core.c | 6 +- drivers/char/mem.c | 6 +- drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c | 2 + drivers/infiniband/ulp/srpt/ib_srpt.c | 3 +- drivers/iommu/arm-smmu-v3.c | 8 +- drivers/md/dm-bufio.c | 7 +- drivers/media/usb/usbvision/usbvision-video.c | 7 + drivers/net/can/usb/gs_usb.c | 2 +- drivers/net/ethernet/intel/e1000e/ich8lan.c | 11 +- drivers/net/ethernet/renesas/sh_eth.c | 29 +- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 6 + drivers/net/usb/cx82310_eth.c | 7 +- drivers/net/usb/lan78xx.c | 9 +- drivers/net/usb/r8152.c | 132 +++--- drivers/net/usb/smsc75xx.c | 8 +- drivers/net/usb/sr9700.c | 9 +- drivers/staging/android/ashmem.c | 2 + drivers/target/iscsi/iscsi_target.c | 20 +- drivers/target/target_core_tmr.c | 9 + drivers/target/target_core_transport.c | 2 + drivers/tty/sysrq.c | 6 + drivers/usb/host/xhci-mem.c | 3 +- drivers/usb/misc/usb3503.c | 2 + drivers/usb/mon/mon_bin.c | 8 +- drivers/usb/musb/ux500.c | 7 +- drivers/usb/serial/cp210x.c | 2 + drivers/usb/storage/unusual_uas.h | 7 + drivers/usb/usbip/usbip_common.c | 17 +- fs/locks.c | 16 +- include/linux/bpf.h | 2 + include/linux/cpu.h | 7 + include/linux/filter.h | 3 + include/linux/phy.h | 11 + include/linux/sh_eth.h | 1 - include/target/target_core_base.h | 1 + include/trace/events/kvm.h | 7 +- kernel/bpf/arraymap.c | 37 +- kernel/bpf/core.c | 71 +++ kernel/bpf/syscall.c | 54 --- kernel/bpf/verifier.c | 217 ++++++--- kernel/futex.c | 8 +- kernel/locking/mutex.c | 5 +- mm/compaction.c | 50 ++- mm/page-writeback.c | 11 +- mm/zswap.c | 24 +- net/8021q/vlan.c | 7 +- net/bluetooth/l2cap_core.c | 20 +- net/core/sock_diag.c | 2 +- net/ipv6/ip6_output.c | 4 +- net/ipv6/ip6_tunnel.c | 9 +- net/mac80211/debugfs.c | 7 +-
Quoted 10 lines
net/rds/rdma.c | 4 + sound/core/oss/pcm_oss.c | 41 +- sound/core/oss/pcm_plugin.c | 14 +- sound/core/pcm_lib.c | 4 +- sound/drivers/aloop.c | 98 ++-- tools/testing/selftests/vm/Makefile | 4 - tools/testing/selftests/x86/test_vsyscall.c | 500 +++++++++++++++++++++ 84 files changed, 1758 insertions(+), 470 deletions(-)
Merged, compiled, and flashed onto my Pixel 2 XL and OnePlus 5.
No initial issues noticed in general usage or dmesg.
Just as a heads up for any other Pixel 2 (XL) users, there will be a conflict in drivers/md/dm-bufio.c due to a Google backport. You can simply take the mainline version of the patch and substitute READ_ONCE for ACCESS_ONCE. I made a small video for thinking about these conflicts if anyone cares for it: https://youtu.be/yWvU8_0O66A
OP5 merges in clean.
Thanks!
Nathan
Greg Kroah-Hartman
maintainerQuoted 383 lines · Nathan Chancellor
Quoted 367 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 4.4.112 release. There are 87 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:11 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.4.112-rc1.gzor in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.gitlinux-4.4.y
and the diffstat can be found below.thanks,
greg k-h
-------------
Pseudo-Shortlog of commits:Greg Kroah-Hartman <[email protected]>
Linux 4.4.112-rc1Andy Lutomirski <[email protected]>
selftests/x86: Addtest_vsyscallDavid Woodhouse <[email protected]>
x86/alternatives: Add missing '\n' at end of ALTERNATIVE inline asmBorislav Petkov <[email protected]>
x86/alternatives: Fixoptimize_nops()checkingDavid Woodhouse <[email protected]>
sysfs/cpu: Fix typos in vulnerability documentationThomas Gleixner <[email protected]>
x86/cpu: Implement CPU vulnerabilites sysfs functionsThomas Gleixner <[email protected]>
sysfs/cpu: Add vulnerability folderDave Hansen <[email protected]>
x86/Documentation: Add PTI descriptionBenjamin Poirier <[email protected]>
e1000e: Fix e1000_check_for_copper_link_ich8lan return value.Icenowy Zheng <[email protected]>
uas: ignore UAS for Norelsys NS1068(X) chipsBen Seri <[email protected]>
Bluetooth: Prevent stack info leak from the EFS element.Viktor Slavkovic <[email protected]>
staging: android: ashmem: fix a race condition inASHMEM_SET_SIZEioctlShuah Khan <[email protected]>
usbip: remove kernel addresses from usb device and urb debug msgsPete Zaitcev <[email protected]>
USB: fix usbmon BUG triggerStefan Agner <[email protected]>
usb: misc: usb3503: make sure reset is low for at least 100usChristian Holl <[email protected]>
USB: serial: cp210x: add new device ID ELV ALC 8xxxDiego Elio Petten� <[email protected]>
USB: serial: cp210x: add IDs for LifeScan OneTouch Verio IQNicholas Bellinger <[email protected]>
target: Avoid earlyCMD_T_PRE_EXECUTEfailures duringABORT_TASKNicholas Bellinger <[email protected]>
iscsi-target: Make TASK_REASSIGN use proper se_cmd->cmd_krefDaniel Borkmann <[email protected]>
bpf, array: fix overflow inmax_entriesand undefined behavior inindex_maskAlexei Starovoitov <[email protected]>
bpf: prevent out-of-bounds speculationAlexei Starovoitov <[email protected]>
bpf: adjustinsn_aux_datawhen patching insnsAlexei Starovoitov <[email protected]>
bpf: refactorfixup_bpf_calls()Alexei Starovoitov <[email protected]>
bpf: movefixup_bpf_calls()functionJakub Kicinski <[email protected]>
bpf: don't (ab)use instructions to store stateDaniel Borkmann <[email protected]>
bpf: addbpf_patch_insn_singlehelperLepton Wu <[email protected]>
kaiser: Set_PAGE_NXonly if supportedDan Carpenter <[email protected]>
drm/vmwgfx: Potential off by one invmw_view_add()Andrew Honig <[email protected]>
KVM: x86: Add memory barrier on vmcs field lookupJia Zhang <[email protected]>
x86/microcode/intel: Extend BDW late-loading with a revision checkIlya Dryomov <[email protected]>
rbd: setmax_segmentstoUSHRT_MAXEric Biggers <[email protected]>
crypto: algapi - fix NULL dereference incrypto_remove_spawns()Eric Dumazet <[email protected]>
ipv6: fix possible mem leaks inipv6_make_skb()Jerome Brunet <[email protected]>
net: stmmac: enable EEE in MII, GMII or RGMII onlySergei Shtylyov <[email protected]>
sh_eth: fix SH7757 GEther initializationSergei Shtylyov <[email protected]>
sh_eth: fix TSU resource handlingMohamed Ghannam <[email protected]>
RDS: null pointer dereference inrds_atomic_free_opMohamed Ghannam <[email protected]>
RDS: Heap OOB write inrds_message_alloc_sgs()Andrii Vladyka <[email protected]>
net: core: fix module type insock_diag_bindEli Cooper <[email protected]>
ip6_tunnel: disable dst caching if tunnel is dual-stackCong Wang <[email protected]>
8021q: fix a memory leak for VLAN 0 devicePavel Tatashin <[email protected]>
x86/pti/efi: broken conversion from efi to kernel page tableGreg Kroah-Hartman <[email protected]>
Revert "userfaultfd: selftest: vm: allow to build in vm/ directory"Ben Hutchings <[email protected]>
xhci: Fix ring leak in failure path ofxhci_alloc_virt_device()Ani Sinha <[email protected]>
sysrq: Fix warning in sysrq generated crash.Jiri Slaby <[email protected]>
hwrng: core - sleep interruptible in readJiri Kosina <[email protected]>
x86/mm/pat,/dev/mem: Remove superfluous error messageEric Dumazet <[email protected]>
cx82310_eth: useskb_cow_head()to deal with cloned skbsEric Dumazet <[email protected]>
smsc75xx: useskb_cow_head()to deal with cloned skbsEric Dumazet <[email protected]>
sr9700: useskb_cow_head()to deal with cloned skbsEric Dumazet <[email protected]>
lan78xx: useskb_cow_head()to deal with cloned skbshayeswang <[email protected]>
r8152: adjust ALDPS functionhayeswang <[email protected]>
r8152: use test_and_clear_bithayeswang <[email protected]>
r8152: fix the wake eventUlf Hansson <[email protected]>
usb: musb: ux500: Fix NULL pointer dereference at system PMOliver Neukum <[email protected]>
usbvision fix overflow of interfaces arrayDavidlohr Bueso <[email protected]>
locking/mutex: Allow next waiter lockless wakeupJianyu Zhan <[email protected]>
futex: Replacebarrier()inunqueue_me()withREAD_ONCE()Jeff Layton <[email protected]>
locks: don't check for race with close when setting OFD lockDan Streetman <[email protected]>
zswap: don'tparam_set_charpwhile holding spinlockDan Streetman <[email protected]>
mm/zswap: use workqueue to destroy poolAndrey Ryabinin <[email protected]>
mm/page-writeback: fixdirty_ratelimitcalculationJoonsoo Kim <[email protected]>
mm/compaction: pass only pageblock aligned range topageblock_pfn_to_pageJoonsoo Kim <[email protected]>
mm/compaction: fix invalidfree_pfnandcompact_cached_free_pfnVikas C Sajjan <[email protected]>
x86/acpi: Reduce code duplication inmp_override_legacy_irq()Takashi Iwai <[email protected]>
ALSA: aloop: Fix racy hw constraints adjustmentTakashi Iwai <[email protected]>
ALSA: aloop: Fix inconsistent format due to incomplete ruleTakashi Iwai <[email protected]>
ALSA: aloop: Release cable upon open error pathTakashi Iwai <[email protected]>
ALSA: pcm: Allow aborting mutex lock at OSS read/write loopsTakashi Iwai <[email protected]>
ALSA: pcm: Abort properly at pending signal in OSS read/write loopsTakashi Iwai <[email protected]>
ALSA: pcm: Add missing error checks in OSS emulation plugin builderTakashi Iwai <[email protected]>
ALSA: pcm: Remove incorrectsnd_BUG_ON()usagesJean-Philippe Brucker <[email protected]>
iommu/arm-smmu-v3: Don't free page table ops twiceVikas C Sajjan <[email protected]>
x86/acpi: Handle SCI interrupts above legacy space gracefullyAndy Lutomirski <[email protected]>
x86/vsdo: Fix build on PARAVIRT_CLOCK=y, KVM_GUEST=nJim Mattson <[email protected]>
kvm: vmx: Scrub hardware GPRs at VM-exitAndrey Ryabinin <[email protected]>
net/mac80211/debugfs.c: prevent build failure withCONFIG_UBSAN=yMaciej W. Rozycki <[email protected]>
MIPS: Disallow outsizedPTRACE_SETREGSETNT_PRFPREGregset accessesMaciej W. Rozycki <[email protected]>
MIPS: Also verify sizeof `elf_fpreg_t' withPTRACE_SETREGSETMaciej W. Rozycki <[email protected]>
MIPS: Fix an FCSR access API regression withNT_PRFPREGand MSAMaciej W. Rozycki <[email protected]>
MIPS: Consistently handle buffer counter withPTRACE_SETREGSETMaciej W. Rozycki <[email protected]>
MIPS: Guard against any partial write attempt withPTRACE_SETREGSETMaciej W. Rozycki <[email protected]>
MIPS: Factor outNT_PRFPREGregset access helpersMaciej W. Rozycki <[email protected]>
MIPS: ValidatePR_SET_FP_MODEprctl(2) requests against the ABI of the taskBart Van Assche <[email protected]>
IB/srpt: Disable RDMA access by the initiatorWolfgang Grandegger <[email protected]>
can:gs_usb: fix return value of the "set_bittiming" callbackWanpeng Li <[email protected]>
KVM: Fix stack-out-of-bounds read inwrite_mmioSuren Baghdasaryan <[email protected]>
dm bufio: fix shrinker scans when (nr_to_scan<retain_target)-------------
Diffstat:
Documentation/ABI/testing/sysfs-devices-system-cpu | 16 + Documentation/kernel-parameters.txt | 21 +- Documentation/x86/pti.txt | 186 ++++++++ Makefile | 4 +- arch/arm/kvm/mmio.c | 6 +- arch/mips/kernel/process.c | 12 + arch/mips/kernel/ptrace.c | 147 ++++-- arch/x86/Kconfig | 1 + arch/x86/include/asm/alternative.h | 4 +- arch/x86/include/asm/kaiser.h | 10 + arch/x86/include/asm/pvclock.h | 2 +- arch/x86/kernel/acpi/boot.c | 61 ++- arch/x86/kernel/alternative.c | 7 +- arch/x86/kernel/cpu/bugs.c | 29 ++ arch/x86/kernel/cpu/microcode/intel.c | 14 +- arch/x86/kvm/svm.c | 19 + arch/x86/kvm/vmx.c | 26 +- arch/x86/kvm/x86.c | 8 +- arch/x86/mm/kaiser.c | 2 + arch/x86/mm/pat.c | 5 +- arch/x86/realmode/init.c | 4 +- arch/x86/realmode/rm/trampoline_64.S | 3 +- crypto/algapi.c | 12 + drivers/base/Kconfig | 3 + drivers/base/cpu.c | 48 ++ drivers/block/rbd.c | 2 +- drivers/char/hw_random/core.c | 6 +- drivers/char/mem.c | 6 +- drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c | 2 + drivers/infiniband/ulp/srpt/ib_srpt.c | 3 +- drivers/iommu/arm-smmu-v3.c | 8 +- drivers/md/dm-bufio.c | 7 +- drivers/media/usb/usbvision/usbvision-video.c | 7 + drivers/net/can/usb/gs_usb.c | 2 +- drivers/net/ethernet/intel/e1000e/ich8lan.c | 11 +- drivers/net/ethernet/renesas/sh_eth.c | 29 +- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 6 + drivers/net/usb/cx82310_eth.c | 7 +- drivers/net/usb/lan78xx.c | 9 +- drivers/net/usb/r8152.c | 132 +++--- drivers/net/usb/smsc75xx.c | 8 +- drivers/net/usb/sr9700.c | 9 +- drivers/staging/android/ashmem.c | 2 + drivers/target/iscsi/iscsi_target.c | 20 +- drivers/target/target_core_tmr.c | 9 + drivers/target/target_core_transport.c | 2 + drivers/tty/sysrq.c | 6 + drivers/usb/host/xhci-mem.c | 3 +- drivers/usb/misc/usb3503.c | 2 + drivers/usb/mon/mon_bin.c | 8 +- drivers/usb/musb/ux500.c | 7 +- drivers/usb/serial/cp210x.c | 2 + drivers/usb/storage/unusual_uas.h | 7 + drivers/usb/usbip/usbip_common.c | 17 +- fs/locks.c | 16 +- include/linux/bpf.h | 2 + include/linux/cpu.h | 7 + include/linux/filter.h | 3 + include/linux/phy.h | 11 + include/linux/sh_eth.h | 1 - include/target/target_core_base.h | 1 + include/trace/events/kvm.h | 7 +- kernel/bpf/arraymap.c | 37 +- kernel/bpf/core.c | 71 +++ kernel/bpf/syscall.c | 54 --- kernel/bpf/verifier.c | 217 ++++++--- kernel/futex.c | 8 +- kernel/locking/mutex.c | 5 +- mm/compaction.c | 50 ++- mm/page-writeback.c | 11 +- mm/zswap.c | 24 +- net/8021q/vlan.c | 7 +- net/bluetooth/l2cap_core.c | 20 +- net/core/sock_diag.c | 2 +- net/ipv6/ip6_output.c | 4 +- net/ipv6/ip6_tunnel.c | 9 +- net/mac80211/debugfs.c | 7 +-Quoted 10 lines
net/rds/rdma.c | 4 + sound/core/oss/pcm_oss.c | 41 +- sound/core/oss/pcm_plugin.c | 14 +- sound/core/pcm_lib.c | 4 +- sound/drivers/aloop.c | 98 ++-- tools/testing/selftests/vm/Makefile | 4 - tools/testing/selftests/x86/test_vsyscall.c | 500 +++++++++++++++++++++ 84 files changed, 1758 insertions(+), 470 deletions(-)Merged, compiled, and flashed onto my Pixel 2 XL and OnePlus 5.
No initial issues noticed in general usage or dmesg.
Quoted 7 lines
Just as a heads up for any other Pixel 2 (XL) users, there will be a conflict in
drivers/md/dm-bufio.cdue to a Google backport. You can simply take the mainline version of the patch and substituteREAD_ONCEforACCESS_ONCE. I made a small video for thinking about these conflicts if anyone cares for it: https://youtu.be/yWvU8_0O66AOP5 merges in clean.
Thanks for testing and letting us know. And thanks for the merge heads-up, I'll use that info when I do the merge of this into android-common later this week :)
greg k-h
Greg Kroah-Hartman wrote...
Quoted 2 lines
Well, that was a brown-bag release, let's try -rc2 now!
kernel.org/pub/linux/kernel/v4.x/stable-review/patch-4.4.112-rc1.gz
Being the bringer of bad news: -rc2.gz obviously.
Also, care to explain what build error messages to expect? I saw your message too late and ran into
arch/x86/kernel/cpu/bugs.c:58:24: error: 'X86_BUG_CPU_MELTDOWN' undeclared (first use in this function)
Christoph
Christoph Biedl wrote...
Quoted 1 line
arch/x86/kernel/cpu/bugs.c:58:24: error: 'X86_BUG_CPU_MELTDOWN' undeclared (first use in this function)
Looking at the diff between -rc1 and -rc2, that's obviously it. Sorry for the noise, and scheduling another build.
Christoph
Quoted 5 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 4.4.112 release. There are 87 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:11 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.4.112-rc1.gzor in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.gitlinux-4.4.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.4.112-rc2
git repo: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git
git branch: linux-4.4.y
git commit: ba079b57b1b26e5be7c19c8c26ca8d0ff93ceffc
git describe: v4.4.111-94-gba079b57b1b2
Test details: https://qa-reports.linaro.org/lkft/linux-stable-rc-4.4-oe/build/v4.4.111-94-gba079b57b1b2
No regressions (compared to build v4.4.111-88-g77b4d3fb7399)
Boards, architectures and test suites:
-------------------------------------
juno-r2 - arm64
* boot - pass: 20,
* kselftest - skip: 29, pass: 32,
* libhugetlbfs - skip: 1, pass: 90,
* ltp-cap_bounds-tests - pass: 2,
* ltp-containers-tests - skip: 36, pass: 28,
* 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: 124, pass: 984,
* ltp-timers-tests - pass: 12,
x15 - arm
* boot - pass: 20,
* kselftest - skip: 29, pass: 31,
* 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: 67, pass: 1036,
* ltp-timers-tests - pass: 12,
x86_64
* boot - pass: 20,
* kselftest - skip: 32, pass: 44,
* 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: 117, pass: 1015,
* ltp-timers-tests - pass: 12,
Summary
------------------------------------------------------------------------
kernel: 4.4.112-rc2
git repo: https://git.linaro.org/lkft/arm64-stable-rc.git
git tag: 4.4.112-rc2-hikey-20180115-107
git commit: 0ca3744c4b978b9e9c8bb96be3edbf854c97ba8f
git describe: 4.4.112-rc2-hikey-20180115-107
Test details: https://qa-reports.linaro.org/lkft/linaro-hikey-stable-rc-4.4-oe/build/4.4.112-rc2-hikey-20180115-107
No regressions (compared to build 4.4.112-rc1-hikey-20180115-106)
Boards, architectures and test suites:
-------------------------------------
hi6220-hikey - arm64
* boot - pass: 20,
* kselftest - skip: 31, pass: 30,
* libhugetlbfs - skip: 1, pass: 90,
* ltp-cap_bounds-tests - pass: 2,
* ltp-containers-tests - skip: 36, pass: 28,
* 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: 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: 124, pass: 980,
* 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.4.112 release. There are 87 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:11 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.4.112-rc1.gzor in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.gitlinux-4.4.y
and the diffstat can be found below.Results from Linaro’s test farm.
No regressions on arm64, arm andx86_64.
Same ebpf question here, did you test it?
thanks,
greg k-h
Quoted 16 lines · Greg Kroah-Hartman
Quoted 15 lines · Dan Rue
Quoted 13 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 4.4.112 release. There are 87 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:11 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.4.112-rc1.gzor in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.gitlinux-4.4.y
and the diffstat can be found below.
Quoted 4 lines
Quoted 2 lines
Results from Linaro’s test farm.
No regressions on arm64, arm andx86_64.Same ebpf question here, did you test it?
We do not have selftests/bpf tests for 4.4
So running 4.14 version of bpf test cases on 4.4 kernel causing failures. The error log is same before and after the previous stable reviews.
- Naresh
Quoted 4 lines
thanks,
greg k-h
Greg Kroah-Hartman
maintainerQuoted 18 lines · Naresh Kamboju
Quoted 16 lines · Greg Kroah-Hartman
Quoted 15 lines · Dan Rue
Quoted 13 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 4.4.112 release. There are 87 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:11 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.4.112-rc1.gzor in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.gitlinux-4.4.y
and the diffstat can be found below.
Quoted 8 lines
Quoted 4 lines
Quoted 2 lines
Results from Linaro’s test farm.
No regressions on arm64, arm andx86_64.Same ebpf question here, did you test it?
We do not have selftests/bpf tests for 4.4
So running 4.14 version of bpf test cases on 4.4 kernel causing failures. The error log is same before and after the previous stable reviews.
How about the 4.9 bpf tests on 4.4?
I want to ensure that the backport did not break anything.
thanks,
greg k-h
Quoted 8 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 4.4.112 release. There are 87 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:11 UTC 2018. Anything received after that time might be too late.
Build results:
total: 145 pass: 145 fail: 0 Qemu test results: total: 118 pass: 118 fail: 0
Details are available at http://kerneltests.org/builders.
Guenter
Quoted 9 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 4.4.112 release. There are 87 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:11 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.4.112-rc1.gzor in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.gitlinux-4.4.y
and the diffstat can be found below.thanks,
greg k-h
Compiled and booted on my test system. No dmesg regressions.
thanks,
-- Shuah
Re: [PATCH 4.4 20/87] ALSA: pcm: Allow aborting mutex lock at OSS read/write loops
In reply to Greg Kroah-HartmanQuoted 17 lines · Greg Kroah-Hartman
4.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
commit
900498a34a3ac9c611e9b425094c8106bdd7dc1cupstream.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()withmutex_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.
[...]
Quoted 23 lines
(quoted diff) +0
-0@@ -1414,18 +1417,18 @@ static ssize_t snd_pcm_oss_write1(struct xfer += tmp;if ((
substream->f_flags&O_NONBLOCK) != 0 && tmp !=runtime->oss.period_bytes)sound/core/oss/pcm_oss.c +1
-1-break ; + tmp = -EAGAIN ;}
+ err:sound/core/oss/pcm_oss.c +3
-0+mutex_unlock (&runtime->oss.params_lock); +if (tmp <0 ) +break ;if (
signal_pending(current)) {
tmp =-ERESTARTSYS;(quoted diff) +1
-1- goto err; + break;}
(quoted diff) +1
-0+ tmp = 0;}
sound/core/oss/pcm_oss.c +0
-5-mutex_unlock (&runtime->oss.params_lock); -return xfer; - - err: -mutex_unlock (&runtime->oss.params_lock);
Quoted 2 lines
return xfer > 0 ? (snd_pcm_sframes_t)xfer : tmp; }
[...]
Some of the "goto err" statements in the loop are conditional on tmp <= 0, but if tmp == 0 this will no longer terminate the loop. Is that intentional or a bug?
The same for snd_pcm_oss_read1().
Ben.
Signature · 2 lines
Ben Hutchings Software Developer, Codethink Ltd.
Re: [PATCH 4.4 20/87] ALSA: pcm: Allow aborting mutex lock at OSS read/write loops
Quoted 47 lines · Ben Hutchings
Quoted 17 lines · Greg Kroah-Hartman
4.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
commit
900498a34a3ac9c611e9b425094c8106bdd7dc1cupstream.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()withmutex_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.[...]
Quoted 25 lines
(quoted diff) +0
-0@@ -1414,18 +1417,18 @@ static ssize_t snd_pcm_oss_write1(struct xfer += tmp;if ((
substream->f_flags&O_NONBLOCK) != 0 && tmp !=runtime->oss.period_bytes)sound/core/oss/pcm_oss.c +1
-1-break ; + tmp = -EAGAIN ;}
+ err:sound/core/oss/pcm_oss.c +3
-0+mutex_unlock (&runtime->oss.params_lock); +if (tmp <0 ) +break ;if (
signal_pending(current)) {
tmp =-ERESTARTSYS;(quoted diff) +1
-1- goto err; + break;}
(quoted diff) +1
-0+ tmp = 0;}
sound/core/oss/pcm_oss.c +0
-5-mutex_unlock (&runtime->oss.params_lock); -return xfer; - - err: -mutex_unlock (&runtime->oss.params_lock);return xfer > 0 ? (snd_pcm_sframes_t)xfer : tmp; }
[...]
Quoted 3 lines
Some of the "goto err" statements in the loop are conditional on tmp <= 0, but if tmp == 0 this will no longer terminate the loop. Is that intentional or a bug?
The patch rather fixes the endless loop: the signal_pending() check is added after goto err, so that it aborts the loop properly.
thanks,
Takashi
Re: [PATCH 4.4 20/87] ALSA: pcm: Allow aborting mutex lock at OSS read/write loops
Quoted 51 lines · Takashi Iwai
Quoted 49 lines · Ben Hutchings
Quoted 17 lines · Greg Kroah-Hartman
4.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
commit
900498a34a3ac9c611e9b425094c8106bdd7dc1cupstream.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()withmutex_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.[...]
Quoted 25 lines
(quoted diff) +0
-0@@ -1414,18 +1417,18 @@ static ssize_t snd_pcm_oss_write1(struct xfer += tmp;if ((
substream->f_flags&O_NONBLOCK) != 0 && tmp !=runtime->oss.period_bytes)sound/core/oss/pcm_oss.c +1
-1-break ; + tmp = -EAGAIN ;}
+ err:sound/core/oss/pcm_oss.c +3
-0+mutex_unlock (&runtime->oss.params_lock); +if (tmp <0 ) +break ;if (
signal_pending(current)) {
tmp =-ERESTARTSYS;(quoted diff) +1
-1- goto err; + break;}
(quoted diff) +1
-0+ tmp = 0;}
sound/core/oss/pcm_oss.c +0
-5-mutex_unlock (&runtime->oss.params_lock); -return xfer; - - err: -mutex_unlock (&runtime->oss.params_lock);return xfer > 0 ? (snd_pcm_sframes_t)xfer : tmp; }
[...]
Quoted 6 lines
Quoted 3 lines
Some of the "goto err" statements in the loop are conditional on tmp <= 0, but if tmp == 0 this will no longer terminate the loop. Is that intentional or a bug?
The patch rather fixes the endless loop: the
signal_pending()check is added after goto err, so that it aborts the loop properly.
Let me rephrase then: if snd_pcm_oss_write2() returns 0, does that imply that signal_pending() is true? If there is any other reason that it could return 0, then this appears to introduce a bug.
Ben.
Signature · 2 lines
Ben Hutchings Software Developer, Codethink Ltd.
Re: [PATCH 4.4 20/87] ALSA: pcm: Allow aborting mutex lock at OSS read/write loops
Quoted 57 lines · Ben Hutchings
Quoted 55 lines · Takashi Iwai
Quoted 52 lines · Ben Hutchings
Quoted 17 lines · Greg Kroah-Hartman
4.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
commit
900498a34a3ac9c611e9b425094c8106bdd7dc1cupstream.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()withmutex_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.[...]
Quoted 23 lines
(quoted diff) +0
-0@@ -1414,18 +1417,18 @@ static ssize_t snd_pcm_oss_write1(struct xfer += tmp;if ((
substream->f_flags&O_NONBLOCK) != 0 && tmp !=runtime->oss.period_bytes)sound/core/oss/pcm_oss.c +1
-1-break ; + tmp = -EAGAIN ;}
+ err:sound/core/oss/pcm_oss.c +3
-0+mutex_unlock (&runtime->oss.params_lock); +if (tmp <0 ) +break ;if (
signal_pending(current)) {
tmp =-ERESTARTSYS;(quoted diff) +1
-1- goto err; + break;}
(quoted diff) +1
-0+ tmp = 0;}
sound/core/oss/pcm_oss.c +0
-5-mutex_unlock (&runtime->oss.params_lock); -return xfer; - - err: -mutex_unlock (&runtime->oss.params_lock);Quoted 2 lines
return xfer > 0 ? (snd_pcm_sframes_t)xfer : tmp; }
[...]
Some of the "goto err" statements in the loop are conditional on tmp <= 0, but if tmp == 0 this will no longer terminate the loop. Is that intentional or a bug?
Quoted 6 lines
Quoted 2 lines
The patch rather fixes the endless loop: the
signal_pending()check is added after goto err, so that it aborts the loop properly.Let me rephrase then: if
snd_pcm_oss_write2()returns 0, does that imply thatsignal_pending()is true? If there is any other reason that it could return 0, then this appears to introduce a bug.
In some condition (depending on the plugin / conversion and partial write) it may return zero, but practically seen it doesn't happen in the whole this loop.
Takashi