summaryrefslogtreecommitdiff
path: root/kernel
AgeCommit message (Collapse)Author
2019-02-07Merge 4.4.173 into android-4.4Greg Kroah-Hartman
Changes in 4.4.173 net: Fix usage of pskb_trim_rcsum openvswitch: Avoid OOB read when parsing flow nlattrs net: ipv4: Fix memory leak in network namespace dismantle net_sched: refetch skb protocol for each filter net: bridge: Fix ethernet header pointer before check skb forwardable USB: serial: simple: add Motorola Tetra TPG2200 device id USB: serial: pl2303: add new PID to support PL2303TB ASoC: atom: fix a missing check of snd_pcm_lib_malloc_pages ARC: perf: map generic branches to correct hardware condition s390/early: improve machine detection s390/smp: fix CPU hotplug deadlock with CPU rescan char/mwave: fix potential Spectre v1 vulnerability staging: rtl8188eu: Add device code for D-Link DWA-121 rev B1 tty: Handle problem if line discipline does not have receive_buf tty/n_hdlc: fix __might_sleep warning CIFS: Fix possible hang during async MTU reads and writes Input: xpad - add support for SteelSeries Stratus Duo KVM: x86: Fix single-step debugging x86/kaslr: Fix incorrect i8254 outb() parameters can: dev: __can_get_echo_skb(): fix bogous check for non-existing skb by removing it can: bcm: check timer values before ktime conversion vt: invoke notifier on screen size change perf unwind: Unwind with libdw doesn't take symfs into account perf unwind: Take pgoff into account when reporting elf to libdwfl irqchip/gic-v3-its: Align PCI Multi-MSI allocation on their size arm64: mm: remove page_mapping check in __sync_icache_dcache f2fs: read page index before freeing Revert "loop: Fix double mutex_unlock(&loop_ctl_mutex) in loop_control_ioctl()" Revert "loop: Get rid of loop_index_mutex" Revert "loop: Fold __loop_release into loop_release" s390/smp: Fix calling smp_call_ipl_cpu() from ipl CPU fs: add the fsnotify call to vfs_iter_write ipv6: Consider sk_bound_dev_if when binding a socket to an address l2tp: copy 4 more bytes to linear part if necessary net/mlx4_core: Add masking for a few queries on HCA caps netrom: switch to sock timer API net/rose: fix NULL ax25_cb kernel panic ucc_geth: Reset BQL queue when stopping device l2tp: remove l2specific_len dependency in l2tp_core l2tp: fix reading optional fields of L2TPv3 CIFS: Do not count -ENODATA as failure for query directory fs/dcache: Fix incorrect nr_dentry_unused accounting in shrink_dcache_sb() ARM: cns3xxx: Fix writing to wrong PCI config registers after alignment arm64: hyp-stub: Forbid kprobing of the hyp-stub gfs2: Revert "Fix loop in gfs2_rbm_find" platform/x86: asus-nb-wmi: Map 0x35 to KEY_SCREENLOCK platform/x86: asus-nb-wmi: Drop mapping of 0x33 and 0x34 scan codes mmc: sdhci-iproc: handle mmc_of_parse() errors during probe kernel/exit.c: release ptraced tasks before zap_pid_ns_processes mm, oom: fix use-after-free in oom_kill_process cifs: Always resolve hostname before reconnecting drivers: core: Remove glue dirs from sysfs earlier mm: migrate: don't rely on __PageMovable() of newpage after unlocking it fs: don't scan the inode cache before SB_BORN is set Linux 4.4.173 Change-Id: Ifc01c8b56016e9145bb67258f91dfc6b6983354c Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2019-02-06kernel/exit.c: release ptraced tasks before zap_pid_ns_processesAndrei Vagin
commit 8fb335e078378c8426fabeed1ebee1fbf915690c upstream. Currently, exit_ptrace() adds all ptraced tasks in a dead list, then zap_pid_ns_processes() waits on all tasks in a current pidns, and only then are tasks from the dead list released. zap_pid_ns_processes() can get stuck on waiting tasks from the dead list. In this case, we will have one unkillable process with one or more dead children. Thanks to Oleg for the advice to release tasks in find_child_reaper(). Link: http://lkml.kernel.org/r/20190110175200.12442-1-avagin@gmail.com Fixes: 7c8bd2322c7f ("exit: ptrace: shift "reap dead" code from exit_ptrace() to forget_original_parent()") Signed-off-by: Andrei Vagin <avagin@gmail.com> Signed-off-by: Oleg Nesterov <oleg@redhat.com> Cc: "Eric W. Biederman" <ebiederm@xmission.com> Cc: <stable@vger.kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-01-13Merge 4.4.170 into android-4.4Greg Kroah-Hartman
Changes in 4.4.170 USB: hso: Fix OOB memory access in hso_probe/hso_get_config_data xhci: Don't prevent USB2 bus suspend in state check intended for USB3 only USB: serial: option: add GosunCn ZTE WeLink ME3630 USB: serial: option: add HP lt4132 USB: serial: option: add Simcom SIM7500/SIM7600 (MBIM mode) USB: serial: option: add Fibocom NL668 series USB: serial: option: add Telit LN940 series mmc: core: Reset HPI enabled state during re-init and in case of errors mmc: omap_hsmmc: fix DMA API warning gpio: max7301: fix driver for use with CONFIG_VMAP_STACK Drivers: hv: vmbus: Return -EINVAL for the sys files for unopened channels x86/mtrr: Don't copy uninitialized gentry fields back to userspace drm/ioctl: Fix Spectre v1 vulnerabilities ip6mr: Fix potential Spectre v1 vulnerability ipv4: Fix potential Spectre v1 vulnerability ax25: fix a use-after-free in ax25_fillin_cb() ibmveth: fix DMA unmap error in ibmveth_xmit_start error path ieee802154: lowpan_header_create check must check daddr ipv6: explicitly initialize udp6_addr in udp_sock_create6() isdn: fix kernel-infoleak in capi_unlocked_ioctl netrom: fix locking in nr_find_socket() packet: validate address length packet: validate address length if non-zero sctp: initialize sin6_flowinfo for ipv6 addrs in sctp_inet6addr_event vhost: make sure used idx is seen before log in vhost_add_used_n() VSOCK: Send reset control packet when socket is partially bound xen/netfront: tolerate frags with no data gro_cell: add napi_disable in gro_cells_destroy sock: Make sock->sk_stamp thread-safe ALSA: rme9652: Fix potential Spectre v1 vulnerability ALSA: emu10k1: Fix potential Spectre v1 vulnerabilities ALSA: pcm: Fix potential Spectre v1 vulnerability ALSA: emux: Fix potential Spectre v1 vulnerabilities ALSA: hda: add mute LED support for HP EliteBook 840 G4 ALSA: hda/tegra: clear pending irq handlers USB: serial: pl2303: add ids for Hewlett-Packard HP POS pole displays USB: serial: option: add Fibocom NL678 series usb: r8a66597: Fix a possible concurrency use-after-free bug in r8a66597_endpoint_disable() Input: elan_i2c - add ACPI ID for touchpad in ASUS Aspire F5-573G KVM: x86: Use jmp to invoke kvm_spurious_fault() from .fixup perf pmu: Suppress potential format-truncation warning ext4: fix possible use after free in ext4_quota_enable ext4: missing unlock/put_page() in ext4_try_to_write_inline_data() ext4: fix EXT4_IOC_GROUP_ADD ioctl ext4: force inode writes when nfsd calls commit_metadata() spi: bcm2835: Fix race on DMA termination spi: bcm2835: Fix book-keeping of DMA termination spi: bcm2835: Avoid finishing transfer prematurely in IRQ mode cdc-acm: fix abnormal DATA RX issue for Mediatek Preloader. media: vivid: free bitmap_cap when updating std/timings/etc. MIPS: Ensure pmd_present() returns false after pmd_mknotpresent() MIPS: Align kernel load address to 64KB CIFS: Fix error mapping for SMB2_LOCK command which caused OFD lock problem x86/kvm/vmx: do not use vm-exit instruction length for fast MMIO when running nested spi: bcm2835: Unbreak the build of esoteric configs powerpc: Fix COFF zImage booting on old powermacs ARM: imx: update the cpu power up timing setting on i.mx6sx Input: restore EV_ABS ABS_RESERVED checkstack.pl: fix for aarch64 xfrm: Fix bucket count reported to userspace scsi: bnx2fc: Fix NULL dereference in error handling Input: omap-keypad - fix idle configuration to not block SoC idle states scsi: zfcp: fix posting too many status read buffers leading to adapter shutdown fork: record start_time late hwpoison, memory_hotplug: allow hwpoisoned pages to be offlined mm, devm_memremap_pages: mark devm_memremap_pages() EXPORT_SYMBOL_GPL mm, devm_memremap_pages: kill mapping "System RAM" support sunrpc: fix cache_head leak due to queued request sunrpc: use SVC_NET() in svcauth_gss_* functions crypto: x86/chacha20 - avoid sleeping with preemption disabled ALSA: cs46xx: Potential NULL dereference in probe ALSA: usb-audio: Avoid access before bLength check in build_audio_procunit() ALSA: usb-audio: Fix an out-of-bound read in create_composite_quirks dlm: fixed memory leaks after failed ls_remove_names allocation dlm: possible memory leak on error path in create_lkb() dlm: lost put_lkb on error path in receive_convert() and receive_unlock() dlm: memory leaks on error path in dlm_user_request() gfs2: Fix loop in gfs2_rbm_find b43: Fix error in cordic routine 9p/net: put a lower bound on msize iommu/vt-d: Handle domain agaw being less than iommu agaw ceph: don't update importing cap's mseq when handing cap export genwqe: Fix size check intel_th: msu: Fix an off-by-one in attribute store power: supply: olpc_battery: correct the temperature units Linux 4.4.170 Change-Id: I1b2927583f8853bfeb3ad11d045c2cf5c5c926f3 Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2019-01-13mm, devm_memremap_pages: kill mapping "System RAM" supportDan Williams
commit 06489cfbd915ff36c8e36df27f1c2dc60f97ca56 upstream. Given the fact that devm_memremap_pages() requires a percpu_ref that is torn down by devm_memremap_pages_release() the current support for mapping RAM is broken. Support for remapping "System RAM" has been broken since the beginning and there is no existing user of this this code path, so just kill the support and make it an explicit error. This cleanup also simplifies a follow-on patch to fix the error path when setting a devm release action for devm_memremap_pages_release() fails. Link: http://lkml.kernel.org/r/154275557997.76910.14689813630968180480.stgit@dwillia2-desk3.amr.corp.intel.com Signed-off-by: Dan Williams <dan.j.williams@intel.com> Reviewed-by: "Jérôme Glisse" <jglisse@redhat.com> Reviewed-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Logan Gunthorpe <logang@deltatee.com> Cc: Balbir Singh <bsingharora@gmail.com> Cc: Michal Hocko <mhocko@suse.com> Cc: <stable@vger.kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-01-13mm, devm_memremap_pages: mark devm_memremap_pages() EXPORT_SYMBOL_GPLDan Williams
commit 808153e1187fa77ac7d7dad261ff476888dcf398 upstream. devm_memremap_pages() is a facility that can create struct page entries for any arbitrary range and give drivers the ability to subvert core aspects of page management. Specifically the facility is tightly integrated with the kernel's memory hotplug functionality. It injects an altmap argument deep into the architecture specific vmemmap implementation to allow allocating from specific reserved pages, and it has Linux specific assumptions about page structure reference counting relative to get_user_pages() and get_user_pages_fast(). It was an oversight and a mistake that this was not marked EXPORT_SYMBOL_GPL from the outset. Again, devm_memremap_pagex() exposes and relies upon core kernel internal assumptions and will continue to evolve along with 'struct page', memory hotplug, and support for new memory types / topologies. Only an in-kernel GPL-only driver is expected to keep up with this ongoing evolution. This interface, and functionality derived from this interface, is not suitable for kernel-external drivers. Link: http://lkml.kernel.org/r/154275557457.76910.16923571232582744134.stgit@dwillia2-desk3.amr.corp.intel.com Signed-off-by: Dan Williams <dan.j.williams@intel.com> Reviewed-by: Christoph Hellwig <hch@lst.de> Acked-by: Michal Hocko <mhocko@suse.com> Cc: "Jérôme Glisse" <jglisse@redhat.com> Cc: Balbir Singh <bsingharora@gmail.com> Cc: Logan Gunthorpe <logang@deltatee.com> Cc: <stable@vger.kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-01-13fork: record start_time lateDavid Herrmann
commit 7b55851367136b1efd84d98fea81ba57a98304cf upstream. This changes the fork(2) syscall to record the process start_time after initializing the basic task structure but still before making the new process visible to user-space. Technically, we could record the start_time anytime during fork(2). But this might lead to scenarios where a start_time is recorded long before a process becomes visible to user-space. For instance, with userfaultfd(2) and TLS, user-space can delay the execution of fork(2) for an indefinite amount of time (and will, if this causes network access, or similar). By recording the start_time late, it much closer reflects the point in time where the process becomes live and can be observed by other processes. Lastly, this makes it much harder for user-space to predict and control the start_time they get assigned. Previously, user-space could fork a process and stall it in copy_thread_tls() before its pid is allocated, but after its start_time is recorded. This can be misused to later-on cycle through PIDs and resume the stalled fork(2) yielding a process that has the same pid and start_time as a process that existed before. This can be used to circumvent security systems that identify processes by their pid+start_time combination. Even though user-space was always aware that start_time recording is flaky (but several projects are known to still rely on start_time-based identification), changing the start_time to be recorded late will help mitigate existing attacks and make it much harder for user-space to control the start_time a process gets assigned. Reported-by: Jann Horn <jannh@google.com> Signed-off-by: Tom Gundersen <teg@jklm.no> Signed-off-by: David Herrmann <dh.herrmann@gmail.com> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-12-21Merge 4.4.169 into android-4.4Greg Kroah-Hartman
Changes in 4.4.169 lib/interval_tree_test.c: make test options module parameters lib/interval_tree_test.c: allow full tree search lib/rbtree_test.c: make input module parameters lib/rbtree-test: lower default params lib/interval_tree_test.c: allow users to limit scope of endpoint timer/debug: Change /proc/timer_list from 0444 to 0400 powerpc/boot: Fix random libfdt related build errors pinctrl: sunxi: a83t: Fix IRQ offset typo for PH11 aio: fix spectre gadget in lookup_ioctx MMC: OMAP: fix broken MMC on OMAP15XX/OMAP5910/OMAP310 tracing: Fix memory leak in set_trigger_filter() tracing: Fix memory leak of instance function hash filters powerpc/msi: Fix NULL pointer access in teardown code Revert "drm/rockchip: Allow driver to be shutdown on reboot/kexec" f2fs: fix a panic caused by NULL flush_cmd_control mac80211: don't WARN on bad WMM parameters from buggy APs mac80211: Fix condition validating WMM IE mac80211_hwsim: fix module init error paths for netlink scsi: libiscsi: Fix NULL pointer dereference in iscsi_eh_session_reset scsi: vmw_pscsi: Rearrange code to avoid multiple calls to free_irq during unload x86/earlyprintk/efi: Fix infinite loop on some screen widths drm/msm: Grab a vblank reference when waiting for commit_done ARC: io.h: Implement reads{x}()/writes{x}() bonding: fix 802.3ad state sent to partner when unbinding slave SUNRPC: Fix a potential race in xprt_connect() sbus: char: add of_node_put() drivers/sbus/char: add of_node_put() drivers/tty: add missing of_node_put() ide: pmac: add of_node_put() clk: mmp: Off by one in mmp_clk_add() Input: omap-keypad - fix keyboard debounce configuration libata: whitelist all SAMSUNG MZ7KM* solid-state disks mv88e6060: disable hardware level MAC learning ARM: 8814/1: mm: improve/fix ARM v7_dma_inv_range() unaligned address handling cifs: In Kconfig CONFIG_CIFS_POSIX needs depends on legacy (insecure cifs) i2c: axxia: properly handle master timeout i2c: scmi: Fix probe error on devices with an empty SMB0001 ACPI device node rtc: snvs: add a missing write sync rtc: snvs: Add timeouts to avoid kernel lockups ALSA: isa/wavefront: prevent some out of bound writes Linux 4.4.169 Change-Id: Ic1bde8f64625c7787feb8e7411b15e70a2f76981 Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2018-12-21tracing: Fix memory leak of instance function hash filtersSteven Rostedt (VMware)
commit 2840f84f74035e5a535959d5f17269c69fa6edc5 upstream. The following commands will cause a memory leak: # cd /sys/kernel/tracing # mkdir instances/foo # echo schedule > instance/foo/set_ftrace_filter # rmdir instances/foo The reason is that the hashes that hold the filters to set_ftrace_filter and set_ftrace_notrace are not freed if they contain any data on the instance and the instance is removed. Found by kmemleak detector. Cc: stable@vger.kernel.org Fixes: 591dffdade9f ("ftrace: Allow for function tracing instance to filter functions") Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-12-21tracing: Fix memory leak in set_trigger_filter()Steven Rostedt (VMware)
commit 3cec638b3d793b7cacdec5b8072364b41caeb0e1 upstream. When create_event_filter() fails in set_trigger_filter(), the filter may still be allocated and needs to be freed. The caller expects the data->filter to be updated with the new filter, even if the new filter failed (we could add an error message by setting set_str parameter of create_event_filter(), but that's another update). But because the error would just exit, filter was left hanging and nothing could free it. Found by kmemleak detector. Cc: stable@vger.kernel.org Fixes: bac5fb97a173a ("tracing: Add and use generic set_trigger_filter() implementation") Reviewed-by: Tom Zanussi <tom.zanussi@linux.intel.com> Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-12-21timer/debug: Change /proc/timer_list from 0444 to 0400Ingo Molnar
[ Upstream commit 8e7df2b5b7f245c9bd11064712db5cb69044a362 ] While it uses %pK, there's still few reasons to read this file as non-root. Suggested-by: Linus Torvalds <torvalds@linux-foundation.org> Acked-by: Thomas Gleixner <tglx@linutronix.de> Cc: Peter Zijlstra <peterz@infradead.org> Cc: linux-kernel@vger.kernel.org Signed-off-by: Ingo Molnar <mingo@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
2018-12-19Merge 4.4.168 into android-4.4Greg Kroah-Hartman
Changes in 4.4.168 ipv6: Check available headroom in ip6_xmit() even without options net: 8139cp: fix a BUG triggered by changing mtu with network traffic net: phy: don't allow __set_phy_supported to add unsupported modes net: Prevent invalid access to skb->prev in __qdisc_drop_all rtnetlink: ndo_dflt_fdb_dump() only work for ARPHRD_ETHER devices tcp: fix NULL ref in tail loss probe tun: forbid iface creation with rtnl ops neighbour: Avoid writing before skb->head in neigh_hh_output() ARM: OMAP2+: prm44xx: Fix section annotation on omap44xx_prm_enable_io_wakeup ARM: OMAP1: ams-delta: Fix possible use of uninitialized field sysv: return 'err' instead of 0 in __sysv_write_inode s390/cpum_cf: Reject request for sampling in event initialization hwmon: (ina2xx) Fix current value calculation ASoC: dapm: Recalculate audio map forcely when card instantiated hwmon: (w83795) temp4_type has writable permission Btrfs: send, fix infinite loop due to directory rename dependencies ASoC: omap-mcpdm: Add pm_qos handling to avoid under/overruns with CPU_IDLE ASoC: omap-dmic: Add pm_qos handling to avoid overruns with CPU_IDLE exportfs: do not read dentry after free bpf: fix check of allowed specifiers in bpf_trace_printk USB: omap_udc: use devm_request_irq() USB: omap_udc: fix crashes on probe error and module removal USB: omap_udc: fix omap_udc_start() on 15xx machines USB: omap_udc: fix USB gadget functionality on Palm Tungsten E KVM: x86: fix empty-body warnings net: thunderx: fix NULL pointer dereference in nic_remove ixgbe: recognize 1000BaseLX SFP modules as 1Gbps net: hisilicon: remove unexpected free_netdev drm/ast: fixed reading monitor EDID not stable issue xen: xlate_mmu: add missing header to fix 'W=1' warning fscache: fix race between enablement and dropping of object fscache, cachefiles: remove redundant variable 'cache' ocfs2: fix deadlock caused by ocfs2_defrag_extent() hfs: do not free node before using hfsplus: do not free node before using debugobjects: avoid recursive calls with kmemleak ocfs2: fix potential use after free pstore: Convert console write to use ->write_buf ALSA: pcm: remove SNDRV_PCM_IOCTL1_INFO internal command KVM: nVMX: fix msr bitmaps to prevent L2 from accessing L0 x2APIC KVM: nVMX: mark vmcs12 pages dirty on L2 exit KVM: nVMX: Eliminate vmcs02 pool KVM: VMX: introduce alloc_loaded_vmcs KVM: VMX: make MSR bitmaps per-VCPU KVM/x86: Add IBPB support KVM/VMX: Emulate MSR_IA32_ARCH_CAPABILITIES KVM/VMX: Allow direct access to MSR_IA32_SPEC_CTRL KVM/SVM: Allow direct access to MSR_IA32_SPEC_CTRL KVM/x86: Remove indirect MSR op calls from SPEC_CTRL x86: reorganize SMAP handling in user space accesses x86: fix SMAP in 32-bit environments x86: Introduce __uaccess_begin_nospec() and uaccess_try_nospec x86/usercopy: Replace open coded stac/clac with __uaccess_{begin, end} x86/uaccess: Use __uaccess_begin_nospec() and uaccess_try_nospec x86/bugs, KVM: Support the combination of guest and host IBRS x86/KVM/VMX: Expose SPEC_CTRL Bit(2) to the guest KVM: SVM: Move spec control call after restore of GS x86/bugs, KVM: Extend speculation control for VIRT_SPEC_CTRL x86/speculation: Use synthetic bits for IBRS/IBPB/STIBP KVM: SVM: Implement VIRT_SPEC_CTRL support for SSBD bpf: support 8-byte metafield access bpf/verifier: Add spi variable to check_stack_write() bpf/verifier: Pass instruction index to check_mem_access() and check_xadd() bpf: Prevent memory disambiguation attack wil6210: missing length check in wmi_set_ie posix-timers: Sanitize overrun handling mm/hugetlb.c: don't call region_abort if region_chg fails hugetlbfs: fix offset overflow in hugetlbfs mmap hugetlbfs: check for pgoff value overflow hugetlbfs: fix bug in pgoff overflow checking swiotlb: clean up reporting sr: pass down correctly sized SCSI sense buffer mm: remove write/force parameters from __get_user_pages_locked() mm: remove write/force parameters from __get_user_pages_unlocked() mm/nommu.c: Switch __get_user_pages_unlocked() to use __get_user_pages() mm: replace get_user_pages_unlocked() write/force parameters with gup_flags mm: replace get_user_pages_locked() write/force parameters with gup_flags mm: replace get_vaddr_frames() write/force parameters with gup_flags mm: replace get_user_pages() write/force parameters with gup_flags mm: replace __access_remote_vm() write parameter with gup_flags mm: replace access_remote_vm() write parameter with gup_flags proc: don't use FOLL_FORCE for reading cmdline and environment proc: do not access cmdline nor environ from file-backed areas media: dvb-frontends: fix i2c access helpers for KASAN matroxfb: fix size of memcpy staging: speakup: Replace strncpy with memcpy rocker: fix rocker_tlv_put_* functions for KASAN selftests: Move networking/timestamping from Documentation Linux 4.4.168 Change-Id: I71a633f645fada4b473abcff660a9ada3103592b Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2018-12-17mm: replace get_user_pages() write/force parameters with gup_flagsLorenzo Stoakes
commit 768ae309a96103ed02eb1e111e838c87854d8b51 upstream. This removes the 'write' and 'force' from get_user_pages() and replaces them with 'gup_flags' to make the use of FOLL_FORCE explicit in callers as use of this flag can result in surprising behaviour (and hence bugs) within the mm subsystem. Signed-off-by: Lorenzo Stoakes <lstoakes@gmail.com> Acked-by: Christian König <christian.koenig@amd.com> Acked-by: Jesper Nilsson <jesper.nilsson@axis.com> Acked-by: Michal Hocko <mhocko@suse.com> Reviewed-by: Jan Kara <jack@suse.cz> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> [bwh: Backported to 4.4: - Drop changes in rapidio, vchiq, goldfish - Keep the "write" variable in amdgpu_ttm_tt_pin_userptr() as it's still needed - Also update calls from various other places that now use get_user_pages_remote() upstream, which were updated there by commit 9beae1ea8930 "mm: replace get_user_pages_remote() write/force ..." - Also update calls from hfi1 and ipath - Adjust context] Signed-off-by: Ben Hutchings <ben.hutchings@codethink.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-12-17posix-timers: Sanitize overrun handlingThomas Gleixner
commit 78c9c4dfbf8c04883941445a195276bb4bb92c76 upstream. The posix timer overrun handling is broken because the forwarding functions can return a huge number of overruns which does not fit in an int. As a consequence timer_getoverrun(2) and siginfo::si_overrun can turn into random number generators. The k_clock::timer_forward() callbacks return a 64 bit value now. Make k_itimer::ti_overrun[_last] 64bit as well, so the kernel internal accounting is correct. 3Remove the temporary (int) casts. Add a helper function which clamps the overrun value returned to user space via timer_getoverrun(2) or siginfo::si_overrun limited to a positive value between 0 and INT_MAX. INT_MAX is an indicator for user space that the overrun value has been clamped. Reported-by: Team OWL337 <icytxw@gmail.com> Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Acked-by: John Stultz <john.stultz@linaro.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Michael Kerrisk <mtk.manpages@gmail.com> Link: https://lkml.kernel.org/r/20180626132705.018623573@linutronix.de [florian: Make patch apply to v4.9.135] Signed-off-by: Florian Fainelli <f.fainelli@gmail.com> Reviewed-by: Thomas Gleixner <tglx@linutronix.de> Signed-off-by: Sasha Levin <sashal@kernel.org> Signed-off-by: Ben Hutchings <ben.hutchings@codethink.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-12-17bpf: Prevent memory disambiguation attackAlexei Starovoitov
commit af86ca4e3088fe5eacf2f7e58c01fa68ca067672 upstream. Detect code patterns where malicious 'speculative store bypass' can be used and sanitize such patterns. 39: (bf) r3 = r10 40: (07) r3 += -216 41: (79) r8 = *(u64 *)(r7 +0) // slow read 42: (7a) *(u64 *)(r10 -72) = 0 // verifier inserts this instruction 43: (7b) *(u64 *)(r8 +0) = r3 // this store becomes slow due to r8 44: (79) r1 = *(u64 *)(r6 +0) // cpu speculatively executes this load 45: (71) r2 = *(u8 *)(r1 +0) // speculatively arbitrary 'load byte' // is now sanitized Above code after x86 JIT becomes: e5: mov %rbp,%rdx e8: add $0xffffffffffffff28,%rdx ef: mov 0x0(%r13),%r14 f3: movq $0x0,-0x48(%rbp) fb: mov %rdx,0x0(%r14) ff: mov 0x0(%rbx),%rdi 103: movzbq 0x0(%rdi),%rsi Signed-off-by: Alexei Starovoitov <ast@kernel.org> Signed-off-by: Thomas Gleixner <tglx@linutronix.de> [bwh: Backported to 4.4: - Add verifier_env parameter to check_stack_write() - Look up stack slot_types with state->stack_slot_type[] rather than state->stack[].slot_type[] - Drop bpf_verifier_env argument to verbose() - Adjust filename, context] Signed-off-by: Ben Hutchings <ben.hutchings@codethink.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-12-17bpf/verifier: Pass instruction index to check_mem_access() and check_xadd()Ben Hutchings
Extracted from commit 31fd85816dbe "bpf: permits narrower load from bpf program context fields". Cc: Daniel Borkmann <daniel@iogearbox.net> Cc: Alexei Starovoitov <ast@kernel.org> Signed-off-by: Ben Hutchings <ben.hutchings@codethink.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-12-17bpf/verifier: Add spi variable to check_stack_write()Ben Hutchings
Extracted from commit dc503a8ad984 "bpf/verifier: track liveness for pruning". Cc: Daniel Borkmann <daniel@iogearbox.net> Cc: Alexei Starovoitov <ast@kernel.org> Signed-off-by: Ben Hutchings <ben.hutchings@codethink.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-12-17bpf: support 8-byte metafield accessAlexei Starovoitov
commit cedaf52693f02372010548c63b2e63228b959099 upstream. The verifier supported only 4-byte metafields in struct __sk_buff and struct xdp_md. The metafields in upcoming struct bpf_perf_event are 8-byte to match register width in struct pt_regs. Teach verifier to recognize 8-byte metafield access. The patch doesn't affect safety of sockets and xdp programs. They check for 4-byte only ctx access before these conditions are hit. Signed-off-by: Alexei Starovoitov <ast@kernel.org> Acked-by: Daniel Borkmann <daniel@iogearbox.net> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Ben Hutchings <ben.hutchings@codethink.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-12-17bpf: fix check of allowed specifiers in bpf_trace_printkMartynas Pumputis
[ Upstream commit 1efb6ee3edea57f57f9fb05dba8dcb3f7333f61f ] A format string consisting of "%p" or "%s" followed by an invalid specifier (e.g. "%p%\n" or "%s%") could pass the check which would make format_decode (lib/vsprintf.c) to warn. Fixes: 9c959c863f82 ("tracing: Allow BPF programs to call bpf_trace_printk()") Reported-by: syzbot+1ec5c5ec949c4adaa0c4@syzkaller.appspotmail.com Signed-off-by: Martynas Pumputis <m@lambda.lt> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net> Signed-off-by: Sasha Levin <sashal@kernel.org>
2018-12-13Merge 4.4.167 into android-4.4Greg Kroah-Hartman
Changes in 4.4.167 media: em28xx: Fix use-after-free when disconnecting Revert "wlcore: Add missing PM call for wlcore_cmd_wait_for_event_or_timeout()" rapidio/rionet: do not free skb before reading its length s390/qeth: fix length check in SNMP processing usbnet: ipheth: fix potential recvmsg bug and recvmsg bug 2 kvm: mmu: Fix race in emulated page table writes xtensa: enable coprocessors that are being flushed xtensa: fix coprocessor context offset definitions Btrfs: ensure path name is null terminated at btrfs_control_ioctl ALSA: wss: Fix invalid snd_free_pages() at error path ALSA: ac97: Fix incorrect bit shift at AC97-SPSA control write ALSA: control: Fix race between adding and removing a user element ALSA: sparc: Fix invalid snd_free_pages() at error path ext2: fix potential use after free dmaengine: at_hdmac: fix memory leak in at_dma_xlate() dmaengine: at_hdmac: fix module unloading btrfs: release metadata before running delayed refs USB: usb-storage: Add new IDs to ums-realtek usb: core: quirks: add RESET_RESUME quirk for Cherry G230 Stream series misc: mic/scif: fix copy-paste error in scif_create_remote_lookup Kbuild: suppress packed-not-aligned warning for default setting only exec: avoid gcc-8 warning for get_task_comm disable stringop truncation warnings for now kobject: Replace strncpy with memcpy unifdef: use memcpy instead of strncpy kernfs: Replace strncpy with memcpy ip_tunnel: Fix name string concatenate in __ip_tunnel_create() drm: gma500: fix logic error scsi: bfa: convert to strlcpy/strlcat staging: rts5208: fix gcc-8 logic error warning kdb: use memmove instead of overlapping memcpy iser: set sector for ambiguous mr status errors uprobes: Fix handle_swbp() vs. unregister() + register() race once more MIPS: ralink: Fix mt7620 nd_sd pinmux mips: fix mips_get_syscall_arg o32 check drm/ast: Fix incorrect free on ioregs scsi: scsi_devinfo: cleanly zero-pad devinfo strings ALSA: trident: Suppress gcc string warning scsi: csiostor: Avoid content leaks and casts kgdboc: Fix restrict error kgdboc: Fix warning with module build leds: call led_pwm_set() in leds-pwm to enforce default LED_OFF leds: turn off the LED and wait for completion on unregistering LED class device leds: leds-gpio: Fix return value check in create_gpio_led() Input: xpad - quirk all PDP Xbox One gamepads Input: matrix_keypad - check for errors from of_get_named_gpio() Input: elan_i2c - add ELAN0620 to the ACPI table Input: elan_i2c - add ACPI ID for Lenovo IdeaPad 330-15ARR Input: elan_i2c - add support for ELAN0621 touchpad btrfs: Always try all copies when reading extent buffers Btrfs: fix use-after-free when dumping free space ARC: change defconfig defaults to ARCv2 arc: [devboards] Add support of NFSv3 ACL mm: cleancache: fix corruption on missed inode invalidation mm: mlock: avoid increase mm->locked_vm on mlock() when already mlock2(,MLOCK_ONFAULT) usb: gadget: dummy: fix nonsensical comparisons iommu/vt-d: Fix NULL pointer dereference in prq_event_thread() iommu/ipmmu-vmsa: Fix crash on early domain free can: rcar_can: Fix erroneous registration batman-adv: Expand merged fragment buffer for full packet bnx2x: Assign unique DMAE channel number for FW DMAE transactions. qed: Fix PTT leak in qed_drain() qed: Fix reading wrong value in loop condition net/mlx4_core: Zero out lkey field in SW2HW_MPT fw command net/mlx4_core: Fix uninitialized variable compilation warning net/mlx4: Fix UBSAN warning of signed integer overflow net: faraday: ftmac100: remove netif_running(netdev) check before disabling interrupts iommu/vt-d: Use memunmap to free memremap net: amd: add missing of_node_put() usb: quirk: add no-LPM quirk on SanDisk Ultra Flair device usb: appledisplay: Add 27" Apple Cinema Display USB: check usb_get_extra_descriptor for proper size ALSA: usb-audio: Fix UAF decrement if card has no live interfaces in card.c ALSA: hda: Add support for AMD Stoney Ridge ALSA: pcm: Fix starvation on down_write_nonblock() ALSA: pcm: Call snd_pcm_unlink() conditionally at closing ALSA: pcm: Fix interval evaluation with openmin/max virtio/s390: avoid race on vcdev->config virtio/s390: fix race in ccw_io_helper() SUNRPC: Fix leak of krb5p encode pages xhci: Prevent U1/U2 link pm states if exit latency is too long Staging: lustre: remove two build warnings cifs: Fix separator when building path from dentry tty: serial: 8250_mtk: always resume the device in probe. kgdboc: fix KASAN global-out-of-bounds bug in param_set_kgdboc_var() mac80211_hwsim: Timer should be initialized before device registered mac80211: Clear beacon_int in ieee80211_do_stop mac80211: ignore tx status for PS stations in ieee80211_tx_status_ext mac80211: fix reordering of buffered broadcast packets mac80211: ignore NullFunc frames in the duplicate detection Linux 4.4.167 Change-Id: Ib893e2bb7e739960eed0710447033f7ab65dab4f Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2018-12-13uprobes: Fix handle_swbp() vs. unregister() + register() race once moreAndrea Parri
commit 09d3f015d1e1b4fee7e9bbdcf54201d239393391 upstream. Commit: 142b18ddc8143 ("uprobes: Fix handle_swbp() vs unregister() + register() race") added the UPROBE_COPY_INSN flag, and corresponding smp_wmb() and smp_rmb() memory barriers, to ensure that handle_swbp() uses fully-initialized uprobes only. However, the smp_rmb() is mis-placed: this barrier should be placed after handle_swbp() has tested for the flag, thus guaranteeing that (program-order) subsequent loads from the uprobe can see the initial stores performed by prepare_uprobe(). Move the smp_rmb() accordingly. Also amend the comments associated to the two memory barriers to indicate their actual locations. Signed-off-by: Andrea Parri <andrea.parri@amarulasolutions.com> Acked-by: Oleg Nesterov <oleg@redhat.com> Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com> Cc: Andrew Morton <akpm@linux-foundation.org> Cc: Arnaldo Carvalho de Melo <acme@redhat.com> Cc: Jiri Olsa <jolsa@redhat.com> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Paul E. McKenney <paulmck@linux.vnet.ibm.com> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Stephane Eranian <eranian@google.com> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: Vince Weaver <vincent.weaver@maine.edu> Cc: stable@kernel.org Fixes: 142b18ddc8143 ("uprobes: Fix handle_swbp() vs unregister() + register() race") Link: http://lkml.kernel.org/r/20181122161031.15179-1-andrea.parri@amarulasolutions.com Signed-off-by: Ingo Molnar <mingo@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-12-13kdb: use memmove instead of overlapping memcpyArnd Bergmann
commit 2cf2f0d5b91fd1b06a6ae260462fc7945ea84add upstream. gcc discovered that the memcpy() arguments in kdbnearsym() overlap, so we should really use memmove(), which is defined to handle that correctly: In function 'memcpy', inlined from 'kdbnearsym' at /git/arm-soc/kernel/debug/kdb/kdb_support.c:132:4: /git/arm-soc/include/linux/string.h:353:9: error: '__builtin_memcpy' accessing 792 bytes at offsets 0 and 8 overlaps 784 bytes at offset 8 [-Werror=restrict] return __builtin_memcpy(p, q, size); Signed-off-by: Arnd Bergmann <arnd@arndb.de> Signed-off-by: Jason Wessel <jason.wessel@windriver.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-12-01Merge 4.4.166 into android-4.4Greg Kroah-Hartman
Changes in 4.4.166 usb: core: Fix hub port connection events lost usb: xhci: fix timeout for transition from RExit to U0 MAINTAINERS: Add Sasha as a stable branch maintainer iwlwifi: mvm: support sta_statistics() even on older firmware v9fs_dir_readdir: fix double-free on p9stat_read error bfs: add sanity check at bfs_fill_super() sctp: clear the transport of some out_chunk_list chunks in sctp_assoc_rm_peer gfs2: Don't leave s_fs_info pointing to freed memory in init_sbd llc: do not use sk_eat_skb() drm/ast: change resolution may cause screen blurred drm/ast: fixed cursor may disappear sometimes can: dev: can_get_echo_skb(): factor out non sending code to __can_get_echo_skb() can: dev: __can_get_echo_skb(): replace struct can_frame by canfd_frame to access frame length can: dev: __can_get_echo_skb(): Don't crash the kernel if can_priv::echo_skb is accessed out of bounds can: dev: __can_get_echo_skb(): print error message, if trying to echo non existing skb usb: xhci: Prevent bus suspend if a port connect change or polling state is detected KVM: PPC: Move and undef TRACE_INCLUDE_PATH/FILE cpufreq: imx6q: add return value check for voltage scale SUNRPC: Fix a bogus get/put in generic_key_to_expire() kdb: Use strscpy with destination buffer size powerpc/numa: Suppress "VPHN is not supported" messages tmpfs: make lseek(SEEK_DATA/SEK_HOLE) return ENXIO with a negative offset of: add helper to lookup compatible child node NFC: nfcmrvl_uart: fix OF child-node lookup net: bcmgenet: fix OF child-node lookup x86/entry: spell EBX register correctly in documentation x86/entry/64: Remove %ebx handling from error_entry/exit arm64: remove no-op -p linker flag ath10k: fix kernel panic due to race in accessing arvif list Input: xpad - remove spurious events of wireless xpad 360 controller Input: xpad - handle "present" and "gone" correctly Input: xpad - update Xbox One Force Feedback Support Input: xpad - workaround dead irq_out after suspend/ resume Input: xpad - use LED API when identifying wireless controllers Input: xpad - correct xbox one pad device name Input: xpad - remove unused function Input: xpad - add Mad Catz FightStick TE 2 VID/PID Input: xpad - prevent spurious input from wired Xbox 360 controllers Input: xpad - add more third-party controllers Input: xpad - xbox one elite controller support Input: xpad - fix rumble on Xbox One controllers with 2015 firmware Input: xpad - power off wireless 360 controllers on suspend Input: xpad - add product ID for Xbox One S pad Input: xpad - fix Xbox One rumble stopping after 2.5 secs Input: xpad - correctly sort vendor id's Input: xpad - move reporting xbox one home button to common function Input: xpad - simplify error condition in init_output Input: xpad - don't depend on endpoint order Input: xpad - fix stuck mode button on Xbox One S pad Input: xpad - restore LED state after device resume Input: xpad - support some quirky Xbox One pads Input: xpad - sort supported devices by USB ID Input: xpad - sync supported devices with xboxdrv Input: xpad - add USB IDs for Mad Catz Brawlstick and Razer Sabertooth Input: xpad - sync supported devices with 360Controller Input: xpad - sync supported devices with XBCD Input: xpad - constify usb_device_id Input: xpad - fix PowerA init quirk for some gamepad models Input: xpad - validate USB endpoint type during probe Input: xpad - add support for PDP Xbox One controllers Input: xpad - add PDP device id 0x02a4 Input: xpad - fix some coding style issues Input: xpad - avoid using __set_bit() for capabilities Input: xpad - add GPD Win 2 Controller USB IDs Input: xpad - fix GPD Win 2 controller name Input: xpad - add support for Xbox1 PDP Camo series gamepad cw1200: Don't leak memory if krealloc failes mwifiex: Fix NULL pointer dereference in skb_dequeue() mwifiex: fix p2p device doesn't find in scan problem netfilter: nf_tables: fix oops when inserting an element into a verdict map scsi: ufs: fix bugs related to null pointer access and array size scsi: ufshcd: Fix race between clk scaling and ungate work scsi: ufs: fix race between clock gating and devfreq scaling work scsi: ufshcd: release resources if probe fails scsi: qla2xxx: do not queue commands when unloading iwlwifi: mvm: fix regulatory domain update when the firmware starts tty: wipe buffer. tty: wipe buffer if not echoing data usb: xhci: fix uninitialized completion when USB3 port got wrong status btrfs: Ensure btrfs_trim_fs can trim the whole filesystem sched/core: Allow __sched_setscheduler() in interrupts when PI is not used namei: allow restricted O_CREAT of FIFOs and regular files s390/mm: Check for valid vma before zapping in gmap_discard drm/ast: Remove existing framebuffers before loading driver Linux 4.4.166 Change-Id: Iba8f0b45bc490f291b504ebb12590b2b01d4f075 Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2018-12-01namei: allow restricted O_CREAT of FIFOs and regular filesSalvatore Mesoraca
commit 30aba6656f61ed44cba445a3c0d38b296fa9e8f5 upstream. Disallows open of FIFOs or regular files not owned by the user in world writable sticky directories, unless the owner is the same as that of the directory or the file is opened without the O_CREAT flag. The purpose is to make data spoofing attacks harder. This protection can be turned on and off separately for FIFOs and regular files via sysctl, just like the symlinks/hardlinks protection. This patch is based on Openwall's "HARDEN_FIFO" feature by Solar Designer. This is a brief list of old vulnerabilities that could have been prevented by this feature, some of them even allow for privilege escalation: CVE-2000-1134 CVE-2007-3852 CVE-2008-0525 CVE-2009-0416 CVE-2011-4834 CVE-2015-1838 CVE-2015-7442 CVE-2016-7489 This list is not meant to be complete. It's difficult to track down all vulnerabilities of this kind because they were often reported without any mention of this particular attack vector. In fact, before hardlinks/symlinks restrictions, fifos/regular files weren't the favorite vehicle to exploit them. [s.mesoraca16@gmail.com: fix bug reported by Dan Carpenter] Link: https://lkml.kernel.org/r/20180426081456.GA7060@mwanda Link: http://lkml.kernel.org/r/1524829819-11275-1-git-send-email-s.mesoraca16@gmail.com [keescook@chromium.org: drop pr_warn_ratelimited() in favor of audit changes in the future] [keescook@chromium.org: adjust commit subjet] Link: http://lkml.kernel.org/r/20180416175918.GA13494@beast Signed-off-by: Salvatore Mesoraca <s.mesoraca16@gmail.com> Signed-off-by: Kees Cook <keescook@chromium.org> Suggested-by: Solar Designer <solar@openwall.com> Suggested-by: Kees Cook <keescook@chromium.org> Cc: Al Viro <viro@zeniv.linux.org.uk> Cc: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Cc: Loic <hackurx@opensec.fr> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-12-01sched/core: Allow __sched_setscheduler() in interrupts when PI is not usedSteven Rostedt (VMware)
commit 896bbb2522587e3b8eb2a0d204d43ccc1042a00d upstream. When priority inheritance was added back in 2.6.18 to sched_setscheduler(), it added a path to taking an rt-mutex wait_lock, which is not IRQ safe. As PI is not a common occurrence, lockdep will likely never trigger if sched_setscheduler was called from interrupt context. A BUG_ON() was added to trigger if __sched_setscheduler() was ever called from interrupt context because there was a possibility to take the wait_lock. Today the wait_lock is irq safe, but the path to taking it in sched_setscheduler() is the same as the path to taking it from normal context. The wait_lock is taken with raw_spin_lock_irq() and released with raw_spin_unlock_irq() which will indiscriminately enable interrupts, which would be bad in interrupt context. The problem is that normalize_rt_tasks, which is called by triggering the sysrq nice-all-RT-tasks was changed to call __sched_setscheduler(), and this is done from interrupt context! Now __sched_setscheduler() takes a "pi" parameter that is used to know if the priority inheritance should be called or not. As the BUG_ON() only cares about calling the PI code, it should only bug if called from interrupt context with the "pi" parameter set to true. Reported-by: Laurent Dufour <ldufour@linux.vnet.ibm.com> Tested-by: Laurent Dufour <ldufour@linux.vnet.ibm.com> Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Cc: Andrew Morton <akpm@osdl.org> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Thomas Gleixner <tglx@linutronix.de> Fixes: dbc7f069b93a ("sched: Use replace normalize_task() with __sched_setscheduler()") Link: http://lkml.kernel.org/r/20170308124654.10e598f2@gandalf.local.home Signed-off-by: Ingo Molnar <mingo@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-12-01kdb: Use strscpy with destination buffer sizePrarit Bhargava
[ Upstream commit c2b94c72d93d0929f48157eef128c4f9d2e603ce ] gcc 8.1.0 warns with: kernel/debug/kdb/kdb_support.c: In function ‘kallsyms_symbol_next’: kernel/debug/kdb/kdb_support.c:239:4: warning: ‘strncpy’ specified bound depends on the length of the source argument [-Wstringop-overflow=] strncpy(prefix_name, name, strlen(name)+1); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ kernel/debug/kdb/kdb_support.c:239:31: note: length computed here Use strscpy() with the destination buffer size, and use ellipses when displaying truncated symbols. v2: Use strscpy() Signed-off-by: Prarit Bhargava <prarit@redhat.com> Cc: Jonathan Toppins <jtoppins@redhat.com> Cc: Jason Wessel <jason.wessel@windriver.com> Cc: Daniel Thompson <daniel.thompson@linaro.org> Cc: kgdb-bugreport@lists.sourceforge.net Reviewed-by: Daniel Thompson <daniel.thompson@linaro.org> Signed-off-by: Daniel Thompson <daniel.thompson@linaro.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
2018-11-27UPSTREAM: seccomp: Fix tracer exit notifications during fatal signalsKees Cook
This fixes a ptrace vs fatal pending signals bug as manifested in seccomp now that seccomp was reordered to happen after ptrace. The short version is that seccomp should not attempt to call do_exit() while fatal signals are pending under a tracer. The existing code was trying to be as defensively paranoid as possible, but it now ends up confusing ptrace. Instead, the syscall can just be skipped (which solves the original concern that the do_exit() was addressing) and normal signal handling, tracer notification, and process death can happen. Paraphrasing from the original bug report: If a tracee task is in a PTRACE_EVENT_SECCOMP trap, or has been resumed after such a trap but not yet been scheduled, and another task in the thread-group calls exit_group(), then the tracee task exits without the ptracer receiving a PTRACE_EVENT_EXIT notification. Test case here: https://gist.github.com/khuey/3c43ac247c72cef8c956ca73281c9be7 The bug happens because when __seccomp_filter() detects fatal_signal_pending(), it calls do_exit() without dequeuing the fatal signal. When do_exit() sends the PTRACE_EVENT_EXIT notification and that task is descheduled, __schedule() notices that there is a fatal signal pending and changes its state from TASK_TRACED to TASK_RUNNING. That prevents the ptracer's waitpid() from returning the ptrace event. A more detailed analysis is here: https://github.com/mozilla/rr/issues/1762#issuecomment-237396255. Reported-by: Robert O'Callahan <robert@ocallahan.org> Reported-by: Kyle Huey <khuey@kylehuey.com> Tested-by: Kyle Huey <khuey@kylehuey.com> Fixes: 93e35efb8de4 ("x86/ptrace: run seccomp after ptrace") Signed-off-by: Kees Cook <keescook@chromium.org> Acked-by: Oleg Nesterov <oleg@redhat.com> Acked-by: James Morris <james.l.morris@oracle.com> (cherry picked from commit 485a252a5559b45d7df04c819ec91177c62c270b) Bug: 119769499 Change-Id: I444e69093e88d58587b4d5c4f2d777985591c32d Signed-off-by: Greg Hackmann <ghackmann@google.com>
2018-11-27UPSTREAM: seccomp: recheck the syscall after RET_TRACEKees Cook
When RET_TRACE triggers, a tracer may change a syscall into something that should be filtered by seccomp. This re-runs seccomp after a trace event to make sure things continue to pass. Signed-off-by: Kees Cook <keescook@chromium.org> Cc: Andy Lutomirski <luto@kernel.org> (cherry picked from commit ce6526e8afa4b6ad0ab134a4cc50c9c863319637) Bug: 119769499 Change-Id: Ib67732df3c2ac8c6b1de87e75f96aaed02f4627d Signed-off-by: Greg Hackmann <ghackmann@google.com>
2018-11-27UPSTREAM: seccomp: remove 2-phase APIKees Cook
Since nothing is using the 2-phase API, and it adds more complexity than benefit, remove it. Signed-off-by: Kees Cook <keescook@chromium.org> Cc: Andy Lutomirski <luto@kernel.org> (cherry picked from commit 8112c4f140fa03f9ee68aad2cc79afa7df5418d3) Bug: 119769499 Change-Id: Iff6246c1e6e9dd0161b80b666a5e796f78a5c785 Signed-off-by: Greg Hackmann <ghackmann@google.com>
2018-11-27BACKPORT: seccomp: Add a seccomp_data parameter secure_computing()Andy Lutomirski
Currently, if arch code wants to supply seccomp_data directly to seccomp (which is generally much faster than having seccomp do it using the syscall_get_xyz() API), it has to use the two-phase seccomp hooks. Add it to the easy hooks, too. Cc: linux-arch@vger.kernel.org Signed-off-by: Andy Lutomirski <luto@kernel.org> Signed-off-by: Kees Cook <keescook@chromium.org> (cherry picked from commit 2f275de5d1ed7269913ef9b4c64a13952c0a38e8) Bug: 119769499 Change-Id: I96876ecd8d1743c289ecef6d2deb65361d1f5baa [ghackmann@google.com: drop changes to parisc, tile, and um, which didn't implement seccomp support in this kernel version] Signed-off-by: Greg Hackmann <ghackmann@google.com>
2018-11-21Merge 4.4.164 into android-4.4Greg Kroah-Hartman
Changes in 4.4.164 bcache: fix miss key refill->end in writeback hwmon: (pmbus) Fix page count auto-detection. jffs2: free jffs2_sb_info through jffs2_kill_sb() pcmcia: Implement CLKRUN protocol disabling for Ricoh bridges ipmi: Fix timer race with module unload parisc: Fix address in HPMC IVA parisc: Fix map_pages() to not overwrite existing pte entries ALSA: hda - Add mic quirk for the Lenovo G50-30 (17aa:3905) ALSA: ca0106: Disable IZD on SB0570 DAC to fix audio pops x86/corruption-check: Fix panic in memory_corruption_check() when boot option without value is provided x86/kconfig: Fall back to ticket spinlocks sparc: Fix single-pcr perf event counter management. x86/fpu: Remove second definition of fpu in __fpu__restore_sig() net: qla3xxx: Remove overflowing shift statement selftests: ftrace: Add synthetic event syntax testcase locking/lockdep: Fix debug_locks off performance problem ataflop: fix error handling during setup swim: fix cleanup on setup error tun: Consistently configure generic netdev params via rtnetlink perf tools: Free temporary 'sys' string in read_event_files() perf tools: Cleanup trace-event-info 'tdata' leak mmc: sdhci-pci-o2micro: Add quirk for O2 Micro dev 0x8620 rev 0x01 Bluetooth: btbcm: Add entry for BCM4335C0 UART bluetooth x86: boot: Fix EFI stub alignment pinctrl: qcom: spmi-mpp: Fix err handling of pmic_mpp_set_mux kprobes: Return error if we fail to reuse kprobe instead of BUG_ON() ACPI / LPSS: Add alternative ACPI HIDs for Cherry Trail DMA controllers pinctrl: qcom: spmi-mpp: Fix drive strength setting pinctrl: spmi-mpp: Fix pmic_mpp_config_get() to be compliant pinctrl: ssbi-gpio: Fix pm8xxx_pin_config_get() to be compliant ath10k: schedule hardware restart if WMI command times out scsi: esp_scsi: Track residual for PIO transfers scsi: megaraid_sas: fix a missing-check bug tpm: suppress transmit cmd error logs when TPM 1.2 is disabled/deactivated ext4: fix argument checking in EXT4_IOC_MOVE_EXT MD: fix invalid stored role for a disk usb: chipidea: Prevent unbalanced IRQ disable driver/dma/ioat: Call del_timer_sync() without holding prep_lock uio: ensure class is registered before devices scsi: lpfc: Correct soft lockup when running mds diagnostics signal: Always deliver the kernel's SIGKILL and SIGSTOP to a pid namespace init dmaengine: dma-jz4780: Return error if not probed from DT ALSA: hda: Check the non-cached stream buffers more explicitly xen-swiotlb: use actually allocated size on check physical continuous tpm: Restore functionality to xen vtpm driver. xen: fix race in xen_qlock_wait() xen: make xen_qlock_wait() nestable net/ipv4: defensive cipso option parsing libnvdimm: Hold reference on parent while scheduling async init jbd2: fix use after free in jbd2_log_do_checkpoint() gfs2_meta: ->mount() can get NULL dev_name ext4: initialize retries variable in ext4_da_write_inline_data_begin() HID: hiddev: fix potential Spectre v1 PCI: Add Device IDs for Intel GPU "spurious interrupt" quirk signal/GenWQE: Fix sending of SIGKILL crypto: lrw - Fix out-of bounds access on counter overflow ima: fix showing large 'violations' or 'runtime_measurements_count' hugetlbfs: dirty pages as they are added to pagecache kbuild: fix kernel/bounds.c 'W=1' warning iio: adc: at91: fix acking DRDY irq on simple conversions iio: adc: at91: fix wrong channel number in triggered buffer mode w1: omap-hdq: fix missing bus unregister at removal smb3: allow stats which track session and share reconnects to be reset smb3: do not attempt cifs operation in smb3 query info error path smb3: on kerberos mount if server doesn't specify auth type use krb5 printk: Fix panic caused by passing log_buf_len to command line genirq: Fix race on spurious interrupt detection NFSv4.1: Fix the r/wsize checking nfsd: Fix an Oops in free_session() lockd: fix access beyond unterminated strings in prints dm ioctl: harden copy_params()'s copy_from_user() from malicious users powerpc/msi: Fix compile error on mpc83xx MIPS: OCTEON: fix out of bounds array access on CN68XX TC: Set DMA masks for devices kgdboc: Passing ekgdboc to command line causes panic xen: fix xen_qlock_wait() media: em28xx: use a default format if TRY_FMT fails media: em28xx: fix input name for Terratec AV 350 media: em28xx: make v4l2-compliance happier by starting sequence on zero ext4: avoid running out of journal credits when appending to an inline file Cramfs: fix abad comparison when wrap-arounds occur arm64: dts: stratix10: Correct System Manager register size soc/tegra: pmc: Fix child-node lookup btrfs: Handle owner mismatch gracefully when walking up tree btrfs: locking: Add extra check in btrfs_init_new_buffer() to avoid deadlock btrfs: iterate all devices during trim, instead of fs_devices::alloc_list btrfs: don't attempt to trim devices that don't support it btrfs: wait on caching when putting the bg cache btrfs: reset max_extent_size on clear in a bitmap btrfs: make sure we create all new block groups Btrfs: fix wrong dentries after fsync of file that got its parent replaced btrfs: qgroup: Dirty all qgroups before rescan Btrfs: fix null pointer dereference on compressed write path error btrfs: set max_extent_size properly MD: fix invalid stored role for a disk - try2 tty: check name length in tty_find_polling_driver() powerpc/nohash: fix undefined behaviour when testing page size support drm/omap: fix memory barrier bug in DMM driver media: pci: cx23885: handle adding to list failure MIPS: kexec: Mark CPU offline before disabling local IRQ powerpc/boot: Ensure _zimage_start is a weak symbol sc16is7xx: Fix for multi-channel stall media: tvp5150: fix width alignment during set_selection() 9p locks: fix glock.client_id leak in do_lock 9p: clear dangling pointers in p9stat_free cdrom: fix improper type cast, which can leat to information leak. scsi: qla2xxx: Fix incorrect port speed being set for FC adapters fuse: Fix use-after-free in fuse_dev_do_read() fuse: Fix use-after-free in fuse_dev_do_write() fuse: fix blocked_waitq wakeup fuse: set FR_SENT while locked mm, elf: handle vm_brk error binfmt_elf: fix calculations for bss padding mm: refuse wrapped vm_brk requests fs, elf: make sure to page align bss in load_elf_library mm: do not bug_on on incorrect length in __mm_populate() e1000: avoid null pointer dereference on invalid stat type e1000: fix race condition between e1000_down() and e1000_watchdog bna: ethtool: Avoid reading past end of buffer MIPS: Loongson-3: Fix CPU UART irq delivery problem MIPS: Loongson-3: Fix BRIDGE irq delivery problem xtensa: add NOTES section to the linker script xtensa: make sure bFLT stack is 16 byte aligned xtensa: fix boot parameters address translation clk: s2mps11: Fix matching when built as module and DT node contains compatible libceph: bump CEPH_MSG_MAX_DATA_LEN mach64: fix display corruption on big endian machines mach64: fix image corruption due to reading accelerator registers vhost/scsi: truncate T10 PI iov_iter to prot_bytes ocfs2: fix a misuse a of brelse after failing ocfs2_check_dir_entry mm: thp: relax __GFP_THISNODE for MADV_HUGEPAGE mappings mtd: docg3: don't set conflicting BCH_CONST_PARAMS option termios, tty/tty_baudrate.c: fix buffer overrun arch/alpha, termios: implement BOTHER, IBSHIFT and termios2 Btrfs: fix data corruption due to cloning of eof block clockevents/drivers/i8253: Add support for PIT shutdown quirk ext4: add missing brelse() update_backups()'s error path ext4: add missing brelse() in set_flexbg_block_bitmap()'s error path ext4: add missing brelse() add_new_gdb_meta_bg()'s error path ext4: avoid potential extra brelse in setup_new_flex_group_blocks() ext4: fix possible inode leak in the retry loop of ext4_resize_fs() ext4: avoid buffer leak in ext4_orphan_add() after prior errors ext4: fix missing cleanup if ext4_alloc_flex_bg_array() fails while resizing ext4: avoid possible double brelse() in add_new_gdb() on error path ext4: fix possible leak of sbi->s_group_desc_leak in error path ext4: release bs.bh before re-using in ext4_xattr_block_find() ext4: fix buffer leak in ext4_xattr_move_to_block() on error path ext4: fix buffer leak in __ext4_read_dirblock() on error path mount: Retest MNT_LOCKED in do_umount mount: Don't allow copying MNT_UNBINDABLE|MNT_LOCKED mounts mount: Prevent MNT_DETACH from disconnecting locked mounts sunrpc: correct the computation for page_ptr when truncating rtc: hctosys: Add missing range error reporting fuse: fix leaked notify reply configfs: replace strncpy with memcpy hugetlbfs: fix kernel BUG at fs/hugetlbfs/inode.c:444! mm: migration: fix migration of huge PMD shared pages drm/rockchip: Allow driver to be shutdown on reboot/kexec drm/dp_mst: Check if primary mstb is null drm/i915/hdmi: Add HDMI 2.0 audio clock recovery N values Linux 4.4.164 Change-Id: I55f9e5e33efd8c8ae2609d2393696c810f49f33e Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2018-11-21genirq: Fix race on spurious interrupt detectionLukas Wunner
commit 746a923b863a1065ef77324e1e43f19b1a3eab5c upstream. Commit 1e77d0a1ed74 ("genirq: Sanitize spurious interrupt detection of threaded irqs") made detection of spurious interrupts work for threaded handlers by: a) incrementing a counter every time the thread returns IRQ_HANDLED, and b) checking whether that counter has increased every time the thread is woken. However for oneshot interrupts, the commit unmasks the interrupt before incrementing the counter. If another interrupt occurs right after unmasking but before the counter is incremented, that interrupt is incorrectly considered spurious: time | irq_thread() | irq_thread_fn() | action->thread_fn() | irq_finalize_oneshot() | unmask_threaded_irq() /* interrupt is unmasked */ | | /* interrupt fires, incorrectly deemed spurious */ | | atomic_inc(&desc->threads_handled); /* counter is incremented */ v This is observed with a hi3110 CAN controller receiving data at high volume (from a separate machine sending with "cangen -g 0 -i -x"): The controller signals a huge number of interrupts (hundreds of millions per day) and every second there are about a dozen which are deemed spurious. In theory with high CPU load and the presence of higher priority tasks, the number of incorrectly detected spurious interrupts might increase beyond the 99,900 threshold and cause disablement of the interrupt. In practice it just increments the spurious interrupt count. But that can cause people to waste time investigating it over and over. Fix it by moving the accounting before the invocation of irq_finalize_oneshot(). [ tglx: Folded change log update ] Fixes: 1e77d0a1ed74 ("genirq: Sanitize spurious interrupt detection of threaded irqs") Signed-off-by: Lukas Wunner <lukas@wunner.de> Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Cc: Mathias Duckeck <m.duckeck@kunbus.de> Cc: Akshay Bhat <akshay.bhat@timesys.com> Cc: Casey Fitzpatrick <casey.fitzpatrick@timesys.com> Cc: stable@vger.kernel.org # v3.16+ Link: https://lkml.kernel.org/r/1dfd8bbd16163940648045495e3e9698e63b50ad.1539867047.git.lukas@wunner.de Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-11-21printk: Fix panic caused by passing log_buf_len to command lineHe Zhe
commit 277fcdb2cfee38ccdbe07e705dbd4896ba0c9930 upstream. log_buf_len_setup does not check input argument before passing it to simple_strtoull. The argument would be a NULL pointer if "log_buf_len", without its value, is set in command line and thus causes the following panic. PANIC: early exception 0xe3 IP 10:ffffffffaaeacd0d error 0 cr2 0x0 [ 0.000000] CPU: 0 PID: 0 Comm: swapper Not tainted 4.19.0-rc4-yocto-standard+ #1 [ 0.000000] RIP: 0010:_parse_integer_fixup_radix+0xd/0x70 ... [ 0.000000] Call Trace: [ 0.000000] simple_strtoull+0x29/0x70 [ 0.000000] memparse+0x26/0x90 [ 0.000000] log_buf_len_setup+0x17/0x22 [ 0.000000] do_early_param+0x57/0x8e [ 0.000000] parse_args+0x208/0x320 [ 0.000000] ? rdinit_setup+0x30/0x30 [ 0.000000] parse_early_options+0x29/0x2d [ 0.000000] ? rdinit_setup+0x30/0x30 [ 0.000000] parse_early_param+0x36/0x4d [ 0.000000] setup_arch+0x336/0x99e [ 0.000000] start_kernel+0x6f/0x4ee [ 0.000000] x86_64_start_reservations+0x24/0x26 [ 0.000000] x86_64_start_kernel+0x6f/0x72 [ 0.000000] secondary_startup_64+0xa4/0xb0 This patch adds a check to prevent the panic. Link: http://lkml.kernel.org/r/1538239553-81805-1-git-send-email-zhe.he@windriver.com Cc: stable@vger.kernel.org Cc: rostedt@goodmis.org Cc: linux-kernel@vger.kernel.org Signed-off-by: He Zhe <zhe.he@windriver.com> Reviewed-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com> Signed-off-by: Petr Mladek <pmladek@suse.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-11-21kbuild: fix kernel/bounds.c 'W=1' warningArnd Bergmann
commit 6a32c2469c3fbfee8f25bcd20af647326650a6cf upstream. Building any configuration with 'make W=1' produces a warning: kernel/bounds.c:16:6: warning: no previous prototype for 'foo' [-Wmissing-prototypes] When also passing -Werror, this prevents us from building any other files. Nobody ever calls the function, but we can't make it 'static' either since we want the compiler output. Calling it 'main' instead however avoids the warning, because gcc does not insist on having a declaration for main. Link: http://lkml.kernel.org/r/20181005083313.2088252-1-arnd@arndb.de Signed-off-by: Arnd Bergmann <arnd@arndb.de> Reported-by: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com> Cc: David Laight <David.Laight@ACULAB.COM> Cc: Masahiro Yamada <yamada.masahiro@socionext.com> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Cc: <stable@vger.kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-11-21signal: Always deliver the kernel's SIGKILL and SIGSTOP to a pid namespace initEric W. Biederman
[ Upstream commit 3597dfe01d12f570bc739da67f857fd222a3ea66 ] Instead of playing whack-a-mole and changing SEND_SIG_PRIV to SEND_SIG_FORCED throughout the kernel to ensure a pid namespace init gets signals sent by the kernel, stop allowing a pid namespace init to ignore SIGKILL or SIGSTOP sent by the kernel. A pid namespace init is only supposed to be able to ignore signals sent from itself and children with SIG_DFL. Fixes: 921cf9f63089 ("signals: protect cinit from unblocked SIG_DFL signals") Reviewed-by: Thomas Gleixner <tglx@linutronix.de> Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com> Signed-off-by: Sasha Levin <sashal@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-11-21kprobes: Return error if we fail to reuse kprobe instead of BUG_ON()Masami Hiramatsu
[ Upstream commit 819319fc93461c07b9cdb3064f154bd8cfd48172 ] Make reuse_unused_kprobe() to return error code if it fails to reuse unused kprobe for optprobe instead of calling BUG_ON(). Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org> Cc: Anil S Keshavamurthy <anil.s.keshavamurthy@intel.com> Cc: David S . Miller <davem@davemloft.net> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Naveen N . Rao <naveen.n.rao@linux.vnet.ibm.com> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Thomas Gleixner <tglx@linutronix.de> Link: http://lkml.kernel.org/r/153666124040.21306.14150398706331307654.stgit@devbox Signed-off-by: Ingo Molnar <mingo@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-11-21locking/lockdep: Fix debug_locks off performance problemWaiman Long
[ Upstream commit 9506a7425b094d2f1d9c877ed5a78f416669269b ] It was found that when debug_locks was turned off because of a problem found by the lockdep code, the system performance could drop quite significantly when the lock_stat code was also configured into the kernel. For instance, parallel kernel build time on a 4-socket x86-64 server nearly doubled. Further analysis into the cause of the slowdown traced back to the frequent call to debug_locks_off() from the __lock_acquired() function probably due to some inconsistent lockdep states with debug_locks off. The debug_locks_off() function did an unconditional atomic xchg to write a 0 value into debug_locks which had already been set to 0. This led to severe cacheline contention in the cacheline that held debug_locks. As debug_locks is being referenced in quite a few different places in the kernel, this greatly slow down the system performance. To prevent that trashing of debug_locks cacheline, lock_acquired() and lock_contended() now checks the state of debug_locks before proceeding. The debug_locks_off() function is also modified to check debug_locks before calling __debug_locks_off(). Signed-off-by: Waiman Long <longman@redhat.com> Cc: Andrew Morton <akpm@linux-foundation.org> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Paul E. McKenney <paulmck@linux.vnet.ibm.com> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: Will Deacon <will.deacon@arm.com> Link: http://lkml.kernel.org/r/1539913518-15598-1-git-send-email-longman@redhat.com Signed-off-by: Ingo Molnar <mingo@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-11-10Merge 4.4.163 into android-4.4Greg Kroah-Hartman
Changes in 4.4.163 xfrm: Validate address prefix lengths in the xfrm selector. xfrm6: call kfree_skb when skb is toobig mac80211: Always report TX status cfg80211: reg: Init wiphy_idx in regulatory_hint_core() ARM: 8799/1: mm: fix pci_ioremap_io() offset check xfrm: validate template mode mac80211_hwsim: do not omit multicast announce of first added radio Bluetooth: SMP: fix crash in unpairing pxa168fb: prepare the clock asix: Check for supported Wake-on-LAN modes ax88179_178a: Check for supported Wake-on-LAN modes lan78xx: Check for supported Wake-on-LAN modes sr9800: Check for supported Wake-on-LAN modes r8152: Check for supported Wake-on-LAN Modes smsc75xx: Check for Wake-on-LAN modes smsc95xx: Check for Wake-on-LAN modes perf/ring_buffer: Prevent concurent ring buffer access net: cxgb3_main: fix a missing-check bug KEYS: put keyring if install_session_keyring_to_cred() fails ipv6: suppress sparse warnings in IP6_ECN_set_ce() net: drop write-only stack variable ser_gigaset: use container_of() instead of detour tracing: Skip more functions when doing stack tracing of events ARM: dts: apq8064: add ahci ports-implemented mask x86/mm/pat: Prevent hang during boot when mapping pages radix-tree: fix radix_tree_iter_retry() for tagged iterators. af_iucv: Move sockaddr length checks to before accessing sa_family in bind and connect handlers net/mlx4_en: Resolve dividing by zero in 32-bit system ipv6: orphan skbs in reassembly unit um: Avoid longjmp/setjmp symbol clashes with libpthread.a sched/cgroup: Fix cgroup entity load tracking tear-down btrfs: don't create or leak aliased root while cleaning up orphans thermal: allow spear-thermal driver to be a module thermal: allow u8500-thermal driver to be a module tpm: fix: return rc when devm_add_action() fails x86/PCI: Mark Broadwell-EP Home Agent 1 as having non-compliant BARs aacraid: Start adapter after updating number of MSIX vectors perf/core: Don't leak event in the syscall error path usbvision: revert commit 588afcc1 MIPS: Fix FCSR Cause bit handling for correct SIGFPE issue ASoC: ak4613: Enable cache usage to fix crashes on resume ASoC: wm8940: Enable cache usage to fix crashes on resume CIFS: handle guest access errors to Windows shares arm64: Fix potential race with hardware DBM in ptep_set_access_flags() xfrm: Clear sk_dst_cache when applying per-socket policy. scsi: Add STARGET_CREATED_REMOVE state to scsi_target_state sparc/pci: Refactor dev_archdata initialization into pci_init_dev_archdata sch_red: update backlog as well usb-storage: fix bogus hardware error messages for ATA pass-thru devices bpf: generally move prog destruction to RCU deferral drm/nouveau/fbcon: fix oops without fbdev emulation fuse: Dont call set_page_dirty_lock() for ITER_BVEC pages for async_dio ixgbevf: Fix handling of NAPI budget when multiple queues are enabled per vector net/mlx5e: Fix LRO modify net/mlx5e: Correctly handle RSS indirection table when changing number of channels ixgbe: fix RSS limit for X550 ixgbe: Correct X550EM_x revision check ALSA: timer: Fix zero-division by continue of uninitialized instance vti6: flush x-netns xfrm cache when vti interface is removed gro: Allow tunnel stacking in the case of FOU/GUE brcmfmac: Fix glom_skb leak in brcmf_sdiod_recv_chain l2tp: hold socket before dropping lock in l2tp_ip{, 6}_recv() tty: serial: sprd: fix error return code in sprd_probe() video: fbdev: pxa3xx_gcu: fix error return code in pxa3xx_gcu_probe() sparc64 mm: Fix more TSB sizing issues gpu: host1x: fix error return code in host1x_probe() sparc64: Fix exception handling in UltraSPARC-III memcpy. gpio: msic: fix error return code in platform_msic_gpio_probe() usb: imx21-hcd: fix error return code in imx21_probe() usb: ehci-omap: fix error return code in ehci_hcd_omap_probe() usb: dwc3: omap: fix error return code in dwc3_omap_probe() spi/bcm63xx-hspi: fix error return code in bcm63xx_hsspi_probe() MIPS: Handle non word sized instructions when examining frame spi/bcm63xx: fix error return code in bcm63xx_spi_probe() spi: xlp: fix error return code in xlp_spi_probe() ASoC: spear: fix error return code in spdif_in_probe() PM / devfreq: tegra: fix error return code in tegra_devfreq_probe() bonding: avoid defaulting hard_header_len to ETH_HLEN on slave removal scsi: aacraid: Fix typo in blink status MIPS: microMIPS: Fix decoding of swsp16 instruction igb: Remove superfluous reset to PHY and page 0 selection MIPS: DEC: Fix an int-handler.S CPU_DADDI_WORKAROUNDS regression ARM: dts: imx53-qsb: disable 1.2GHz OPP fs/fat/fatent.c: add cond_resched() to fat_count_free_clusters() mtd: spi-nor: Add support for is25wp series chips perf tools: Disable parallelism for 'make clean' bridge: do not add port to router list when receives query with source 0.0.0.0 net: bridge: remove ipv6 zero address check in mcast queries ipv6: mcast: fix a use-after-free in inet6_mc_check ipv6/ndisc: Preserve IPv6 control buffer if protocol error handlers are called net/ipv6: Fix index counter for unicast addresses in in6_dump_addrs net: sched: gred: pass the right attribute to gred_change_table_def() net: socket: fix a missing-check bug net: stmmac: Fix stmmac_mdio_reset() when building stmmac as modules r8169: fix NAPI handling under high load sctp: fix race on sctp_id2asoc net: drop skb on failure in ip_check_defrag() vhost: Fix Spectre V1 vulnerability rtnetlink: Disallow FDB configuration for non-Ethernet device mremap: properly flush TLB before releasing the page crypto: shash - Fix a sleep-in-atomic bug in shash_setkey_unaligned ahci: don't ignore result code of ahci_reset_controller() cachefiles: fix the race between cachefiles_bury_object() and rmdir(2) ptp: fix Spectre v1 vulnerability RDMA/ucma: Fix Spectre v1 vulnerability IB/ucm: Fix Spectre v1 vulnerability cdc-acm: correct counting of UART states in serial state notification usb: gadget: storage: Fix Spectre v1 vulnerability USB: fix the usbfs flag sanitization for control transfers Input: elan_i2c - add ACPI ID for Lenovo IdeaPad 330-15IGM sched/fair: Fix throttle_list starvation with low CFS quota x86/percpu: Fix this_cpu_read() cpuidle: Do not access cpuidle_devices when !CONFIG_CPU_IDLE l2tp: hold tunnel socket when handling control frames in l2tp_ip and l2tp_ip6 x86/time: Correct the attribute on jiffies' definition Linux 4.4.163 Change-Id: Idb0efd175853886145a1fb7eaaf18797c39e5f6f Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2018-11-10cpuidle: Do not access cpuidle_devices when !CONFIG_CPU_IDLECatalin Marinas
commit 9bd616e3dbedfc103f158197c8ad93678849b1ed upstream. The cpuidle_devices per-CPU variable is only defined when CPU_IDLE is enabled. Commit c8cc7d4de7a4 ("sched/idle: Reorganize the idle loop") removed the #ifdef CONFIG_CPU_IDLE around cpuidle_idle_call() with the compiler optimising away __this_cpu_read(cpuidle_devices). However, with CONFIG_UBSAN && !CONFIG_CPU_IDLE, this optimisation no longer happens and the kernel fails to link since cpuidle_devices is not defined. This patch introduces an accessor function for the current CPU cpuidle device (returning NULL when !CONFIG_CPU_IDLE) and uses it in cpuidle_idle_call(). Signed-off-by: Catalin Marinas <catalin.marinas@arm.com> Cc: 4.5+ <stable@vger.kernel.org> # 4.5+ Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Cc: Guenter Roeck <linux@roeck-us.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-11-10sched/fair: Fix throttle_list starvation with low CFS quotaPhil Auld
commit baa9be4ffb55876923dc9716abc0a448e510ba30 upstream. With a very low cpu.cfs_quota_us setting, such as the minimum of 1000, distribute_cfs_runtime may not empty the throttled_list before it runs out of runtime to distribute. In that case, due to the change from c06f04c7048 to put throttled entries at the head of the list, later entries on the list will starve. Essentially, the same X processes will get pulled off the list, given CPU time and then, when expired, get put back on the head of the list where distribute_cfs_runtime will give runtime to the same set of processes leaving the rest. Fix the issue by setting a bit in struct cfs_bandwidth when distribute_cfs_runtime is running, so that the code in throttle_cfs_rq can decide to put the throttled entry on the tail or the head of the list. The bit is set/cleared by the callers of distribute_cfs_runtime while they hold cfs_bandwidth->lock. This is easy to reproduce with a handful of CPU consumers. I use 'crash' on the live system. In some cases you can simply look at the throttled list and see the later entries are not changing: crash> list cfs_rq.throttled_list -H 0xffff90b54f6ade40 -s cfs_rq.runtime_remaining | paste - - | awk '{print $1" "$4}' | pr -t -n3 1 ffff90b56cb2d200 -976050 2 ffff90b56cb2cc00 -484925 3 ffff90b56cb2bc00 -658814 4 ffff90b56cb2ba00 -275365 5 ffff90b166a45600 -135138 6 ffff90b56cb2da00 -282505 7 ffff90b56cb2e000 -148065 8 ffff90b56cb2fa00 -872591 9 ffff90b56cb2c000 -84687 10 ffff90b56cb2f000 -87237 11 ffff90b166a40a00 -164582 crash> list cfs_rq.throttled_list -H 0xffff90b54f6ade40 -s cfs_rq.runtime_remaining | paste - - | awk '{print $1" "$4}' | pr -t -n3 1 ffff90b56cb2d200 -994147 2 ffff90b56cb2cc00 -306051 3 ffff90b56cb2bc00 -961321 4 ffff90b56cb2ba00 -24490 5 ffff90b166a45600 -135138 6 ffff90b56cb2da00 -282505 7 ffff90b56cb2e000 -148065 8 ffff90b56cb2fa00 -872591 9 ffff90b56cb2c000 -84687 10 ffff90b56cb2f000 -87237 11 ffff90b166a40a00 -164582 Sometimes it is easier to see by finding a process getting starved and looking at the sched_info: crash> task ffff8eb765994500 sched_info PID: 7800 TASK: ffff8eb765994500 CPU: 16 COMMAND: "cputest" sched_info = { pcount = 8, run_delay = 697094208, last_arrival = 240260125039, last_queued = 240260327513 }, crash> task ffff8eb765994500 sched_info PID: 7800 TASK: ffff8eb765994500 CPU: 16 COMMAND: "cputest" sched_info = { pcount = 8, run_delay = 697094208, last_arrival = 240260125039, last_queued = 240260327513 }, Signed-off-by: Phil Auld <pauld@redhat.com> Reviewed-by: Ben Segall <bsegall@google.com> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: stable@vger.kernel.org Fixes: c06f04c70489 ("sched: Fix potential near-infinite distribute_cfs_runtime() loop") Link: http://lkml.kernel.org/r/20181008143639.GA4019@pauld.bos.csb Signed-off-by: Ingo Molnar <mingo@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-11-10bpf: generally move prog destruction to RCU deferralDaniel Borkmann
[ Upstream commit 1aacde3d22c42281236155c1ef6d7a5aa32a826b ] Jann Horn reported following analysis that could potentially result in a very hard to trigger (if not impossible) UAF race, to quote his event timeline: - Set up a process with threads T1, T2 and T3 - Let T1 set up a socket filter F1 that invokes another filter F2 through a BPF map [tail call] - Let T1 trigger the socket filter via a unix domain socket write, don't wait for completion - Let T2 call PERF_EVENT_IOC_SET_BPF with F2, don't wait for completion - Now T2 should be behind bpf_prog_get(), but before bpf_prog_put() - Let T3 close the file descriptor for F2, dropping the reference count of F2 to 2 - At this point, T1 should have looked up F2 from the map, but not finished executing it - Let T3 remove F2 from the BPF map, dropping the reference count of F2 to 1 - Now T2 should call bpf_prog_put() (wrong BPF program type), dropping the reference count of F2 to 0 and scheduling bpf_prog_free_deferred() via schedule_work() - At this point, the BPF program could be freed - BPF execution is still running in a freed BPF program While at PERF_EVENT_IOC_SET_BPF time it's only guaranteed that the perf event fd we're doing the syscall on doesn't disappear from underneath us for whole syscall time, it may not be the case for the bpf fd used as an argument only after we did the put. It needs to be a valid fd pointing to a BPF program at the time of the call to make the bpf_prog_get() and while T2 gets preempted, F2 must have dropped reference to 1 on the other CPU. The fput() from the close() in T3 should also add additionally delay to the reference drop via exit_task_work() when bpf_prog_release() gets called as well as scheduling bpf_prog_free_deferred(). That said, it makes nevertheless sense to move the BPF prog destruction generally after RCU grace period to guarantee that such scenario above, but also others as recently fixed in ceb56070359b ("bpf, perf: delay release of BPF prog after grace period") with regards to tail calls won't happen. Integrating bpf_prog_free_deferred() directly into the RCU callback is not allowed since the invocation might happen from either softirq or process context, so we're not permitted to block. Reviewing all bpf_prog_put() invocations from eBPF side (note, cBPF -> eBPF progs don't use this for their destruction) with call_rcu() look good to me. Since we don't know whether at the time of attaching the program, we're already part of a tail call map, we need to use RCU variant. However, due to this, there won't be severely more stress on the RCU callback queue: situations with above bpf_prog_get() and bpf_prog_put() combo in practice normally won't lead to releases, but even if they would, enough effort/ cycles have to be put into loading a BPF program into the kernel already. Reported-by: Jann Horn <jannh@google.com> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net> Acked-by: Alexei Starovoitov <ast@kernel.org> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Sasha Levin <sashal@kernel.org>
2018-11-10perf/core: Don't leak event in the syscall error pathAlexander Shishkin
[ Upstream commit 201c2f85bd0bc13b712d9c0b3d11251b182e06ae ] In the error path, event_file not being NULL is used to determine whether the event itself still needs to be free'd, so fix it up to avoid leaking. Reported-by: Leon Yu <chianglungyu@gmail.com> Signed-off-by: Alexander Shishkin <alexander.shishkin@linux.intel.com> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Cc: Arnaldo Carvalho de Melo <acme@kernel.org> Cc: Arnaldo Carvalho de Melo <acme@redhat.com> Cc: Jiri Olsa <jolsa@redhat.com> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Stephane Eranian <eranian@google.com> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: Vince Weaver <vincent.weaver@maine.edu> Fixes: 130056275ade ("perf: Do not double free") Link: http://lkml.kernel.org/r/87twk06yxp.fsf@ashishki-desk.ger.corp.intel.com Signed-off-by: Ingo Molnar <mingo@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
2018-11-10sched/cgroup: Fix cgroup entity load tracking tear-downPeter Zijlstra
[ Upstream commit 6fe1f348b3dd1f700f9630562b7d38afd6949568 ] When a cgroup's CPU runqueue is destroyed, it should remove its remaining load accounting from its parent cgroup. The current site for doing so it unsuited because its far too late and unordered against other cgroup removal (->css_free() will be, but we're also in an RCU callback). Put it in the ->css_offline() callback, which is the start of cgroup destruction, right after the group has been made unavailable to userspace. The ->css_offline() callbacks are called in hierarchical order after the following v4.4 commit: aa226ff4a1ce ("cgroup: make sure a parent css isn't offlined before its children") Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Cc: Christian Borntraeger <borntraeger@de.ibm.com> Cc: Johannes Weiner <hannes@cmpxchg.org> Cc: Li Zefan <lizefan@huawei.com> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Oleg Nesterov <oleg@redhat.com> Cc: Paul E. McKenney <paulmck@linux.vnet.ibm.com> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Tejun Heo <tj@kernel.org> Cc: Thomas Gleixner <tglx@linutronix.de> Link: http://lkml.kernel.org/r/20160121212416.GL6357@twins.programming.kicks-ass.net Signed-off-by: Ingo Molnar <mingo@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
2018-11-10tracing: Skip more functions when doing stack tracing of eventsSteven Rostedt (Red Hat)
[ Upstream commit be54f69c26193de31053190761e521903b89d098 ] # echo 1 > options/stacktrace # echo 1 > events/sched/sched_switch/enable # cat trace <idle>-0 [002] d..2 1982.525169: <stack trace> => save_stack_trace => __ftrace_trace_stack => trace_buffer_unlock_commit_regs => event_trigger_unlock_commit => trace_event_buffer_commit => trace_event_raw_event_sched_switch => __schedule => schedule => schedule_preempt_disabled => cpu_startup_entry => start_secondary The above shows that we are seeing 6 functions before ever making it to the caller of the sched_switch event. # echo stacktrace > events/sched/sched_switch/trigger # cat trace <idle>-0 [002] d..3 2146.335208: <stack trace> => trace_event_buffer_commit => trace_event_raw_event_sched_switch => __schedule => schedule => schedule_preempt_disabled => cpu_startup_entry => start_secondary The stacktrace trigger isn't as bad, because it adds its own skip to the stacktracing, but still has two events extra. One issue is that if the stacktrace passes its own "regs" then there should be no addition to the skip, as the regs will not include the functions being called. This was an issue that was fixed by commit 7717c6be6999 ("tracing: Fix stacktrace skip depth in trace_buffer_unlock_commit_regs()" as adding the skip number for kprobes made the probes not have any stack at all. But since this is only an issue when regs is being used, a skip should be added if regs is NULL. Now we have: # echo 1 > options/stacktrace # echo 1 > events/sched/sched_switch/enable # cat trace <idle>-0 [000] d..2 1297.676333: <stack trace> => __schedule => schedule => schedule_preempt_disabled => cpu_startup_entry => rest_init => start_kernel => x86_64_start_reservations => x86_64_start_kernel # echo stacktrace > events/sched/sched_switch/trigger # cat trace <idle>-0 [002] d..3 1370.759745: <stack trace> => __schedule => schedule => schedule_preempt_disabled => cpu_startup_entry => start_secondary And kprobes are not touched. Reported-by: Peter Zijlstra <peterz@infradead.org> Signed-off-by: Steven Rostedt <rostedt@goodmis.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
2018-11-10perf/ring_buffer: Prevent concurent ring buffer accessJiri Olsa
[ Upstream commit cd6fb677ce7e460c25bdd66f689734102ec7d642 ] Some of the scheduling tracepoints allow the perf_tp_event code to write to ring buffer under different cpu than the code is running on. This results in corrupted ring buffer data demonstrated in following perf commands: # perf record -e 'sched:sched_switch,sched:sched_wakeup' perf bench sched messaging # Running 'sched/messaging' benchmark: # 20 sender and receiver processes per group # 10 groups == 400 processes run Total time: 0.383 [sec] [ perf record: Woken up 8 times to write data ] 0x42b890 [0]: failed to process type: -1765585640 [ perf record: Captured and wrote 4.825 MB perf.data (29669 samples) ] # perf report --stdio 0x42b890 [0]: failed to process type: -1765585640 The reason for the corruption are some of the scheduling tracepoints, that have __perf_task dfined and thus allow to store data to another cpu ring buffer: sched_waking sched_wakeup sched_wakeup_new sched_stat_wait sched_stat_sleep sched_stat_iowait sched_stat_blocked The perf_tp_event function first store samples for current cpu related events defined for tracepoint: hlist_for_each_entry_rcu(event, head, hlist_entry) perf_swevent_event(event, count, &data, regs); And then iterates events of the 'task' and store the sample for any task's event that passes tracepoint checks: ctx = rcu_dereference(task->perf_event_ctxp[perf_sw_context]); list_for_each_entry_rcu(event, &ctx->event_list, event_entry) { if (event->attr.type != PERF_TYPE_TRACEPOINT) continue; if (event->attr.config != entry->type) continue; perf_swevent_event(event, count, &data, regs); } Above code can race with same code running on another cpu, ending up with 2 cpus trying to store under the same ring buffer, which is specifically not allowed. This patch prevents the problem, by allowing only events with the same current cpu to receive the event. NOTE: this requires the use of (per-task-)per-cpu buffers for this feature to work; perf-record does this. Signed-off-by: Jiri Olsa <jolsa@kernel.org> [peterz: small edits to Changelog] Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com> Cc: Andrew Vagin <avagin@openvz.org> Cc: Arnaldo Carvalho de Melo <acme@kernel.org> Cc: Arnaldo Carvalho de Melo <acme@redhat.com> Cc: Jiri Olsa <jolsa@redhat.com> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Stephane Eranian <eranian@google.com> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: Vince Weaver <vincent.weaver@maine.edu> Fixes: e6dab5ffab59 ("perf/trace: Add ability to set a target task for events") Link: http://lkml.kernel.org/r/20180923161343.GB15054@krava Signed-off-by: Ingo Molnar <mingo@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
2018-10-13Merge 4.4.161 into android-4.4Greg Kroah-Hartman
Changes in 4.4.161 mm/vmstat.c: skip NR_TLB_REMOTE_FLUSH* properly fbdev/omapfb: fix omapfb_memory_read infoleak x86/vdso: Fix asm constraints on vDSO syscall fallbacks x86/vdso: Fix vDSO syscall fallback asm constraint regression PCI: Reprogram bridge prefetch registers on resume mac80211: fix setting IEEE80211_KEY_FLAG_RX_MGMT for AP mode keys PM / core: Clear the direct_complete flag on errors dm cache: fix resize crash if user doesn't reload cache table xhci: Add missing CAS workaround for Intel Sunrise Point xHCI USB: serial: simple: add Motorola Tetra MTP6550 id of: unittest: Disable interrupt node tests for old world MAC systems ext4: always verify the magic number in xattr blocks cgroup: Fix deadlock in cpu hotplug path ath10k: fix use-after-free in ath10k_wmi_cmd_send_nowait powerpc/fadump: Return error when fadump registration fails ARC: clone syscall to setp r25 as thread pointer ucma: fix a use-after-free in ucma_resolve_ip() ubifs: Check for name being NULL while mounting tcp: increment sk_drops for dropped rx packets tcp: use an RB tree for ooo receive queue tcp: fix a stale ooo_last_skb after a replace tcp: free batches of packets in tcp_prune_ofo_queue() tcp: call tcp_drop() from tcp_data_queue_ofo() tcp: add tcp_ooo_try_coalesce() helper ath10k: fix scan crash due to incorrect length calculation ebtables: arpreply: Add the standard target sanity check Linux 4.4.161 Change-Id: I4c6607d0be0977857f966b048279590470c854c2 Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2018-10-13cgroup: Fix deadlock in cpu hotplug pathPrateek Sood
commit 116d2f7496c51b2e02e8e4ecdd2bdf5fb9d5a641 upstream. Deadlock during cgroup migration from cpu hotplug path when a task T is being moved from source to destination cgroup. kworker/0:0 cpuset_hotplug_workfn() cpuset_hotplug_update_tasks() hotplug_update_tasks_legacy() remove_tasks_in_empty_cpuset() cgroup_transfer_tasks() // stuck in iterator loop cgroup_migrate() cgroup_migrate_add_task() In cgroup_migrate_add_task() it checks for PF_EXITING flag of task T. Task T will not migrate to destination cgroup. css_task_iter_start() will keep pointing to task T in loop waiting for task T cg_list node to be removed. Task T do_exit() exit_signals() // sets PF_EXITING exit_task_namespaces() switch_task_namespaces() free_nsproxy() put_mnt_ns() drop_collected_mounts() namespace_unlock() synchronize_rcu() _synchronize_rcu_expedited() schedule_work() // on cpu0 low priority worker pool wait_event() // waiting for work item to execute Task T inserted a work item in the worklist of cpu0 low priority worker pool. It is waiting for expedited grace period work item to execute. This work item will only be executed once kworker/0:0 complete execution of cpuset_hotplug_workfn(). kworker/0:0 ==> Task T ==>kworker/0:0 In case of PF_EXITING task being migrated from source to destination cgroup, migrate next available task in source cgroup. Signed-off-by: Prateek Sood <prsood@codeaurora.org> Signed-off-by: Tejun Heo <tj@kernel.org> [AmitP: Upstream commit cherry-pick failed, so I picked the backported changes from CAF/msm-4.9 tree instead: https://source.codeaurora.org/quic/la/kernel/msm-4.9/commit/?id=49b74f1696417b270c89cd893ca9f37088928078] Signed-off-by: Amit Pundir <amit.pundir@linaro.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-10-10Merge 4.4.160 into android-4.4Greg Kroah-Hartman
Changes in 4.4.160 crypto: skcipher - Fix -Wstringop-truncation warnings tsl2550: fix lux1_input error in low light vmci: type promotion bug in qp_host_get_user_memory() x86/numa_emulation: Fix emulated-to-physical node mapping staging: rts5208: fix missing error check on call to rtsx_write_register uwb: hwa-rc: fix memory leak at probe power: vexpress: fix corruption in notifier registration Bluetooth: Add a new Realtek 8723DE ID 0bda:b009 USB: serial: kobil_sct: fix modem-status error handling 6lowpan: iphc: reset mac_header after decompress to fix panic md-cluster: clear another node's suspend_area after the copy is finished media: exynos4-is: Prevent NULL pointer dereference in __isp_video_try_fmt() powerpc/kdump: Handle crashkernel memory reservation failure media: fsl-viu: fix error handling in viu_of_probe() x86/tsc: Add missing header to tsc_msr.c x86/entry/64: Add two more instruction suffixes scsi: target/iscsi: Make iscsit_ta_authentication() respect the output buffer size scsi: klist: Make it safe to use klists in atomic context scsi: ibmvscsi: Improve strings handling usb: wusbcore: security: cast sizeof to int for comparison powerpc/powernv/ioda2: Reduce upper limit for DMA window size alarmtimer: Prevent overflow for relative nanosleep s390/extmem: fix gcc 8 stringop-overflow warning ALSA: snd-aoa: add of_node_put() in error path media: s3c-camif: ignore -ENOIOCTLCMD from v4l2_subdev_call for s_power media: soc_camera: ov772x: correct setting of banding filter media: omap3isp: zero-initialize the isp cam_xclk{a,b} initial data staging: android: ashmem: Fix mmap size validation drivers/tty: add error handling for pcmcia_loop_config media: tm6000: add error handling for dvb_register_adapter ALSA: hda: Add AZX_DCAPS_PM_RUNTIME for AMD Raven Ridge ath10k: protect ath10k_htt_rx_ring_free with rx_ring.lock rndis_wlan: potential buffer overflow in rndis_wlan_auth_indication() wlcore: Add missing PM call for wlcore_cmd_wait_for_event_or_timeout() ARM: mvebu: declare asm symbols as character arrays in pmsu.c HID: hid-ntrig: add error handling for sysfs_create_group scsi: bnx2i: add error handling for ioremap_nocache EDAC, i7core: Fix memleaks and use-after-free on probe and remove ASoC: dapm: Fix potential DAI widget pointer deref when linking DAIs module: exclude SHN_UNDEF symbols from kallsyms api nfsd: fix corrupted reply to badly ordered compound ARM: dts: dra7: fix DCAN node addresses floppy: Do not copy a kernel pointer to user memory in FDGETPRM ioctl serial: cpm_uart: return immediately from console poll spi: tegra20-slink: explicitly enable/disable clock spi: sh-msiof: Fix invalid SPI use during system suspend spi: sh-msiof: Fix handling of write value for SISTR register spi: rspi: Fix invalid SPI use during system suspend spi: rspi: Fix interrupted DMA transfers USB: fix error handling in usb_driver_claim_interface() USB: handle NULL config in usb_find_alt_setting() slub: make ->cpu_partial unsigned int media: uvcvideo: Support realtek's UVC 1.5 device USB: usbdevfs: sanitize flags more USB: usbdevfs: restore warning for nonsensical flags Revert "usb: cdc-wdm: Fix a sleep-in-atomic-context bug in service_outstanding_interrupt()" USB: remove LPM management from usb_driver_claim_interface() Input: elantech - enable middle button of touchpad on ThinkPad P72 IB/srp: Avoid that sg_reset -d ${srp_device} triggers an infinite loop scsi: target: iscsi: Use bin2hex instead of a re-implementation serial: imx: restore handshaking irq for imx1 arm64: KVM: Tighten guest core register access from userspace ext4: never move the system.data xattr out of the inode body thermal: of-thermal: disable passive polling when thermal zone is disabled net: hns: fix length and page_offset overflow when CONFIG_ARM64_64K_PAGES e1000: check on netif_running() before calling e1000_up() e1000: ensure to free old tx/rx rings in set_ringparam() hwmon: (ina2xx) fix sysfs shunt resistor read access hwmon: (adt7475) Make adt7475_read_word() return errors i2c: i801: Allow ACPI AML access I/O ports not reserved for SMBus arm64: cpufeature: Track 32bit EL0 support arm64: KVM: Sanitize PSTATE.M when being set from userspace media: v4l: event: Prevent freeing event subscriptions while accessed KVM: PPC: Book3S HV: Don't truncate HPTE index in xlate function mac80211: correct use of IEEE80211_VHT_CAP_RXSTBC_X mac80211_hwsim: correct use of IEEE80211_VHT_CAP_RXSTBC_X gpio: adp5588: Fix sleep-in-atomic-context bug mac80211: mesh: fix HWMP sequence numbering to follow standard cfg80211: nl80211_update_ft_ies() to validate NL80211_ATTR_IE RAID10 BUG_ON in raise_barrier when force is true and conf->barrier is 0 i2c: uniphier: issue STOP only for last message or I2C_M_STOP i2c: uniphier-f: issue STOP only for last message or I2C_M_STOP net: cadence: Fix a sleep-in-atomic-context bug in macb_halt_tx() fs/cifs: don't translate SFM_SLASH (U+F026) to backslash cfg80211: fix a type issue in ieee80211_chandef_to_operating_class() mac80211: fix a race between restart and CSA flows mac80211: Fix station bandwidth setting after channel switch mac80211: shorten the IBSS debug messages tools/vm/slabinfo.c: fix sign-compare warning tools/vm/page-types.c: fix "defined but not used" warning mm: madvise(MADV_DODUMP): allow hugetlbfs pages usb: gadget: fotg210-udc: Fix memory leak of fotg210->ep[i] perf probe powerpc: Ignore SyS symbols irrespective of endianness RDMA/ucma: check fd type in ucma_migrate_id() USB: yurex: Check for truncation in yurex_read() drm/nouveau/TBDdevinit: don't fail when PMU/PRE_OS is missing from VBIOS fs/cifs: suppress a string overflow warning dm thin metadata: try to avoid ever aborting transactions arch/hexagon: fix kernel/dma.c build warning hexagon: modify ffs() and fls() to return int arm64: jump_label.h: use asm_volatile_goto macro instead of "asm goto" r8169: Clear RTL_FLAG_TASK_*_PENDING when clearing RTL_FLAG_TASK_ENABLED s390/qeth: don't dump past end of unknown HW header cifs: read overflow in is_valid_oplock_break() xen/manage: don't complain about an empty value in control/sysrq node xen: avoid crash in disable_hotplug_cpu xen: fix GCC warning and remove duplicate EVTCHN_ROW/EVTCHN_COL usage smb2: fix missing files in root share directory listing ALSA: hda/realtek - Cannot adjust speaker's volume on Dell XPS 27 7760 crypto: mxs-dcp - Fix wait logic on chan threads proc: restrict kernel stack dumps to root ocfs2: fix locking for res->tracking and dlm->tracking_list dm thin metadata: fix __udivdi3 undefined on 32-bit Linux 4.4.160 Change-Id: I54d72945f741d6b4442adcd7bc18cb5417accb0f Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2018-10-10module: exclude SHN_UNDEF symbols from kallsyms apiJessica Yu
[ Upstream commit 9f2d1e68cf4d641def734adaccfc3823d3575e6c ] Livepatch modules are special in that we preserve their entire symbol tables in order to be able to apply relocations after module load. The unwanted side effect of this is that undefined (SHN_UNDEF) symbols of livepatch modules are accessible via the kallsyms api and this can confuse symbol resolution in livepatch (klp_find_object_symbol()) and cause subtle bugs in livepatch. Have the module kallsyms api skip over SHN_UNDEF symbols. These symbols are usually not available for normal modules anyway as we cut down their symbol tables to just the core (non-undefined) symbols, so this should really just affect livepatch modules. Note that this patch doesn't affect the display of undefined symbols in /proc/kallsyms. Reported-by: Josh Poimboeuf <jpoimboe@redhat.com> Tested-by: Josh Poimboeuf <jpoimboe@redhat.com> Reviewed-by: Josh Poimboeuf <jpoimboe@redhat.com> Signed-off-by: Jessica Yu <jeyu@kernel.org> Signed-off-by: Sasha Levin <alexander.levin@microsoft.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-10-10alarmtimer: Prevent overflow for relative nanosleepThomas Gleixner
[ Upstream commit 5f936e19cc0ef97dbe3a56e9498922ad5ba1edef ] Air Icy reported: UBSAN: Undefined behaviour in kernel/time/alarmtimer.c:811:7 signed integer overflow: 1529859276030040771 + 9223372036854775807 cannot be represented in type 'long long int' Call Trace: alarm_timer_nsleep+0x44c/0x510 kernel/time/alarmtimer.c:811 __do_sys_clock_nanosleep kernel/time/posix-timers.c:1235 [inline] __se_sys_clock_nanosleep kernel/time/posix-timers.c:1213 [inline] __x64_sys_clock_nanosleep+0x326/0x4e0 kernel/time/posix-timers.c:1213 do_syscall_64+0xb8/0x3a0 arch/x86/entry/common.c:290 alarm_timer_nsleep() uses ktime_add() to add the current time and the relative expiry value. ktime_add() has no sanity checks so the addition can overflow when the relative timeout is large enough. Use ktime_add_safe() which has the necessary sanity checks in place and limits the result to the valid range. Fixes: 9a7adcf5c6de ("timers: Posix interface for alarm-timers") Reported-by: Team OWL337 <icytxw@gmail.com> Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Cc: John Stultz <john.stultz@linaro.org> Link: https://lkml.kernel.org/r/alpine.DEB.2.21.1807020926360.1595@nanos.tec.linutronix.de Signed-off-by: Sasha Levin <alexander.levin@microsoft.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-09-29Merge 4.4.159 into android-4.4Greg Kroah-Hartman
Changes in 4.4.159 NFC: Fix possible memory corruption when handling SHDLC I-Frame commands NFC: Fix the number of pipes ASoC: cs4265: fix MMTLR Data switch control ALSA: bebob: use address returned by kmalloc() instead of kernel stack for streaming DMA mapping ALSA: emu10k1: fix possible info leak to userspace on SNDRV_EMU10K1_IOCTL_INFO platform/x86: alienware-wmi: Correct a memory leak xen/netfront: don't bug in case of too many frags xen/x86/vpmu: Zero struct pt_regs before calling into sample handling code ring-buffer: Allow for rescheduling when removing pages mm: shmem.c: Correctly annotate new inodes for lockdep gso_segment: Reset skb->mac_len after modifying network header ipv6: fix possible use-after-free in ip6_xmit() net/appletalk: fix minor pointer leak to userspace in SIOCFINDIPDDPRT net: hp100: fix always-true check for link up state neighbour: confirm neigh entries when ARP packet is received scsi: target: iscsi: Use hex2bin instead of a re-implementation ocfs2: fix ocfs2 read block panic drm/nouveau/drm/nouveau: Use pm_runtime_get_noresume() in connector_detect() tty: vt_ioctl: fix potential Spectre v1 ext4: avoid divide by zero fault when deleting corrupted inline directories ext4: recalucate superblock checksum after updating free blocks/inodes ext4: fix online resize's handling of a too-small final block group ext4: fix online resizing for bigalloc file systems with a 1k block size ext4: don't mark mmp buffer head dirty arm64: Add trace_hardirqs_off annotation in ret_to_user HID: sony: Update device ids HID: sony: Support DS4 dongle iw_cxgb4: only allow 1 flush on user qps Linux 4.4.159 Change-Id: I98239ca60783ca69147f2f11034138fc22e2af65 Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>