985 Commits

Author SHA1 Message Date
Michael Bestas
bbea1101c3 Merge tag 'v4.4.258' into android-msm-wahoo-4.4
This is the 4.4.258 stable release

# gpg: Signature made Tue Feb 23 14:58:32 2021 EET
# gpg:                using RSA key 647F28654894E3BD457199BE38DBBDC86092693E
# gpg: Good signature from "Greg Kroah-Hartman <gregkh@kernel.org>" [full]
# gpg: gregkh@kernel.org: Verified 9 signatures in the past 2 hours.  Encrypted
#      0 messages.

# By Jan Beulich (8) and others
# Via Greg Kroah-Hartman
* tag 'v4.4.258':
  Linux 4.4.258
  kvm: check tlbs_dirty directly
  scsi: qla2xxx: Fix crash during driver load on big endian machines
  xen-blkback: fix error handling in xen_blkbk_map()
  xen-scsiback: don't "handle" error by BUG()
  xen-netback: don't "handle" error by BUG()
  xen-blkback: don't "handle" error by BUG()
  xen/arm: don't ignore return errors from set_phys_to_machine
  Xen/gntdev: correct error checking in gntdev_map_grant_pages()
  Xen/gntdev: correct dev_bus_addr handling in gntdev_map_grant_pages()
  Xen/x86: also check kernel mapping in set_foreign_p2m_mapping()
  Xen/x86: don't bail early from clear_foreign_p2m_mapping()
  tracing: Avoid calling cc-option -mrecord-mcount for every Makefile
  tracing: Fix SKIP_STACK_VALIDATION=1 build due to bad merge with -mrecord-mcount
  trace: Use -mcount-record for dynamic ftrace
  x86/build: Disable CET instrumentation in the kernel for 32-bit too
  vsock: fix locking in vsock_shutdown()
  net: watchdog: hold device global xmit lock during tx disable
  usb: dwc3: ulpi: Replace CPU-based busyloop with Protocol-based one
  usb: dwc3: ulpi: fix checkpatch warning
  h8300: fix PREEMPTION build, TI_PRE_COUNT undefined
  netfilter: xt_recent: Fix attempt to update deleted entry
  memblock: do not start bottom-up allocations with kernel_end
  squashfs: add more sanity checks in xattr id lookup
  squashfs: add more sanity checks in inode lookup
  squashfs: add more sanity checks in id lookup
  memcg: fix a crash in wb_workfn when a device disappears
  include/trace/events/writeback.h: fix -Wstringop-truncation warnings
  lib/string: Add strscpy_pad() function
  SUNRPC: Handle 0 length opaque XDR object data properly
  SUNRPC: Move simple_get_bytes and simple_get_netobj into private header
  iwlwifi: mvm: guard against device removal in reprobe
  iwlwifi: pcie: add a NULL check in iwl_pcie_txq_unmap
  af_key: relax availability checks for skb size calculation
  fgraph: Initialize tracing_graph_pause at task creation
  tracing: Do not count ftrace events in top level enable output

Change-Id: I1b31d727428550a5170b62cd709d4ee850f0b66d
2021-07-24 19:19:00 +03:00
Lai Jiangshan
4230401d22 kvm: check tlbs_dirty directly
commit 88bf56d04bc3564542049ec4ec168a8b60d0b48c upstream

In kvm_mmu_notifier_invalidate_range_start(), tlbs_dirty is used as:
        need_tlb_flush |= kvm->tlbs_dirty;
with need_tlb_flush's type being int and tlbs_dirty's type being long.

It means that tlbs_dirty is always used as int and the higher 32 bits
is useless.  We need to check tlbs_dirty in a correct way and this
change checks it directly without propagating it to need_tlb_flush.

Note: it's _extremely_ unlikely this neglecting of higher 32 bits can
cause problems in practice.  It would require encountering tlbs_dirty
on a 4 billion count boundary, and KVM would need to be using shadow
paging or be running a nested guest.

Cc: stable@vger.kernel.org
Fixes: a4ee1ca4a3 ("KVM: MMU: delay flush all tlbs on sync_page path")
Signed-off-by: Lai Jiangshan <laijs@linux.alibaba.com>
Message-Id: <20201217154118.16497-1-jiangshanlai@gmail.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
[sudip: adjust context]
Signed-off-by: Sudip Mukherjee <sudipm.mukherjee@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-02-23 13:58:14 +01:00
Nathan Chancellor
44902e73a4 Merge 4.4.238 into android-msm-wahoo-4.4
Changes in 4.4.238: (86 commits)
        af_key: pfkey_dump needs parameter validation
        KVM: fix memory leak in kvm_io_bus_unregister_dev()
        kprobes: fix kill kprobe which has been marked as gone
        ftrace: Setup correct FTRACE_FL_REGS flags for module
        RDMA/ucma: ucma_context reference leak in error path
        mtd: Fix comparison in map_word_andequal()
        hdlc_ppp: add range checks in ppp_cp_parse_cr()
        tipc: use skb_unshare() instead in tipc_buf_append()
        net: add __must_check to skb_put_padto()
        ip: fix tos reflection in ack and reset packets
        serial: 8250: Avoid error message on reprobe
        scsi: aacraid: fix illegal IO beyond last LBA
        m68k: q40: Fix info-leak in rtc_ioctl
        gma/gma500: fix a memory disclosure bug due to uninitialized bytes
        ASoC: kirkwood: fix IRQ error handling
        PM / devfreq: tegra30: Fix integer overflow on CPU's freq max out
        mtd: cfi_cmdset_0002: don't free cfi->cfiq in error path of cfi_amdstd_setup()
        mfd: mfd-core: Protect against NULL call-back function pointer
        tracing: Adding NULL checks for trace_array descriptor pointer
        bcache: fix a lost wake-up problem caused by mca_cannibalize_lock
        xfs: fix attr leaf header freemap.size underflow
        kernel/sys.c: avoid copying possible padding bytes in copy_to_user
        neigh_stat_seq_next() should increase position index
        rt_cpu_seq_next should increase position index
        seqlock: Require WRITE_ONCE surrounding raw_seqcount_barrier
        ACPI: EC: Reference count query handlers under lock
        tracing: Set kernel_stack's caller size properly
        ar5523: Add USB ID of SMCWUSBT-G2 wireless adapter
        Bluetooth: Fix refcount use-after-free issue
        mm: pagewalk: fix termination condition in walk_pte_range()
        Bluetooth: prefetch channel before killing sock
        skbuff: fix a data race in skb_queue_len()
        audit: CONFIG_CHANGE don't log internal bookkeeping as an event
        selinux: sel_avc_get_stat_idx should increase position index
        scsi: lpfc: Fix RQ buffer leakage when no IOCBs available
        drm/omap: fix possible object reference leak
        dmaengine: tegra-apb: Prevent race conditions on channel's freeing
        media: go7007: Fix URB type for interrupt handling
        Bluetooth: guard against controllers sending zero'd events
        drm/amdgpu: increase atombios cmd timeout
        Bluetooth: L2CAP: handle l2cap config request during open state
        media: tda10071: fix unsigned sign extension overflow
        tpm: ibmvtpm: Wait for buffer to be set before proceeding
        tracing: Use address-of operator on section symbols
        serial: 8250_omap: Fix sleeping function called from invalid context during probe
        SUNRPC: Fix a potential buffer overflow in 'svc_print_xprts()'
        ubifs: Fix out-of-bounds memory access caused by abnormal value of node_len
        ALSA: usb-audio: Fix case when USB MIDI interface has more than one extra endpoint descriptor
        mm/filemap.c: clear page error before actual read
        mm/mmap.c: initialize align_offset explicitly for vm_unmapped_area
        KVM: Remove CREATE_IRQCHIP/SET_PIT2 race
        bdev: Reduce time holding bd_mutex in sync in blkdev_close()
        drivers: char: tlclk.c: Avoid data race between init and interrupt handler
        dt-bindings: sound: wm8994: Correct required supplies based on actual implementaion
        atm: fix a memory leak of vcc->user_back
        phy: samsung: s5pv210-usb2: Add delay after reset
        Bluetooth: Handle Inquiry Cancel error after Inquiry Complete
        USB: EHCI: ehci-mv: fix error handling in mv_ehci_probe()
        tty: serial: samsung: Correct clock selection logic
        ALSA: hda: Fix potential race in unsol event handler
        fuse: don't check refcount after stealing page
        USB: EHCI: ehci-mv: fix less than zero comparison of an unsigned int
        e1000: Do not perform reset in reset_task if we are already down
        printk: handle blank console arguments passed in.
        vfio/pci: fix memory leaks of eventfd ctx
        perf kcore_copy: Fix module map when there are no modules loaded
        mtd: rawnand: omap_elm: Fix runtime PM imbalance on error
        ceph: fix potential race in ceph_check_caps
        mtd: parser: cmdline: Support MTD names containing one or more colons
        x86/speculation/mds: Mark mds_user_clear_cpu_buffers() __always_inline
        vfio/pci: Clear error and request eventfd ctx after releasing
        vfio/pci: fix racy on error and request eventfd ctx
        s390/init: add missing __init annotations
        mwifiex: Increase AES key storage size to 256 bits
        batman-adv: bla: fix type misuse for backbone_gw hash indexing
        atm: eni: fix the missed pci_disable_device() for eni_init_one()
        batman-adv: mcast/TT: fix wrongly dropped or rerouted packets
        ALSA: asihpi: fix iounmap in error handler
        MIPS: Add the missing 'CPU_1074K' into __get_cpu_type()
        tty: vt, consw->con_scrolldelta cleanup
        kprobes: Fix to check probe enabled before disarm_kprobe_ftrace()
        lib/string.c: implement stpcpy
        ata: define AC_ERR_OK
        ata: make qc_prep return ata_completion_errors
        ata: sata_mv, avoid trigerrable BUG_ON
        Linux 4.4.238

Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
2020-10-01 10:14:23 -07:00
Rustam Kovhaev
f0dfffce3f KVM: fix memory leak in kvm_io_bus_unregister_dev()
[ Upstream commit f65886606c2d3b562716de030706dfe1bea4ed5e ]

when kmalloc() fails in kvm_io_bus_unregister_dev(), before removing
the bus, we should iterate over all other devices linked to it and call
kvm_iodevice_destructor() for them

Fixes: 90db10434b16 ("KVM: kvm_io_bus_unregister_dev() should never fail")
Cc: stable@vger.kernel.org
Reported-and-tested-by: syzbot+f196caa45793d6374707@syzkaller.appspotmail.com
Link: https://syzkaller.appspot.com/bug?extid=f196caa45793d6374707
Signed-off-by: Rustam Kovhaev <rkovhaev@gmail.com>
Reviewed-by: Vitaly Kuznetsov <vkuznets@redhat.com>
Message-Id: <20200907185535.233114-1-rkovhaev@gmail.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2020-10-01 11:11:49 +02:00
Nathan Chancellor
8de13f8453 Merge 4.4.216 into android-msm-wahoo-4.4
Changes in 4.4.216: (73 commits)
        iwlwifi: pcie: fix rb_allocator workqueue allocation
        ext4: fix potential race between online resizing and write operations
        ext4: fix potential race between s_flex_groups online resizing and access
        ext4: fix potential race between s_group_info online resizing and access
        ipmi:ssif: Handle a possible NULL pointer reference
        mac80211: consider more elements in parsing CRC
        cfg80211: check wiphy driver existence for drvinfo report
        cifs: Fix mode output in debugging statements
        cfg80211: add missing policy for NL80211_ATTR_STATUS_CODE
        sysrq: Restore original console_loglevel when sysrq disabled
        sysrq: Remove duplicated sysrq message
        net: fib_rules: Correctly set table field when table number exceeds 8 bits
        net: phy: restore mdio regs in the iproc mdio driver
        ipv6: Fix nlmsg_flags when splitting a multipath route
        ipv6: Fix route replacement with dev-only route
        sctp: move the format error check out of __sctp_sf_do_9_1_abort
        nfc: pn544: Fix occasional HW initialization failure
        net: sched: correct flower port blocking
        ext4: potential crash on allocation error in ext4_alloc_flex_bg_array()
        audit: fix error handling in audit_data_to_entry()
        HID: core: fix off-by-one memset in hid_report_raw_event()
        HID: core: increase HID report buffer size to 8KiB
        HID: hiddev: Fix race in in hiddev_disconnect()
        MIPS: VPE: Fix a double free and a memory leak in 'release_vpe()'
        i2c: jz4780: silence log flood on txabrt
        ecryptfs: Fix up bad backport of fe2e082f5da5b4a0a92ae32978f81507ef37ec66
        include/linux/bitops.h: introduce BITS_PER_TYPE
        net: netlink: cap max groups which will be considered in netlink_bind()
        namei: only return -ECHILD from follow_dotdot_rcu()
        KVM: Check for a bad hva before dropping into the ghc slow path
        slip: stop double free sl->dev in slip_open
        mm: make page ref count overflow check tighter and more explicit
        mm: add 'try_get_page()' helper function
        mm, gup: remove broken VM_BUG_ON_PAGE compound check for hugepages
        mm, gup: ensure real head page is ref-counted when using hugepages
        mm: prevent get_user_pages() from overflowing page refcount
        pipe: add pipe_buf_get() helper
        fs: prevent page refcount overflow in pipe_buf_get
        audit: always check the netlink payload length in audit_receive_msg()
        serial: ar933x_uart: set UART_CS_{RX,TX}_READY_ORIDE
        usb: gadget: ffs: ffs_aio_cancel(): Save/restore IRQ flags
        usb: gadget: serial: fix Tx stall after buffer overflow
        drm: msm: Fix return type of dsi_mgr_connector_mode_valid for kCFI
        drm/msm/dsi: save pll state before dsi host is powered off
        net: ks8851-ml: Remove 8-bit bus accessors
        net: ks8851-ml: Fix 16-bit data access
        net: ks8851-ml: Fix 16-bit IO operation
        watchdog: da9062: do not ping the hw during stop()
        s390/cio: cio_ignore_proc_seq_next should increase position index
        cifs: don't leak -EAGAIN for stat() during reconnect
        usb: storage: Add quirk for Samsung Fit flash
        usb: quirks: add NO_LPM quirk for Logitech Screen Share
        usb: core: hub: do error out if usb_autopm_get_interface() fails
        usb: core: port: do error out if usb_autopm_get_interface() fails
        vgacon: Fix a UAF in vgacon_invert_region
        fat: fix uninit-memory access for partial initialized inode
        vt: selection, close sel_buffer race
        vt: selection, push console lock down
        vt: selection, push sel_lock up
        dmaengine: tegra-apb: Fix use-after-free
        dmaengine: tegra-apb: Prevent race conditions of tasklet vs free list
        ASoC: pcm: Fix possible buffer overflow in dpcm state sysfs output
        ASoC: pcm512x: Fix unbalanced regulator enable call in probe error path
        ASoC: dapm: Correct DAPM handling of active widgets during shutdown
        RDMA/iwcm: Fix iwcm work deallocation
        RMDA/cm: Fix missing ib_cm_destroy_id() in ib_cm_insert_listen()
        ARM: imx: build v7_cpu_resume() unconditionally
        hwmon: (adt7462) Fix an error return in ADT7462_REG_VOLT()
        dmaengine: coh901318: Fix a double lock bug in dma_tc_handle()
        powerpc: fix hardware PMU exception bug on PowerVM compatibility mode systems
        dm cache: fix a crash due to incorrect work item cancelling
        crypto: algif_skcipher - use ZERO_OR_NULL_PTR in skcipher_recvmsg_async
        Linux 4.4.216

Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>

Conflicts:
	drivers/usb/gadget/function/f_fs.c
	drivers/usb/gadget/function/u_serial.c
2020-03-11 00:24:24 -07:00
Sean Christopherson
2f4375851a KVM: Check for a bad hva before dropping into the ghc slow path
commit fcfbc617547fc6d9552cb6c1c563b6a90ee98085 upstream.

When reading/writing using the guest/host cache, check for a bad hva
before checking for a NULL memslot, which triggers the slow path for
handing cross-page accesses.  Because the memslot is nullified on error
by __kvm_gfn_to_hva_cache_init(), if the bad hva is encountered after
crossing into a new page, then the kvm_{read,write}_guest() slow path
could potentially write/access the first chunk prior to detecting the
bad hva.

Arguably, performing a partial access is semantically correct from an
architectural perspective, but that behavior is certainly not intended.
In the original implementation, memslot was not explicitly nullified
and therefore the partial access behavior varied based on whether the
memslot itself was null, or if the hva was simply bad.  The current
behavior was introduced as a seemingly unintentional side effect in
commit f1b9dd5eb86c ("kvm: Disallow wraparound in
kvm_gfn_to_hva_cache_init"), which justified the change with "since some
callers don't check the return code from this function, it sit seems
prudent to clear ghc->memslot in the event of an error".

Regardless of intent, the partial access is dependent on _not_ checking
the result of the cache initialization, which is arguably a bug in its
own right, at best simply weird.

Fixes: 8f964525a1 ("KVM: Allow cross page reads and writes from cached translations.")
Cc: Jim Mattson <jmattson@google.com>
Cc: Andrew Honig <ahonig@google.com>
Signed-off-by: Sean Christopherson <sean.j.christopherson@intel.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-03-11 07:51:14 +01:00
Nathan Chancellor
2c9203de9f Merge 4.4.194 into android-msm-wahoo-4.4
Changes in 4.4.194: (58 commits)
        bridge/mdb: remove wrong use of NLM_F_MULTI
        cdc_ether: fix rndis support for Mediatek based smartphones
        ipv6: Fix the link time qualifier of 'ping_v6_proc_exit_net()'
        isdn/capi: check message length in capi_write()
        net: Fix null de-reference of device refcount
        sch_hhf: ensure quantum and hhf_non_hh_weight are non-zero
        sctp: Fix the link time qualifier of 'sctp_ctrlsock_exit()'
        sctp: use transport pf_retrans in sctp_do_8_2_transport_strike
        tcp: fix tcp_ecn_withdraw_cwr() to clear TCP_ECN_QUEUE_CWR
        tipc: add NULL pointer check before calling kfree_rcu
        tun: fix use-after-free when register netdev failed
        Revert "MIPS: SiByte: Enable swiotlb for SWARM, LittleSur and BigSur"
        Btrfs: fix assertion failure during fsync and use of stale transaction
        genirq: Prevent NULL pointer dereference in resend_irqs()
        KVM: s390: Do not leak kernel stack data in the KVM_S390_INTERRUPT ioctl
        KVM: x86: work around leak of uninitialized stack contents
        KVM: nVMX: handle page fault in vmread
        MIPS: VDSO: Prevent use of smp_processor_id()
        MIPS: VDSO: Use same -m%-float cflag as the kernel proper
        clk: rockchip: Don't yell about bad mmc phases when getting
        driver core: Fix use-after-free and double free on glue directory
        crypto: talitos - check AES key size
        crypto: talitos - check data blocksize in ablkcipher.
        x86/build: Add -Wnoaddress-of-packed-member to REALMODE_CFLAGS, to silence GCC9 build warning
        MIPS: netlogic: xlr: Remove erroneous check in nlm_fmn_send()
        ARC: configs: Remove CONFIG_INITRAMFS_SOURCE from defconfigs
        USB: usbcore: Fix slab-out-of-bounds bug during device reset
        media: tm6000: double free if usb disconnect while streaming
        x86/boot: Add missing bootparam that breaks boot on some platforms
        xen-netfront: do not assume sk_buff_head list is empty in error handling
        KVM: coalesced_mmio: add bounds checking
        serial: sprd: correct the wrong sequence of arguments
        tty/serial: atmel: reschedule TX after RX was started
        mwifiex: Fix three heap overflow at parsing element in cfg80211_ap_settings
        s390/bpf: fix lcgr instruction encoding
        ARM: OMAP2+: Fix omap4 errata warning on other SoCs
        s390/bpf: use 32-bit index for tail calls
        NFSv4: Fix return values for nfs4_file_open()
        NFS: Fix initialisation of I/O result struct in nfs_pgio_rpcsetup
        Kconfig: Fix the reference to the IDT77105 Phy driver in the description of ATM_NICSTAR_USE_IDT77105
        ARM: 8874/1: mm: only adjust sections of valid mm structures
        r8152: Set memory to all 0xFFs on failed reg reads
        x86/apic: Fix arch_dynirq_lower_bound() bug for DT enabled machines
        netfilter: nf_conntrack_ftp: Fix debug output
        NFSv2: Fix eof handling
        NFSv2: Fix write regression
        cifs: set domainName when a domain-key is used in multiuser
        cifs: Use kzfree() to zero out the password
        sky2: Disable MSI on yet another ASUS boards (P6Xxxx)
        tools/power turbostat: fix buffer overrun
        net: seeq: Fix the function used to release some memory in an error handling path
        dmaengine: ti: omap-dma: Add cleanup in omap_dma_probe()
        keys: Fix missing null pointer check in request_key_auth_describe()
        floppy: fix usercopy direction
        media: technisat-usb2: break out of loop at end of buffer
        ARC: export "abort" for modules
        net_sched: let qdisc_put() accept NULL pointer
        Linux 4.4.194

Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
2019-09-21 08:28:04 -07:00
Matt Delco
ae41539657 KVM: coalesced_mmio: add bounds checking
commit b60fe990c6b07ef6d4df67bc0530c7c90a62623a upstream.

The first/last indexes are typically shared with a user app.
The app can change the 'last' index that the kernel uses
to store the next result.  This change sanity checks the index
before using it for writing to a potentially arbitrary address.

This fixes CVE-2019-14821.

Cc: stable@vger.kernel.org
Fixes: 5f94c1741b ("KVM: Add coalesced MMIO support (common part)")
Signed-off-by: Matt Delco <delco@chromium.org>
Signed-off-by: Jim Mattson <jmattson@google.com>
Reported-by: syzbot+983c866c3dd6efa3662a@syzkaller.appspotmail.com
[Use READ_ONCE. - Paolo]
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-09-21 07:12:47 +02:00
Nathan Chancellor
a53398dbf4 Merge 4.4.178 into android-msm-wahoo-4.4
Changes in 4.4.178: (132 commits)
        mmc: pxamci: fix enum type confusion
        drm/vmwgfx: Don't double-free the mode stored in par->set_mode
        udf: Fix crash on IO error during truncate
        mips: loongson64: lemote-2f: Add IRQF_NO_SUSPEND to "cascade" irqaction.
        MIPS: Fix kernel crash for R6 in jump label branch function
        futex: Ensure that futex address is aligned in handle_futex_death()
        ext4: fix NULL pointer dereference while journal is aborted
        ext4: fix data corruption caused by unaligned direct AIO
        ext4: brelse all indirect buffer in ext4_ind_remove_space()
        mmc: tmio_mmc_core: don't claim spurious interrupts
        media: v4l2-ctrls.c/uvc: zero v4l2_event
        locking/lockdep: Add debug_locks check in __lock_downgrade()
        ALSA: hda - Record the current power state before suspend/resume calls
        ALSA: hda - Enforces runtime_resume after S3 and S4 for each codec
        mmc: pwrseq_simple: Make reset-gpios optional to match doc
        mmc: debugfs: Add a restriction to mmc debugfs clock setting
        mmc: make MAN_BKOPS_EN message a debug
        mmc: sanitize 'bus width' in debug output
        mmc: core: shut up "voltage-ranges unspecified" pr_info()
        usb: dwc3: gadget: Fix suspend/resume during device mode
        arm64: mm: Add trace_irqflags annotations to do_debug_exception()
        mmc: core: fix using wrong io voltage if mmc_select_hs200 fails
        mm/rmap: replace BUG_ON(anon_vma->degree) with VM_WARN_ON
        extcon: usb-gpio: Don't miss event during suspend/resume
        kbuild: setlocalversion: print error to STDERR
        usb: gadget: composite: fix dereference after null check coverify warning
        usb: gadget: Add the gserial port checking in gs_start_tx()
        tcp/dccp: drop SYN packets if accept queue is full
        serial: sprd: adjust TIMEOUT to a big value
        Hang/soft lockup in d_invalidate with simultaneous calls
        arm64: traps: disable irq in die()
        usb: renesas_usbhs: gadget: fix unused-but-set-variable warning
        serial: sprd: clear timeout interrupt only rather than all interrupts
        lib/int_sqrt: optimize small argument
        USB: core: only clean up what we allocated
        rtc: Fix overflow when converting time64_t to rtc_time
        ath10k: avoid possible string overflow
        Bluetooth: Check L2CAP option sizes returned from l2cap_get_conf_opt
        Bluetooth: Verify that l2cap_get_conf_opt provides large enough buffer
        sched/fair: Fix new task's load avg removed from source CPU in wake_up_new_task()
        mmc: block: Allow more than 8 partitions per card
        arm64: fix COMPAT_SHMLBA definition for large pages
        efi: stub: define DISABLE_BRANCH_PROFILING for all architectures
        ARM: 8458/1: bL_switcher: add GIC dependency
        ARM: 8494/1: mm: Enable PXN when running non-LPAE kernel on LPAE processor
        android: unconditionally remove callbacks in sync_fence_free()
        vmstat: make vmstat_updater deferrable again and shut down on idle
        hid-sensor-hub.c: fix wrong do_div() usage
        arm64: hide __efistub_ aliases from kallsyms
        perf: Synchronously free aux pages in case of allocation failure
        net: diag: support v4mapped sockets in inet_diag_find_one_icsk()
        Revert "mmc: block: don't use parameter prefix if built as module"
        writeback: initialize inode members that track writeback history
        coresight: fixing lockdep error
        coresight: coresight_unregister() function cleanup
        coresight: release reference taken by 'bus_find_device()'
        coresight: remove csdev's link from topology
        stm class: Fix locking in unbinding policy path
        stm class: Fix link list locking
        stm class: Prevent user-controllable allocations
        stm class: Support devices with multiple instances
        stm class: Fix unlocking braino in the error path
        stm class: Guard output assignment against concurrency
        stm class: Fix unbalanced module/device refcounting
        stm class: Fix a race in unlinking
        coresight: "DEVICE_ATTR_RO" should defined as static.
        coresight: etm4x: Check every parameter used by dma_xx_coherent.
        asm-generic: Fix local variable shadow in __set_fixmap_offset
        staging: ashmem: Avoid deadlock with mmap/shrink
        staging: ashmem: Add missing include
        staging: ion: Set minimum carveout heap allocation order to PAGE_SHIFT
        staging: goldfish: audio: fix compiliation on arm
        ARM: 8510/1: rework ARM_CPU_SUSPEND dependencies
        arm64/kernel: fix incorrect EL0 check in inv_entry macro
        mac80211: fix "warning: ‘target_metric’ may be used uninitialized"
        perf/ring_buffer: Refuse to begin AUX transaction after rb->aux_mmap_count drops
        arm64: kernel: Include _AC definition in page.h
        PM / Hibernate: Call flush_icache_range() on pages restored in-place
        stm class: Do not leak the chrdev in error path
        stm class: Fix stm device initialization order
        ipv6: fix endianness error in icmpv6_err
        usb: gadget: configfs: add mutex lock before unregister gadget
        usb: gadget: rndis: free response queue during REMOTE_NDIS_RESET_MSG
        cpu/hotplug: Handle unbalanced hotplug enable/disable
        video: fbdev: Set pixclock = 0 in goldfishfb
        arm64: kconfig: drop CONFIG_RTC_LIB dependency
        mmc: mmc: fix switch timeout issue caused by jiffies precision
        cfg80211: size various nl80211 messages correctly
        stmmac: copy unicast mac address to MAC registers
        dccp: do not use ipv6 header for ipv4 flow
        mISDN: hfcpci: Test both vendor & device ID for Digium HFC4S
        net/packet: Set __GFP_NOWARN upon allocation in alloc_pg_vec
        net: rose: fix a possible stack overflow
        Add hlist_add_tail_rcu() (Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net)
        packets: Always register packet sk in the same order
        tcp: do not use ipv6 header for ipv4 flow
        vxlan: Don't call gro_cells_destroy() before device is unregistered
        sctp: get sctphdr by offset in sctp_compute_cksum
        mac8390: Fix mmio access size probe
        btrfs: remove WARN_ON in log_dir_items
        btrfs: raid56: properly unmap parity page in finish_parity_scrub()
        ARM: imx6q: cpuidle: fix bug that CPU might not wake up at expected time
        ALSA: compress: add support for 32bit calls in a 64bit kernel
        ALSA: rawmidi: Fix potential Spectre v1 vulnerability
        ALSA: seq: oss: Fix Spectre v1 vulnerability
        ALSA: pcm: Fix possible OOB access in PCM oss plugins
        ALSA: pcm: Don't suspend stream in unrecoverable PCM state
        scsi: sd: Fix a race between closing an sd device and sd I/O
        scsi: zfcp: fix rport unblock if deleted SCSI devices on Scsi_Host
        scsi: zfcp: fix scsi_eh host reset with port_forced ERP for non-NPIV FCP devices
        tty: atmel_serial: fix a potential NULL pointer dereference
        staging: vt6655: Remove vif check from vnt_interrupt
        staging: vt6655: Fix interrupt race condition on device start up.
        serial: max310x: Fix to avoid potential NULL pointer dereference
        serial: sh-sci: Fix setting SCSCR_TIE while transferring data
        USB: serial: cp210x: add new device id
        USB: serial: ftdi_sio: add additional NovaTech products
        USB: serial: mos7720: fix mos_parport refcount imbalance on error path
        USB: serial: option: set driver_info for SIM5218 and compatibles
        USB: serial: option: add Olicard 600
        Disable kgdboc failed by echo space to /sys/module/kgdboc/parameters/kgdboc
        fs/proc/proc_sysctl.c: fix NULL pointer dereference in put_links
        gpio: adnp: Fix testing wrong value in adnp_gpio_direction_input
        perf intel-pt: Fix TSC slip
        x86/smp: Enforce CONFIG_HOTPLUG_CPU when SMP=y
        KVM: Reject device ioctls from processes other than the VM's creator
        xhci: Fix port resume done detection for SS ports with LPM enabled
        Revert "USB: core: only clean up what we allocated"
        arm64: support keyctl() system call in 32-bit mode
        coresight: removing bind/unbind options from sysfs
        stm class: Hide STM-specific options if STM is disabled
        Linux 4.4.178

Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>

Conflicts:
	arch/arm/Kconfig
	arch/arm64/Kconfig
	arch/arm64/kernel/traps.c
	drivers/hwtracing/coresight/coresight-etm4x.c
	drivers/hwtracing/coresight/coresight-tmc.c
	drivers/hwtracing/stm/Kconfig
	drivers/hwtracing/stm/core.c
	drivers/mmc/core/mmc.c
	drivers/usb/gadget/configfs.c
	drivers/usb/gadget/function/rndis.c
	drivers/usb/gadget/function/u_serial.c
	kernel/events/ring_buffer.c
	kernel/sched/fair.c
	sound/core/compress_offload.c
2019-04-02 22:00:46 -07:00
Sean Christopherson
9aacea736c KVM: Reject device ioctls from processes other than the VM's creator
commit ddba91801aeb5c160b660caed1800eb3aef403f8 upstream.

KVM's API requires thats ioctls must be issued from the same process
that created the VM.  In other words, userspace can play games with a
VM's file descriptors, e.g. fork(), SCM_RIGHTS, etc..., but only the
creator can do anything useful.  Explicitly reject device ioctls that
are issued by a process other than the VM's creator, and update KVM's
API documentation to extend its requirements to device ioctls.

Fixes: 852b6d57dc ("kvm: add device control API")
Cc: <stable@vger.kernel.org>
Signed-off-by: Sean Christopherson <sean.j.christopherson@intel.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-04-03 06:23:28 +02:00
Nathan Chancellor
12a1173759 Merge 4.4.177 into android-msm-wahoo-4.4
Changes in 4.4.177: (231 commits)
        ceph: avoid repeatedly adding inode to mdsc->snap_flush_list
        numa: change get_mempolicy() to use nr_node_ids instead of MAX_NUMNODES
        KEYS: allow reaching the keys quotas exactly
        mfd: ti_am335x_tscadc: Use PLATFORM_DEVID_AUTO while registering mfd cells
        mfd: twl-core: Fix section annotations on {,un}protect_pm_master
        mfd: db8500-prcmu: Fix some section annotations
        mfd: ab8500-core: Return zero in get_register_interruptible()
        mfd: qcom_rpm: write fw_version to CTRL_REG
        mfd: wm5110: Add missing ASRC rate register
        mfd: mc13xxx: Fix a missing check of a register-read failure
        net: hns: Fix use after free identified by SLUB debug
        MIPS: ath79: Enable OF serial ports in the default config
        scsi: qla4xxx: check return code of qla4xxx_copy_from_fwddb_param
        scsi: isci: initialize shost fully before calling scsi_add_host()
        MIPS: jazz: fix 64bit build
        isdn: i4l: isdn_tty: Fix some concurrency double-free bugs
        atm: he: fix sign-extension overflow on large shift
        leds: lp5523: fix a missing check of return value of lp55xx_read
        isdn: avm: Fix string plus integer warning from Clang
        RDMA/srp: Rework SCSI device reset handling
        KEYS: user: Align the payload buffer
        KEYS: always initialize keyring_index_key::desc_len
        batman-adv: fix uninit-value in batadv_interface_tx()
        net/packet: fix 4gb buffer limit due to overflow check
        team: avoid complex list operations in team_nl_cmd_options_set()
        sit: check if IPv6 enabled before calling ip6_err_gen_icmpv6_unreach()
        net/mlx4_en: Force CHECKSUM_NONE for short ethernet frames
        ARCv2: Enable unaligned access in early ASM code
        Revert "bridge: do not add port to router list when receives query with source 0.0.0.0"
        libceph: handle an empty authorize reply
        scsi: libsas: Fix rphy phy_identifier for PHYs with end devices attached
        drm/msm: Unblock writer if reader closes file
        ASoC: Intel: Haswell/Broadwell: fix setting for .dynamic field
        ALSA: compress: prevent potential divide by zero bugs
        thermal: int340x_thermal: Fix a NULL vs IS_ERR() check
        usb: dwc3: gadget: Fix the uninitialized link_state when udc starts
        usb: gadget: Potential NULL dereference on allocation error
        ASoC: dapm: change snprintf to scnprintf for possible overflow
        ASoC: imx-audmux: change snprintf to scnprintf for possible overflow
        ARC: fix __ffs return value to avoid build warnings
        mac80211: fix miscounting of ttl-dropped frames
        serial: fsl_lpuart: fix maximum acceptable baud rate with over-sampling
        scsi: csiostor: fix NULL pointer dereference in csio_vport_set_state()
        net: altera_tse: fix connect_local_phy error path
        ibmveth: Do not process frames after calling napi_reschedule
        mac80211: don't initiate TDLS connection if station is not associated to AP
        cfg80211: extend range deviation for DMG
        KVM: nSVM: clear events pending from svm_complete_interrupts() when exiting to L1
        arm/arm64: KVM: Feed initialized memory to MMIO accesses
        KVM: arm/arm64: Fix MMIO emulation data handling
        powerpc: Always initialize input array when calling epapr_hypercall()
        mmc: spi: Fix card detection during probe
        mm: enforce min addr even if capable() in expand_downwards()
        x86/uaccess: Don't leak the AC flag into __put_user() value evaluation
        USB: serial: option: add Telit ME910 ECM composition
        USB: serial: cp210x: add ID for Ingenico 3070
        USB: serial: ftdi_sio: add ID for Hjelmslund Electronics USB485
        cpufreq: Use struct kobj_attribute instead of struct global_attr
        sockfs: getxattr: Fail with -EOPNOTSUPP for invalid attribute names
        ncpfs: fix build warning of strncpy
        isdn: isdn_tty: fix build warning of strncpy
        staging: lustre: fix buffer overflow of string buffer
        net-sysfs: Fix mem leak in netdev_register_kobject
        sky2: Disable MSI on Dell Inspiron 1545 and Gateway P-79
        team: Free BPF filter when unregistering netdev
        bnxt_en: Drop oversize TX packets to prevent errors.
        net: nfc: Fix NULL dereference on nfc_llcp_build_tlv fails
        xen-netback: fix occasional leak of grant ref mappings under memory pressure
        net: Add __icmp_send helper.
        net: avoid use IPCB in cipso_v4_error
        net: phy: Micrel KSZ8061: link failure after cable connect
        x86/CPU/AMD: Set the CPB bit unconditionally on F17h
        applicom: Fix potential Spectre v1 vulnerabilities
        MIPS: irq: Allocate accurate order pages for irq stack
        hugetlbfs: fix races and page leaks during migration
        netlabel: fix out-of-bounds memory accesses
        net: dsa: mv88e6xxx: Fix u64 statistics
        ip6mr: Do not call __IP6_INC_STATS() from preemptible context
        media: uvcvideo: Fix 'type' check leading to overflow
        vti4: Fix a ipip packet processing bug in 'IPCOMP' virtual tunnel
        perf tools: Handle TOPOLOGY headers with no CPU
        IB/{hfi1, qib}: Fix WC.byte_len calculation for UD_SEND_WITH_IMM
        ipvs: Fix signed integer overflow when setsockopt timeout
        iommu/amd: Fix IOMMU page flush when detach device from a domain
        xtensa: SMP: fix ccount_timer_shutdown
        xtensa: SMP: fix secondary CPU initialization
        xtensa: smp_lx200_defconfig: fix vectors clash
        xtensa: SMP: mark each possible CPU as present
        xtensa: SMP: limit number of possible CPUs by NR_CPUS
        net: altera_tse: fix msgdma_tx_completion on non-zero fill_level case
        net: hns: Fix wrong read accesses via Clause 45 MDIO protocol
        net: stmmac: dwmac-rk: fix error handling in rk_gmac_powerup()
        gpio: vf610: Mask all GPIO interrupts
        nfs: Fix NULL pointer dereference of dev_name
        scsi: libfc: free skb when receiving invalid flogi resp
        platform/x86: Fix unmet dependency warning for SAMSUNG_Q10
        cifs: fix computation for MAX_SMB2_HDR_SIZE
        x86/kexec: Don't setup EFI info if EFI runtime is not enabled
        x86_64: increase stack size for KASAN_EXTRA
        mm, memory_hotplug: is_mem_section_removable do not pass the end of a zone
        mm, memory_hotplug: test_pages_in_a_zone do not pass the end of zone
        fs/drop_caches.c: avoid softlockups in drop_pagecache_sb()
        autofs: drop dentry reference only when it is never used
        autofs: fix error return in autofs_fill_super()
        ARM: pxa: ssp: unneeded to free devm_ allocated data
        irqchip/mmp: Only touch the PJ4 IRQ & FIQ bits on enable/disable
        dmaengine: at_xdmac: Fix wrongfull report of a channel as in use
        dmaengine: dmatest: Abort test in case of mapping error
        s390/qeth: fix use-after-free in error path
        perf symbols: Filter out hidden symbols from labels
        MIPS: Remove function size check in get_frame_info()
        Input: wacom_serial4 - add support for Wacom ArtPad II tablet
        Input: elan_i2c - add id for touchpad found in Lenovo s21e-20
        iscsi_ibft: Fix missing break in switch statement
        futex,rt_mutex: Restructure rt_mutex_finish_proxy_lock()
        ARM: dts: exynos: Add minimal clkout parameters to Exynos3250 PMU
        Revert "x86/platform/UV: Use efi_runtime_lock to serialise BIOS calls"
        ARM: dts: exynos: Do not ignore real-world fuse values for thermal zone 0 on Exynos5420
        udplite: call proper backlog handlers
        netfilter: x_tables: enforce nul-terminated table name from getsockopt GET_ENTRIES
        netfilter: nfnetlink_log: just returns error for unknown command
        netfilter: nfnetlink_acct: validate NFACCT_FILTER parameters
        netfilter: nf_conntrack_tcp: Fix stack out of bounds when parsing TCP options
        KEYS: restrict /proc/keys by credentials at open time
        l2tp: fix infoleak in l2tp_ip6_recvmsg()
        net: hsr: fix memory leak in hsr_dev_finalize()
        net: sit: fix UBSAN Undefined behaviour in check_6rd
        net/x25: fix use-after-free in x25_device_event()
        net/x25: reset state in x25_connect()
        pptp: dst_release sk_dst_cache in pptp_sock_destruct
        ravb: Decrease TxFIFO depth of Q3 and Q2 to one
        route: set the deleted fnhe fnhe_daddr to 0 in ip_del_fnhe to fix a race
        tcp: handle inet_csk_reqsk_queue_add() failures
        net/mlx4_core: Fix reset flow when in command polling mode
        net/mlx4_core: Fix qp mtt size calculation
        net/x25: fix a race in x25_bind()
        mdio_bus: Fix use-after-free on device_register fails
        net: Set rtm_table to RT_TABLE_COMPAT for ipv6 for tables > 255
        missing barriers in some of unix_sock ->addr and ->path accesses
        ipvlan: disallow userns cap_net_admin to change global mode/flags
        vxlan: test dev->flags & IFF_UP before calling gro_cells_receive()
        vxlan: Fix GRO cells race condition between receive and link delete
        net/hsr: fix possible crash in add_timer()
        gro_cells: make sure device is up in gro_cells_receive()
        tcp/dccp: remove reqsk_put() from inet_child_forget()
        ALSA: bebob: use more identical mod_alias for Saffire Pro 10 I/O against Liquid Saffire 56
        fs/9p: use fscache mutex rather than spinlock
        It's wrong to add len to sector_nr in raid10 reshape twice
        media: videobuf2-v4l2: drop WARN_ON in vb2_warn_zero_bytesused()
        9p: use inode->i_lock to protect i_size_write() under 32-bit
        9p/net: fix memory leak in p9_client_create
        ASoC: fsl_esai: fix register setting issue in RIGHT_J mode
        stm class: Fix an endless loop in channel allocation
        crypto: caam - fixed handling of sg list
        crypto: ahash - fix another early termination in hash walk
        gpu: ipu-v3: Fix i.MX51 CSI control registers offset
        gpu: ipu-v3: Fix CSI offsets for imx53
        s390/dasd: fix using offset into zero size array error
        ARM: OMAP2+: Variable "reg" in function omap4_dsi_mux_pads() could be uninitialized
        Input: matrix_keypad - use flush_delayed_work()
        i2c: cadence: Fix the hold bit setting
        Input: st-keyscan - fix potential zalloc NULL dereference
        ARM: 8824/1: fix a migrating irq bug when hotplug cpu
        assoc_array: Fix shortcut creation
        scsi: libiscsi: Fix race between iscsi_xmit_task and iscsi_complete_task
        net: systemport: Fix reception of BPDUs
        pinctrl: meson: meson8b: fix the sdxc_a data 1..3 pins
        net: mv643xx_eth: disable clk on error path in mv643xx_eth_shared_probe()
        ASoC: topology: free created components in tplg load error
        arm64: Relax GIC version check during early boot
        tmpfs: fix link accounting when a tmpfile is linked in
        ARC: uacces: remove lp_start, lp_end from clobber list
        phonet: fix building with clang
        mac80211_hwsim: propagate genlmsg_reply return code
        net: set static variable an initial value in atl2_probe()
        tmpfs: fix uninitialized return value in shmem_link
        stm class: Prevent division by zero
        crypto: arm64/aes-ccm - fix logical bug in AAD MAC handling
        CIFS: Fix read after write for files with read caching
        tracing: Do not free iter->trace in fail path of tracing_open_pipe()
        ACPI / device_sysfs: Avoid OF modalias creation for removed device
        regulator: s2mps11: Fix steps for buck7, buck8 and LDO35
        regulator: s2mpa01: Fix step values for some LDOs
        clocksource/drivers/exynos_mct: Move one-shot check from tick clear to ISR
        clocksource/drivers/exynos_mct: Clear timer interrupt when shutdown
        s390/virtio: handle find on invalid queue gracefully
        scsi: virtio_scsi: don't send sc payload with tmfs
        scsi: target/iscsi: Avoid iscsit_release_commands_from_conn() deadlock
        m68k: Add -ffreestanding to CFLAGS
        btrfs: ensure that a DUP or RAID1 block group has exactly two stripes
        Btrfs: fix corruption reading shared and compressed extents after hole punching
        crypto: pcbc - remove bogus memcpy()s with src == dest
        cpufreq: tegra124: add missing of_node_put()
        cpufreq: pxa2xx: remove incorrect __init annotation
        ext4: fix crash during online resizing
        ext2: Fix underflow in ext2_max_size()
        clk: ingenic: Fix round_rate misbehaving with non-integer dividers
        dmaengine: usb-dmac: Make DMAC system sleep callbacks explicit
        mm/vmalloc: fix size check for remap_vmalloc_range_partial()
        kernel/sysctl.c: add missing range check in do_proc_dointvec_minmax_conv
        intel_th: Don't reference unassigned outputs
        parport_pc: fix find_superio io compare code, should use equal test.
        i2c: tegra: fix maximum transfer size
        perf bench: Copy kernel files needed to build mem{cpy,set} x86_64 benchmarks
        serial: 8250_pci: Fix number of ports for ACCES serial cards
        serial: 8250_pci: Have ACCES cards that use the four port Pericom PI7C9X7954 chip use the pci_pericom_setup()
        jbd2: clear dirty flag when revoking a buffer from an older transaction
        jbd2: fix compile warning when using JBUFFER_TRACE
        powerpc/32: Clear on-stack exception marker upon exception return
        powerpc/wii: properly disable use of BATs when requested.
        powerpc/powernv: Make opal log only readable by root
        powerpc/83xx: Also save/restore SPRG4-7 during suspend
        ARM: s3c24xx: Fix boolean expressions in osiris_dvs_notify
        dm: fix to_sector() for 32bit
        NFS41: pop some layoutget errors to application
        perf intel-pt: Fix CYC timestamp calculation after OVF
        perf auxtrace: Define auxtrace record alignment
        perf intel-pt: Fix overlap calculation for padding
        md: Fix failed allocation of md_register_thread
        NFS: Fix an I/O request leakage in nfs_do_recoalesce
        NFS: Don't recoalesce on error in nfs_pageio_complete_mirror()
        nfsd: fix memory corruption caused by readdir
        nfsd: fix wrong check in write_v4_end_grace()
        PM / wakeup: Rework wakeup source timer cancellation
        rcu: Do RCU GP kthread self-wakeup from softirq and interrupt
        media: uvcvideo: Avoid NULL pointer dereference at the end of streaming
        drm/radeon/evergreen_cs: fix missing break in switch statement
        KVM: nVMX: Sign extend displacements of VMX instr's mem operands
        KVM: nVMX: Ignore limit checks on VMX instructions using flat segments
        KVM: X86: Fix residual mmio emulation request to userspace
        Linux 4.4.177

Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>

Conflicts:
	arch/arm/kernel/irq.c
	sound/core/compress_offload.c
2019-03-23 08:25:40 -07:00
Christoffer Dall
05de33f100 KVM: arm/arm64: Fix MMIO emulation data handling
commit 83091db981e105d97562d3ed3ffe676e21927e3a upstream.

When the kernel was handling a guest MMIO read access internally, we
need to copy the emulation result into the run->mmio structure in order
for the kvm_handle_mmio_return() function to pick it up and inject the
	result back into the guest.

Currently the only user of kvm_io_bus for ARM is the VGIC, which did
this copying itself, so this was not causing issues so far.

But with the upcoming new vgic implementation we need this done
properly.

Update the kvm_handle_mmio_return description and cleanup the code to
only perform a single copying when needed.

Code and commit message inspired by Andre Przywara.

Reported-by: Andre Przywara <andre.przywara@arm.com>
Signed-off-by: Christoffer Dall <christoffer.dall@linaro.org>
Signed-off-by: Andre Przywara <andre.przywara@arm.com>
Reviewed-by: Marc Zyngier <marc.zyngier@arm.com>
Reviewed-by: Andre Przywara <andre.przywara@arm.com>
Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-03-23 08:44:20 +01:00
Nathan Chancellor
857f66e0ba Merge 4.4.176 into android-msm-wahoo-4.4
Changes in 4.4.176: (21 commits)
        net: fix IPv6 prefix route residue
        vsock: cope with memory allocation failure at socket creation time
        hwmon: (lm80) Fix missing unlock on error in set_fan_div()
        net: Fix for_each_netdev_feature on Big endian
        sky2: Increase D3 delay again
        net: Add header for usage of fls64()
        tcp: tcp_v4_err() should be more careful
        net: Do not allocate page fragments that are not skb aligned
        tcp: clear icsk_backoff in tcp_write_queue_purge()
        vxlan: test dev->flags & IFF_UP before calling netif_rx()
        net: stmmac: Fix a race in EEE enable callback
        net: ipv4: use a dedicated counter for icmp_v4 redirect packets
        x86: livepatch: Treat R_X86_64_PLT32 as R_X86_64_PC32
        kvm: fix kvm_ioctl_create_device() reference counting (CVE-2019-6974)
        mfd: as3722: Handle interrupts on suspend
        mfd: as3722: Mark PM functions as __maybe_unused
        net/x25: do not hold the cpu too long in x25_new_lci()
        mISDN: fix a race in dev_expire_timer()
        ax25: fix possible use-after-free
        KVM: VMX: Fix x2apic check in vmx_msr_bitmap_mode()
        Linux 4.4.176

Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
2019-02-23 07:40:22 -07:00
Jann Horn
bc4db52485 kvm: fix kvm_ioctl_create_device() reference counting (CVE-2019-6974)
commit cfa39381173d5f969daf43582c95ad679189cbc9 upstream.

kvm_ioctl_create_device() does the following:

1. creates a device that holds a reference to the VM object (with a borrowed
   reference, the VM's refcount has not been bumped yet)
2. initializes the device
3. transfers the reference to the device to the caller's file descriptor table
4. calls kvm_get_kvm() to turn the borrowed reference to the VM into a real
   reference

The ownership transfer in step 3 must not happen before the reference to the VM
becomes a proper, non-borrowed reference, which only happens in step 4.
After step 3, an attacker can close the file descriptor and drop the borrowed
reference, which can cause the refcount of the kvm object to drop to zero.

This means that we need to grab a reference for the device before
anon_inode_getfd(), otherwise the VM can disappear from under us.

Fixes: 852b6d57dc ("kvm: add device control API")
Cc: stable@kernel.org
Signed-off-by: Jann Horn <jannh@google.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-02-23 09:05:14 +01:00
Nathan Chancellor
3ca05e0d41 Merge 4.4.168 into android-msm-wahoo-4.4
Changes in 4.4.168: (89 commits)
        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

Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>

Conflicts:
	arch/x86/include/asm/uaccess.h
	arch/x86/include/asm/uaccess_32.h
	arch/x86/include/asm/uaccess_64.h
2018-12-17 14:48:49 -07:00
Lorenzo Stoakes
2b29980eb7 mm: replace get_user_pages_unlocked() write/force parameters with gup_flags
commit c164154f66f0c9b02673f07aa4f044f1d9c70274 upstream.

This removes the 'write' and 'force' use from get_user_pages_unlocked()
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>
Reviewed-by: Jan Kara <jack@suse.cz>
Acked-by: Michal Hocko <mhocko@suse.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
[bwh: Backported to 4.4:
 - Also update calls from process_vm_rw_single_vec() and async_pf_execute()
 - Adjust context]
Signed-off-by: Ben Hutchings <ben.hutchings@codethink.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-12-17 21:55:16 +01:00
Lorenzo Stoakes
ab424c8eb7 mm: remove write/force parameters from __get_user_pages_unlocked()
commit d4944b0ecec0af882483fe44b66729316e575208 upstream.

This removes the redundant 'write' and 'force' parameters from
__get_user_pages_unlocked() 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: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: Jan Kara <jack@suse.cz>
Acked-by: Michal Hocko <mhocko@suse.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
[bwh: Backported to 4.4:
 - Defer changes in process_vm_rw_single_vec() and async_pf_execute() since
   they use get_user_pages_unlocked() here
 - Adjust context]
Signed-off-by: Ben Hutchings <ben.hutchings@codethink.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-12-17 21:55:16 +01:00
Nathan Chancellor
14f46630e7 Merge 4.4.152 into android-msm-wahoo-4.4
Changes in 4.4.152: (79 commits)
        ARC: Explicitly add -mmedium-calls to CFLAGS
        netfilter: ipv6: nf_defrag: reduce struct net memory waste
        selftests: pstore: return Kselftest Skip code for skipped tests
        selftests: static_keys: return Kselftest Skip code for skipped tests
        selftests: user: return Kselftest Skip code for skipped tests
        selftests: zram: return Kselftest Skip code for skipped tests
        selftests: sync: add config fragment for testing sync framework
        ARM: dts: Cygnus: Fix I2C controller interrupt type
        usb: dwc2: fix isoc split in transfer with no data
        usb: gadget: composite: fix delayed_status race condition when set_interface
        usb: gadget: dwc2: fix memory leak in gadget_init()
        scsi: xen-scsifront: add error handling for xenbus_printf
        arm64: make secondary_start_kernel() notrace
        qed: Add sanity check for SIMD fastpath handler.
        enic: initialize enic->rfs_h.lock in enic_probe
        net: hamradio: use eth_broadcast_addr
        net: propagate dev_get_valid_name return code
        ARC: Enable machine_desc->init_per_cpu for !CONFIG_SMP
        net: davinci_emac: match the mdio device against its compatible if possible
        locking/lockdep: Do not record IRQ state within lockdep code
        ipv6: mcast: fix unsolicited report interval after receiving querys
        Smack: Mark inode instant in smack_task_to_inode
        cxgb4: when disabling dcb set txq dcb priority to 0
        brcmfmac: stop watchdog before detach and free everything
        ARM: dts: am437x: make edt-ft5x06 a wakeup source
        usb: xhci: increase CRS timeout value
        perf test session topology: Fix test on s390
        perf report powerpc: Fix crash if callchain is empty
        selftests/x86/sigreturn/64: Fix spurious failures on AMD CPUs
        ARM: dts: da850: Fix interrups property for gpio
        dmaengine: k3dma: Off by one in k3_of_dma_simple_xlate()
        md/raid10: fix that replacement cannot complete recovery after reassemble
        drm/exynos: gsc: Fix support for NV16/61, YUV420/YVU420 and YUV422 modes
        drm/exynos: decon5433: Fix per-plane global alpha for XRGB modes
        drm/exynos: decon5433: Fix WINCONx reset value
        bnx2x: Fix receiving tx-timeout in error or recovery state.
        m68k: fix "bad page state" oops on ColdFire boot
        HID: wacom: Correct touch maximum XY of 2nd-gen Intuos
        ARM: imx_v6_v7_defconfig: Select ULPI support
        ARM: imx_v4_v5_defconfig: Select ULPI support
        tracing: Use __printf markup to silence compiler
        kasan: fix shadow_size calculation error in kasan_module_alloc
        smsc75xx: Add workaround for gigabit link up hardware errata.
        netfilter: x_tables: set module owner for icmp(6) matches
        ARM: pxa: irq: fix handling of ICMR registers in suspend/resume
        ieee802154: at86rf230: switch from BUG_ON() to WARN_ON() on problem
        ieee802154: at86rf230: use __func__ macro for debug messages
        ieee802154: fakelb: switch from BUG_ON() to WARN_ON() on problem
        drm/armada: fix colorkey mode property
        bnxt_en: Fix for system hang if request_irq fails
        perf llvm-utils: Remove bashism from kernel include fetch script
        ARM: 8780/1: ftrace: Only set kernel memory back to read-only after boot
        ARM: dts: am3517.dtsi: Disable reference to OMAP3 OTG controller
        ixgbe: Be more careful when modifying MAC filters
        packet: reset network header if packet shorter than ll reserved space
        qlogic: check kstrtoul() for errors
        tcp: remove DELAYED ACK events in DCTCP
        drm/nouveau/gem: off by one bugs in nouveau_gem_pushbuf_reloc_apply()
        net/ethernet/freescale/fman: fix cross-build error
        net: usb: rtl8150: demote allmulti message to dev_dbg()
        net: qca_spi: Avoid packet drop during initial sync
        net: qca_spi: Make sure the QCA7000 reset is triggered
        net: qca_spi: Fix log level if probe fails
        tcp: identify cryptic messages as TCP seq # bugs
        staging: android: ion: check for kref overflow
        KVM: irqfd: fix race between EPOLLHUP and irq_bypass_register_consumer
        ext4: fix spectre gadget in ext4_mb_regular_allocator()
        parisc: Remove ordered stores from syscall.S
        xfrm_user: prevent leaking 2 bytes of kernel memory
        netfilter: conntrack: dccp: treat SYNC/SYNCACK as invalid if no prior state
        packet: refine ring v3 block size test to hold one frame
        bridge: Propagate vlan add failure to user
        parisc: Remove unnecessary barriers from spinlock.h
        PCI: hotplug: Don't leak pci_slot on registration failure
        PCI: Skip MPS logic for Virtual Functions (VFs)
        PCI: pciehp: Fix use-after-free on unplug
        i2c: imx: Fix race condition in dma read
        reiserfs: fix broken xattr handling (heap corruption, bad retval)
        Linux 4.4.152

Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>

Conflicts:
	drivers/staging/android/ion/ion.c
2018-08-24 07:53:30 -07:00
Paolo Bonzini
1186a6ea75 KVM: irqfd: fix race between EPOLLHUP and irq_bypass_register_consumer
commit 9432a3175770e06cb83eada2d91fac90c977cb99 upstream.

A comment warning against this bug is there, but the code is not doing what
the comment says.  Therefore it is possible that an EPOLLHUP races against
irq_bypass_register_consumer.  The EPOLLHUP handler schedules irqfd_shutdown,
and if that runs soon enough, you get a use-after-free.

Reported-by: syzbot <syzkaller@googlegroups.com>
Cc: stable@vger.kernel.org
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: David Hildenbrand <david@redhat.com>
Signed-off-by: Sudip Mukherjee <sudipm.mukherjee@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-08-24 13:27:00 +02:00
Nathan Chancellor
1c1c5864b2 Merge 4.4.144 into android-msm-wahoo-4.4
Changes in 4.4.144: (108 commits)
        KVM/Eventfd: Avoid crash when assign and deassign specific eventfd in parallel.
        x86/MCE: Remove min interval polling limitation
        fat: fix memory allocation failure handling of match_strdup()
        ALSA: rawmidi: Change resized buffers atomically
        ARC: Fix CONFIG_SWAP
        ARC: mm: allow mprotect to make stack mappings executable
        mm: memcg: fix use after free in mem_cgroup_iter()
        ipv4: Return EINVAL when ping_group_range sysctl doesn't map to user ns
        ipv6: fix useless rol32 call on hash
        lib/rhashtable: consider param->min_size when setting initial table size
        net/ipv4: Set oif in fib_compute_spec_dst
        net: phy: fix flag masking in __set_phy_supported
        ptp: fix missing break in switch
        tg3: Add higher cpu clock for 5762.
        net: Don't copy pfmemalloc flag in __copy_skb_header()
        skbuff: Unconditionally copy pfmemalloc in __skb_clone()
        xhci: Fix perceived dead host due to runtime suspend race with event handler
        x86/paravirt: Make native_save_fl() extern inline
        x86/cpufeatures: Add CPUID_7_EDX CPUID leaf
        x86/cpufeatures: Add Intel feature bits for Speculation Control
        x86/cpufeatures: Add AMD feature bits for Speculation Control
        x86/msr: Add definitions for new speculation control MSRs
        x86/pti: Do not enable PTI on CPUs which are not vulnerable to Meltdown
        x86/cpufeature: Blacklist SPEC_CTRL/PRED_CMD on early Spectre v2 microcodes
        x86/speculation: Add basic IBPB (Indirect Branch Prediction Barrier) support
        x86/cpufeatures: Clean up Spectre v2 related CPUID flags
        x86/cpuid: Fix up "virtual" IBRS/IBPB/STIBP feature bits on Intel
        x86/pti: Mark constant arrays as __initconst
        x86/asm/entry/32: Simplify pushes of zeroed pt_regs->REGs
        x86/entry/64/compat: Clear registers for compat syscalls, to reduce speculation attack surface
        x86/speculation: Update Speculation Control microcode blacklist
        x86/speculation: Correct Speculation Control microcode blacklist again
        x86/speculation: Clean up various Spectre related details
        x86/speculation: Fix up array_index_nospec_mask() asm constraint
        x86/speculation: Add <asm/msr-index.h> dependency
        x86/xen: Zero MSR_IA32_SPEC_CTRL before suspend
        x86/mm: Factor out LDT init from context init
        x86/mm: Give each mm TLB flush generation a unique ID
        x86/speculation: Use Indirect Branch Prediction Barrier in context switch
        x86/spectre_v2: Don't check microcode versions when running under hypervisors
        x86/speculation: Use IBRS if available before calling into firmware
        x86/speculation: Move firmware_restrict_branch_speculation_*() from C to CPP
        x86/speculation: Remove Skylake C2 from Speculation Control microcode blacklist
        selftest/seccomp: Fix the flag name SECCOMP_FILTER_FLAG_TSYNC
        selftest/seccomp: Fix the seccomp(2) signature
        xen: set cpu capabilities from xen_start_kernel()
        x86/amd: don't set X86_BUG_SYSRET_SS_ATTRS when running under Xen
        x86/nospec: Simplify alternative_msr_write()
        x86/bugs: Concentrate bug detection into a separate function
        x86/bugs: Concentrate bug reporting into a separate function
        x86/bugs: Read SPEC_CTRL MSR during boot and re-use reserved bits
        x86/bugs, KVM: Support the combination of guest and host IBRS
        x86/cpu: Rename Merrifield2 to Moorefield
        x86/cpu/intel: Add Knights Mill to Intel family
        x86/bugs: Expose /sys/../spec_store_bypass
        x86/cpufeatures: Add X86_FEATURE_RDS
        x86/bugs: Provide boot parameters for the spec_store_bypass_disable mitigation
        x86/bugs/intel: Set proper CPU features and setup RDS
        x86/bugs: Whitelist allowed SPEC_CTRL MSR values
        x86/bugs/AMD: Add support to disable RDS on Fam[15, 16, 17]h if requested
        x86/speculation: Create spec-ctrl.h to avoid include hell
        prctl: Add speculation control prctls
        x86/process: Optimize TIF checks in __switch_to_xtra()
        x86/process: Correct and optimize TIF_BLOCKSTEP switch
        x86/process: Optimize TIF_NOTSC switch
        x86/process: Allow runtime control of Speculative Store Bypass
        x86/speculation: Add prctl for Speculative Store Bypass mitigation
        nospec: Allow getting/setting on non-current task
        proc: Provide details on speculation flaw mitigations
        seccomp: Enable speculation flaw mitigations
        prctl: Add force disable speculation
        seccomp: Use PR_SPEC_FORCE_DISABLE
        seccomp: Add filter flag to opt-out of SSB mitigation
        seccomp: Move speculation migitation control to arch code
        x86/speculation: Make "seccomp" the default mode for Speculative Store Bypass
        x86/bugs: Rename _RDS to _SSBD
        proc: Use underscores for SSBD in 'status'
        Documentation/spec_ctrl: Do some minor cleanups
        x86/bugs: Fix __ssb_select_mitigation() return type
        x86/bugs: Make cpu_show_common() static
        x86/bugs: Fix the parameters alignment and missing void
        x86/cpu: Make alternative_msr_write work for 32-bit code
        x86/speculation: Use synthetic bits for IBRS/IBPB/STIBP
        x86/cpufeatures: Disentangle MSR_SPEC_CTRL enumeration from IBRS
        x86/cpufeatures: Disentangle SSBD enumeration
        x86/cpu/AMD: Fix erratum 1076 (CPB bit)
        x86/cpufeatures: Add FEATURE_ZEN
        x86/speculation: Handle HT correctly on AMD
        x86/bugs, KVM: Extend speculation control for VIRT_SPEC_CTRL
        x86/speculation: Add virtualized speculative store bypass disable support
        x86/speculation: Rework speculative_store_bypass_update()
        x86/bugs: Unify x86_spec_ctrl_{set_guest, restore_host}
        x86/bugs: Expose x86_spec_ctrl_base directly
        x86/bugs: Remove x86_spec_ctrl_set()
        x86/bugs: Rework spec_ctrl base and mask logic
        x86/speculation, KVM: Implement support for VIRT_SPEC_CTRL/LS_CFG
        x86/bugs: Rename SSBD_NO to SSB_NO
        x86/xen: Add call of speculative_store_bypass_ht_init() to PV paths
        x86/cpu: Re-apply forced caps every time CPU caps are re-read
        block: do not use interruptible wait anywhere
        clk: tegra: Fix PLL_U post divider and initial rate on Tegra30
        ubi: Introduce vol_ignored()
        ubi: Rework Fastmap attach base code
        ubi: Be more paranoid while seaching for the most recent Fastmap
        ubi: Fix races around ubi_refill_pools()
        ubi: Fix Fastmap's update_vol()
        ubi: fastmap: Erase outdated anchor PEBs during attach
        Linux 4.4.144

Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>

Conflicts:
	drivers/mtd/ubi/wl.c
	include/uapi/linux/prctl.h
	kernel/sys.c
	sound/core/rawmidi.c
2018-07-25 06:18:25 -07:00
Lan Tianyu
49e065f504 KVM/Eventfd: Avoid crash when assign and deassign specific eventfd in parallel.
commit b5020a8e6b54d2ece80b1e7dedb33c79a40ebd47 upstream.

Syzbot reports crashes in kvm_irqfd_assign(), caused by use-after-free
when kvm_irqfd_assign() and kvm_irqfd_deassign() run in parallel
for one specific eventfd. When the assign path hasn't finished but irqfd
has been added to kvm->irqfds.items list, another thead may deassign the
eventfd and free struct kvm_kernel_irqfd(). The assign path then uses
the struct kvm_kernel_irqfd that has been freed by deassign path. To avoid
such issue, keep irqfd under kvm->irq_srcu protection after the irqfd
has been added to kvm->irqfds.items list, and call synchronize_srcu()
in irq_shutdown() to make sure that irqfd has been fully initialized in
the assign path.

Reported-by: Dmitry Vyukov <dvyukov@google.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: Radim Krčmář <rkrcmar@redhat.com>
Cc: Dmitry Vyukov <dvyukov@google.com>
Signed-off-by: Tianyu Lan <tianyu.lan@intel.com>
Cc: stable@vger.kernel.org
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-07-25 10:18:15 +02:00
Nathan Chancellor
f1443bcf82 Merge 4.4.121 into android-msm-wahoo-4.4-oreo-mr1
Changes in 4.4.121: (37 commits)
        tpm: st33zp24: fix potential buffer overruns caused by bit glitches on the bus
        tpm_i2c_infineon: fix potential buffer overruns caused by bit glitches on the bus
        tpm_i2c_nuvoton: fix potential buffer overruns caused by bit glitches on the bus
        ALSA: usb-audio: Add a quirck for B&W PX headphones
        ALSA: hda: Add a power_save blacklist
        cpufreq: s3c24xx: Fix broken s3c_cpufreq_init()
        media: m88ds3103: don't call a non-initalized function
        nospec: Allow index argument to have const-qualified type
        ARM: mvebu: Fix broken PL310_ERRATA_753970 selects
        KVM: mmu: Fix overlap between public and private memslots
        x86/syscall: Sanitize syscall table de-references under speculation fix
        btrfs: Don't clear SGID when inheriting ACLs
        ARM: dts: LogicPD Torpedo: Fix I2C1 pinmux
        x86/apic/vector: Handle legacy irq data correctly
        leds: do not overflow sysfs buffer in led_trigger_show
        x86/spectre: Fix an error message
        Revert "led: core: Fix brightness setting when setting delay_off=0"
        bridge: check brport attr show in brport_show
        fib_semantics: Don't match route with mismatching tclassid
        hdlc_ppp: carrier detect ok, don't turn off negotiation
        ipv6 sit: work around bogus gcc-8 -Wrestrict warning
        net: fix race on decreasing number of TX queues
        net: ipv4: don't allow setting net.ipv4.route.min_pmtu below 68
        netlink: ensure to loop over all netns in genlmsg_multicast_allns()
        ppp: prevent unregistered channels from connecting to PPP units
        udplite: fix partial checksum initialization
        sctp: fix dst refcnt leak in sctp_v4_get_dst
        sctp: fix dst refcnt leak in sctp_v6_get_dst()
        s390/qeth: fix SETIP command handling
        s390/qeth: fix IPA command submission race
        sctp: verify size of a new chunk in _sctp_make_chunk()
        net: mpls: Pull common label check into helper
        mpls, nospec: Sanitize array index in mpls_label_ok()
        dm io: fix duplicate bio completion due to missing ref count
        bpf, x64: implement retpoline for tail call
        btrfs: preserve i_mode if __btrfs_set_acl() fails
        Linux 4.4.121

Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
2018-03-11 10:23:14 -07:00
Wanpeng Li
42f587fa77 KVM: mmu: Fix overlap between public and private memslots
commit b28676bb8ae4569cced423dc2a88f7cb319d5379 upstream.

Reported by syzkaller:

    pte_list_remove: ffff9714eb1f8078 0->BUG
    ------------[ cut here ]------------
    kernel BUG at arch/x86/kvm/mmu.c:1157!
    invalid opcode: 0000 [#1] SMP
    RIP: 0010:pte_list_remove+0x11b/0x120 [kvm]
    Call Trace:
     drop_spte+0x83/0xb0 [kvm]
     mmu_page_zap_pte+0xcc/0xe0 [kvm]
     kvm_mmu_prepare_zap_page+0x81/0x4a0 [kvm]
     kvm_mmu_invalidate_zap_all_pages+0x159/0x220 [kvm]
     kvm_arch_flush_shadow_all+0xe/0x10 [kvm]
     kvm_mmu_notifier_release+0x6c/0xa0 [kvm]
     ? kvm_mmu_notifier_release+0x5/0xa0 [kvm]
     __mmu_notifier_release+0x79/0x110
     ? __mmu_notifier_release+0x5/0x110
     exit_mmap+0x15a/0x170
     ? do_exit+0x281/0xcb0
     mmput+0x66/0x160
     do_exit+0x2c9/0xcb0
     ? __context_tracking_exit.part.5+0x4a/0x150
     do_group_exit+0x50/0xd0
     SyS_exit_group+0x14/0x20
     do_syscall_64+0x73/0x1f0
     entry_SYSCALL64_slow_path+0x25/0x25

The reason is that when creates new memslot, there is no guarantee for new
memslot not overlap with private memslots. This can be triggered by the
following program:

   #include <fcntl.h>
   #include <pthread.h>
   #include <setjmp.h>
   #include <signal.h>
   #include <stddef.h>
   #include <stdint.h>
   #include <stdio.h>
   #include <stdlib.h>
   #include <string.h>
   #include <sys/ioctl.h>
   #include <sys/stat.h>
   #include <sys/syscall.h>
   #include <sys/types.h>
   #include <unistd.h>
   #include <linux/kvm.h>

   long r[16];

   int main()
   {
	void *p = valloc(0x4000);

	r[2] = open("/dev/kvm", 0);
	r[3] = ioctl(r[2], KVM_CREATE_VM, 0x0ul);

	uint64_t addr = 0xf000;
	ioctl(r[3], KVM_SET_IDENTITY_MAP_ADDR, &addr);
	r[6] = ioctl(r[3], KVM_CREATE_VCPU, 0x0ul);
	ioctl(r[3], KVM_SET_TSS_ADDR, 0x0ul);
	ioctl(r[6], KVM_RUN, 0);
	ioctl(r[6], KVM_RUN, 0);

	struct kvm_userspace_memory_region mr = {
		.slot = 0,
		.flags = KVM_MEM_LOG_DIRTY_PAGES,
		.guest_phys_addr = 0xf000,
		.memory_size = 0x4000,
		.userspace_addr = (uintptr_t) p
	};
	ioctl(r[3], KVM_SET_USER_MEMORY_REGION, &mr);
	return 0;
   }

This patch fixes the bug by not adding a new memslot even if it
overlaps with private memslots.

Reported-by: Dmitry Vyukov <dvyukov@google.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: Radim Krčmář <rkrcmar@redhat.com>
Cc: Dmitry Vyukov <dvyukov@google.com>
Cc: Eric Biggers <ebiggers3@gmail.com>
Cc: stable@vger.kernel.org
Signed-off-by: Wanpeng Li <wanpeng.li@hotmail.com>
2018-03-11 16:19:45 +01:00
Nathan Chancellor
40bb3b9e1a Merge 4.4.108 into android-msm-wahoo-4.4-oreo-mr1
Changes in 4.4.108: (79 commits)
        arm64: Initialise high_memory global variable earlier
        cxl: Check if vphb exists before iterating over AFU devices
        x86/mm: Add INVPCID helpers
        x86/mm: Fix INVPCID asm constraint
        x86/mm: Add a 'noinvpcid' boot option to turn off INVPCID
        x86/mm: If INVPCID is available, use it to flush global mappings
        mm/rmap: batched invalidations should use existing api
        mm/mmu_context, sched/core: Fix mmu_context.h assumption
        sched/core: Add switch_mm_irqs_off() and use it in the scheduler
        x86/mm: Build arch/x86/mm/tlb.c even on !SMP
        x86/mm, sched/core: Uninline switch_mm()
        x86/mm, sched/core: Turn off IRQs in switch_mm()
        ARM: Hide finish_arch_post_lock_switch() from modules
        sched/core: Idle_task_exit() shouldn't use switch_mm_irqs_off()
        x86/irq: Do not substract irq_tlb_count from irq_call_count
        ALSA: hda - add support for docking station for HP 820 G2
        ALSA: hda - add support for docking station for HP 840 G3
        arm: kprobes: Fix the return address of multiple kretprobes
        arm: kprobes: Align stack to 8-bytes in test code
        cpuidle: Validate cpu_dev in cpuidle_add_sysfs()
        r8152: fix the list rx_done may be used without initialization
        crypto: deadlock between crypto_alg_sem/rtnl_mutex/genl_mutex
        sch_dsmark: fix invalid skb_cow() usage
        bna: integer overflow bug in debugfs
        net: qmi_wwan: Add USB IDs for MDM6600 modem on Motorola Droid 4
        usb: gadget: f_uvc: Sanity check wMaxPacketSize for SuperSpeed
        usb: gadget: udc: remove pointer dereference after free
        netfilter: nfnl_cthelper: fix runtime expectation policy updates
        netfilter: nfnl_cthelper: Fix memory leak
        inet: frag: release spinlock before calling icmp_send()
        pinctrl: st: add irq_request/release_resources callbacks
        scsi: lpfc: Fix PT2PT PRLI reject
        KVM: x86: correct async page present tracepoint
        KVM: VMX: Fix enable VPID conditions
        ARM: dts: ti: fix PCI bus dtc warnings
        hwmon: (asus_atk0110) fix uninitialized data access
        HID: xinmo: fix for out of range for THT 2P arcade controller.
        r8152: prevent the driver from transmitting packets with carrier off
        s390/qeth: no ETH header for outbound AF_IUCV
        bna: avoid writing uninitialized data into hw registers
        net: Do not allow negative values for busy_read and busy_poll sysctl interfaces
        i40e: Do not enable NAPI on q_vectors that have no rings
        RDMA/iser: Fix possible mr leak on device removal event
        irda: vlsi_ir: fix check for DMA mapping errors
        netfilter: nfnl_cthelper: fix a race when walk the nf_ct_helper_hash table
        netfilter: nf_nat_snmp: Fix panic when snmp_trap_helper fails to register
        ARM: dts: am335x-evmsk: adjust mmc2 param to allow suspend
        KVM: pci-assign: do not map smm memory slot pages in vt-d page tables
        isdn: kcapi: avoid uninitialized data
        xhci: plat: Register shutdown for xhci_plat
        netfilter: nfnetlink_queue: fix secctx memory leak
        ARM: dma-mapping: disallow dma_get_sgtable() for non-kernel managed memory
        cpuidle: powernv: Pass correct drv->cpumask for registration
        bnxt_en: Fix NULL pointer dereference in reopen failure path
        backlight: pwm_bl: Fix overflow condition
        crypto: crypto4xx - increase context and scatter ring buffer elements
        rtc: pl031: make interrupt optional
        net: phy: at803x: Change error to EINVAL for invalid MAC
        PCI: Avoid bus reset if bridge itself is broken
        scsi: cxgb4i: fix Tx skb leak
        scsi: mpt3sas: Fix IO error occurs on pulling out a drive from RAID1 volume created on two SATA drive
        PCI: Create SR-IOV virtfn/physfn links before attaching driver
        igb: check memory allocation failure
        ixgbe: fix use of uninitialized padding
        PCI/AER: Report non-fatal errors only to the affected endpoint
        scsi: lpfc: Fix secure firmware updates
        scsi: lpfc: PLOGI failures during NPIV testing
        fm10k: ensure we process SM mbx when processing VF mbx
        tcp: fix under-evaluated ssthresh in TCP Vegas
        rtc: set the alarm to the next expiring timer
        cpuidle: fix broadcast control when broadcast can not be entered
        thermal: hisilicon: Handle return value of clk_prepare_enable
        MIPS: math-emu: Fix final emulation phase for certain instructions
        Revert "Bluetooth: btusb: driver to enable the usb-wakeup feature"
        ALSA: hda - Clear the leftover component assignment at snd_hdac_i915_exit()
        ALSA: hda - Degrade i915 binding failure message
        ALSA: hda - Fix yet another i915 pointer leftover in error path
        alpha: fix build failures
        Linux 4.4.108

Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
2017-12-25 08:11:49 -07:00
Herongguang (Stephen)
f15394085d KVM: pci-assign: do not map smm memory slot pages in vt-d page tables
[ Upstream commit 0292e169b2d9c8377a168778f0b16eadb1f578fd ]

or VM memory are not put thus leaked in kvm_iommu_unmap_memslots() when
destroy VM.

This is consistent with current vfio implementation.

Signed-off-by: herongguang <herongguang.he@huawei.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Sasha Levin <alexander.levin@verizon.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-12-25 14:22:13 +01:00
Nathan Chancellor
e4a2ad5046 Merge 4.4.105 into android-msm-wahoo-4.4-oreo-mr1
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>

Conflicts:
	drivers/gpu/drm/msm/msm_gem_submit.c
	drivers/media/v4l2-core/v4l2-compat-ioctl32.c
	drivers/mmc/core/bus.c
	drivers/net/wireless/iwlwifi/iwl-nvm-parse.c
	drivers/scsi/ufs/ufshcd.h
	kernel/power/process.c
	net/wireless/nl80211.c
	sound/usb/card.c
2017-12-09 13:44:10 -07:00
Christoffer Dall
48222dd037 KVM: arm/arm64: Fix occasional warning from the timer work function
[ Upstream commit 63e41226afc3f7a044b70325566fa86ac3142538 ]

When a VCPU blocks (WFI) and has programmed the vtimer, we program a
soft timer to expire in the future to wake up the vcpu thread when
appropriate.  Because such as wake up involves a vcpu kick, and the
timer expire function can get called from interrupt context, and the
kick may sleep, we have to schedule the kick in the work function.

The work function currently has a warning that gets raised if it turns
out that the timer shouldn't fire when it's run, which was added because
the idea was that in that case the work should never have been cancelled.

However, it turns out that this whole thing is racy and we can get
spurious warnings.  The problem is that we clear the armed flag in the
work function, which may run in parallel with the
kvm_timer_unschedule->timer_disarm() call.  This results in a possible
situation where the timer_disarm() call does not call
cancel_work_sync(), which effectively synchronizes the completion of the
work function with running the VCPU.  As a result, the VCPU thread
proceeds before the work function completees, causing changes to the
timer state such that kvm_timer_should_fire(vcpu) returns false in the
work function.

All we do in the work function is to kick the VCPU, and an occasional
rare extra kick never harmed anyone.  Since the race above is extremely
rare, we don't bother checking if the race happens but simply remove the
check and the clearing of the armed flag from the work function.

Reported-by: Matthias Brugger <mbrugger@suse.com>
Reviewed-by: Marc Zyngier <marc.zyngier@arm.com>
Signed-off-by: Christoffer Dall <christoffer.dall@linaro.org>
Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
Signed-off-by: Sasha Levin <alexander.levin@verizon.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-12-09 18:42:42 +01:00
Thierry Strudel
75c8bc7183 Merged linux-4.4.80 into android-msm-wahoo-4.4
Linux 4.4.80
    ASoC: dpcm: Avoid putting stream state to STOP when FE stream is paused
    scsi: snic: Return error code on memory allocation failure
    scsi: fnic: Avoid sending reset to firmware when another reset is in progress
    HID: ignore Petzl USB headlamp
    ALSA: usb-audio: test EP_FLAG_RUNNING at urb completion
    sh_eth: enable RX descriptor word 0 shift on SH7734
    nvmem: imx-ocotp: Fix wrong register size
    arm64: mm: fix show_pte KERN_CONT fallout
    vfio-pci: Handle error from pci_iomap
    video: fbdev: cobalt_lcdfb: Handle return NULL error from devm_ioremap
    perf symbols: Robustify reading of build-id from sysfs
    perf tools: Install tools/lib/traceevent plugins with install-bin
    xfrm: Don't use sk_family for socket policy lookups
    tools lib traceevent: Fix prev/next_prio for deadline tasks
    Btrfs: adjust outstanding_extents counter properly when dio write is split
    usb: gadget: Fix copy/pasted error message
    ACPI / scan: Prefer devices without _HID/_CID for _ADR matching
    ARM: s3c2410_defconfig: Fix invalid values for NF_CT_PROTO_*
    ARM64: zynqmp: Fix i2c node's compatible string
    ARM64: zynqmp: Fix W=1 dtc 1.4 warnings
    dmaengine: ti-dma-crossbar: Add some 'of_node_put()' in error path.
    dmaengine: ioatdma: workaround SKX ioatdma version
    dmaengine: ioatdma: Add Skylake PCI Dev ID
    openrisc: Add _text symbol to fix ksym build error
    irqchip/mxs: Enable SKIP_SET_WAKE and MASK_ON_SUSPEND
    ASoC: nau8825: fix invalid configuration in Pre-Scalar of FLL
    spi: dw: Make debugfs name unique between instances
    ASoC: tlv320aic3x: Mark the RESET register as volatile
    irqchip/keystone: Fix "scheduling while atomic" on rt
    vfio-pci: use 32-bit comparisons for register address for gcc-4.5
    drm/msm: Verify that MSM_SUBMIT_BO_FLAGS are set
    drm/msm: Ensure that the hardware write pointer is valid
    net/mlx4: Remove BUG_ON from ICM allocation routine
    ipv6: Should use consistent conditional judgement for ip6 fragment between __ip6_append_data and ip6_finish_output
    ARM: dts: n900: Mark eMMC slot with no-sdio and no-sd flags
    r8169: add support for RTL8168 series add-on card.
    x86/mce/AMD: Make the init code more robust
    tpm: Replace device number bitmap with IDR
    tpm: fix a kernel memory leak in tpm-sysfs.c
    xen/blkback: don't use xen_blkif_get() in xen-blkback kthread
    xen/blkback: don't free be structure too early
    sched/cputime: Fix prev steal time accouting during CPU hotplug
    net: skb_needs_check() accepts CHECKSUM_NONE for tx
    pstore: Use dynamic spinlock initializer
    pstore: Correctly initialize spinlock and flags
    pstore: Allow prz to control need for locking
    vlan: Propagate MAC address to VLANs
    /proc/iomem: only expose physical resource addresses to privileged users
    Make file credentials available to the seqfile interfaces
    v4l: s5c73m3: fix negation operator
    dentry name snapshots
    ipmi/watchdog: fix watchdog timeout set on reboot
    libnvdimm, btt: fix btt_rw_page not returning errors
    RDMA/uverbs: Fix the check for port number
    PM / Domains: defer dev_pm_domain_set() until genpd->attach_dev succeeds if present
    sched/cgroup: Move sched_online_group() back into css_online() to fix crash
    kaweth: fix oops upon failed memory allocation
    kaweth: fix firmware download
    mpt3sas: Don't overreach ioc->reply_post[] during initialization
    mailbox: handle empty message in tx_tick
    mailbox: skip complete wait event if timer expired
    mailbox: always wait in mbox_send_message for blocking Tx mode
    wil6210: fix deadlock when using fw_no_recovery option
    ath10k: fix null deref on wmi-tlv when trying spectral scan
    isdn/i4l: fix buffer overflow
    isdn: Fix a sleep-in-atomic bug
    net: phy: Do not perform software reset for Generic PHY
    nfc: fdp: fix NULL pointer dereference
    xfs: don't BUG() on mixed direct and mapped I/O
    perf intel-pt: Ensure never to set 'last_ip' when packet 'count' is zero
    perf intel-pt: Use FUP always when scanning for an IP
    perf intel-pt: Fix last_ip usage
    perf intel-pt: Fix ip compression
    drm: rcar-du: Simplify and fix probe error handling
    drm: rcar-du: Perform initialization/cleanup at probe/remove time
    drm/rcar: Nuke preclose hook
    Staging: comedi: comedi_fops: Avoid orphaned proc entry
    Revert "powerpc/numa: Fix percpu allocations to be NUMA aware"
    KVM: PPC: Book3S HV: Save/restore host values of debug registers
    KVM: PPC: Book3S HV: Reload HTM registers explicitly
    KVM: PPC: Book3S HV: Restore critical SPRs to host values on guest exit
    KVM: PPC: Book3S HV: Context-switch EBB registers properly
    drm/nouveau/bar/gf100: fix access to upper half of BAR2
    drm/vmwgfx: Fix gcc-7.1.1 warning
    md/raid5: add thread_group worker async_tx_issue_pending_all
    crypto: authencesn - Fix digest_null crash
    powerpc/pseries: Fix of_node_put() underflow during reconfig remove
    net: reduce skb_warn_bad_offload() noise
    pstore: Make spinlock per zone instead of global
    af_key: Add lock to key dump
Linux 4.4.79
    alarmtimer: don't rate limit one-shot timers
    tracing: Fix kmemleak in instance_rmdir
    spmi: Include OF based modalias in device uevent
    of: device: Export of_device_{get_modalias, uvent_modalias} to modules
    drm/mst: Avoid processing partially received up/down message transactions
    drm/mst: Avoid dereferencing a NULL mstb in drm_dp_mst_handle_up_req()
    drm/mst: Fix error handling during MST sideband message reception
    RDMA/core: Initialize port_num in qp_attr
    ceph: fix race in concurrent readdir
    staging: rtl8188eu: add TL-WN722N v2 support
    Revert "perf/core: Drop kernel samples even though :u is specified"
    perf annotate: Fix broken arrow at row 0 connecting jmp instruction to its target
    target: Fix COMPARE_AND_WRITE caw_sem leak during se_cmd quiesce
    udf: Fix deadlock between writeback and udf_setsize()
    NFS: only invalidate dentrys that are clearly invalid.
    Input: i8042 - fix crash at boot time
    MIPS: Fix a typo: s/preset/present/ in r2-to-r6 emulation error message
    MIPS: Send SIGILL for linked branches in `__compute_return_epc_for_insn'
    MIPS: Rename `sigill_r6' to `sigill_r2r6' in `__compute_return_epc_for_insn'
    MIPS: Send SIGILL for BPOSGE32 in `__compute_return_epc_for_insn'
    MIPS: math-emu: Prevent wrong ISA mode instruction emulation
    MIPS: Fix unaligned PC interpretation in `compute_return_epc'
    MIPS: Actually decode JALX in `__compute_return_epc_for_insn'
    MIPS: Save static registers before sysmips
    MIPS: Fix MIPS I ISA /proc/cpuinfo reporting
    x86/ioapic: Pass the correct data to unmask_ioapic_irq()
    x86/acpi: Prevent out of bound access caused by broken ACPI tables
    MIPS: Negate error syscall return in trace
    MIPS: Fix mips_atomic_set() with EVA
    MIPS: Fix mips_atomic_set() retry condition
    ftrace: Fix uninitialized variable in match_records()
    vfio: New external user group/file match
    vfio: Fix group release deadlock
    f2fs: Don't clear SGID when inheriting ACLs
    ipmi:ssif: Add missing unlock in error branch
    ipmi: use rcu lock around call to intf->handlers->sender()
    drm/radeon: Fix eDP for single-display iMac10,1 (v2)
    drm/radeon/ci: disable mclk switching for high refresh rates (v2)
    drm/amd/amdgpu: Return error if initiating read out of range on vram
    s390/syscalls: Fix out of bounds arguments access
    Raid5 should update rdev->sectors after reshape
    cx88: Fix regression in initial video standard setting
    x86/xen: allow userspace access during hypercalls
    md: don't use flush_signals in userspace processes
    usb: renesas_usbhs: gadget: disable all eps when the driver stops
    usb: renesas_usbhs: fix usbhsc_resume() for !USBHSF_RUNTIME_PWCTRL
    USB: cdc-acm: add device-id for quirky printer
    usb: storage: return on error to avoid a null pointer dereference
    xhci: Fix NULL pointer dereference when cleaning up streams for removed host
    xhci: fix 20000ms port resume timeout
    ipvs: SNAT packet replies only for NATed connections
    PCI/PM: Restore the status of PCI devices across hibernation
    af_key: Fix sadb_x_ipsecrequest parsing
    powerpc/asm: Mark cr0 as clobbered in mftb()
    powerpc: Fix emulation of mfocrf in emulate_step()
    powerpc: Fix emulation of mcrf in emulate_step()
    powerpc/64: Fix atomic64_inc_not_zero() to return an int
    iscsi-target: Add login_keys_workaround attribute for non RFC initiators
    scsi: ses: do not add a device to an enclosure if enclosure_add_links() fails.
    PM / Domains: Fix unsafe iteration over modified list of domain providers
    PM / Domains: Fix unsafe iteration over modified list of device links
    ASoC: compress: Derive substream from stream based on direction
    wlcore: fix 64K page support
    Bluetooth: use constant time memory comparison for secret values
    perf intel-pt: Clear FUP flag on error
    perf intel-pt: Ensure IP is zero when state is INTEL_PT_STATE_NO_IP
    perf intel-pt: Fix missing stack clear
    perf intel-pt: Improve sample timestamp
    perf intel-pt: Move decoder error setting into one condition
    NFC: Add sockaddr length checks before accessing sa_family in bind handlers
    nfc: Fix the sockaddr length sanitization in llcp_sock_connect
    nfc: Ensure presence of required attributes in the activate_target handler
    NFC: nfcmrvl: fix firmware-management initialisation
    NFC: nfcmrvl: use nfc-device for firmware download
    NFC: nfcmrvl: do not use device-managed resources
    NFC: nfcmrvl_uart: add missing tty-device sanity check
    NFC: fix broken device allocation
    ath9k: fix tx99 bus error
    ath9k: fix tx99 use after free
    thermal: cpu_cooling: Avoid accessing potentially freed structures
    s5p-jpeg: don't return a random width/height
    ir-core: fix gcc-7 warning on bool arithmetic
    disable new gcc-7.1.1 warnings for now
Linux 4.4.78
    kvm: vmx: allow host to access guest MSR_IA32_BNDCFGS
    kvm: vmx: Check value written to IA32_BNDCFGS
    kvm: x86: Guest BNDCFGS requires guest MPX support
    kvm: vmx: Do not disable intercepts for BNDCFGS
    KVM: x86: disable MPX if host did not enable MPX XSAVE features
    tracing: Use SOFTIRQ_OFFSET for softirq dectection for more accurate results
    PM / QoS: return -EINVAL for bogus strings
    PM / wakeirq: Convert to SRCU
    sched/topology: Optimize build_group_mask()
    sched/topology: Fix overlapping sched_group_mask
    crypto: caam - fix signals handling
    crypto: sha1-ssse3 - Disable avx2
    crypto: atmel - only treat EBUSY as transient if backlog
    crypto: talitos - Extend max key length for SHA384/512-HMAC and AEAD
    mm: fix overflow check in expand_upwards()
    tpm: Issue a TPM2_Shutdown for TPM2 devices.
    Add "shutdown" to "struct class".
    tpm: Provide strong locking for device removal
    tpm: Get rid of chip->pdev
    selftests/capabilities: Fix the test_execve test
    mnt: Make propagate_umount less slow for overlapping mount propagation trees
    mnt: In propgate_umount handle visiting mounts in any order
    mnt: In umount propagation reparent in a separate pass
    vt: fix unchecked __put_user() in tioclinux ioctls
    exec: Limit arg stack to at most 75% of _STK_LIM
    s390: reduce ELF_ET_DYN_BASE
    powerpc: move ELF_ET_DYN_BASE to 4GB / 4MB
    arm64: move ELF_ET_DYN_BASE to 4GB / 4MB
    arm: move ELF_ET_DYN_BASE to 4MB
    binfmt_elf: use ELF_ET_DYN_BASE only for PIE
    checkpatch: silence perl 5.26.0 unescaped left brace warnings
    fs/dcache.c: fix spin lockup issue on nlru->lock
    mm/list_lru.c: fix list_lru_count_node() to be race free
    kernel/extable.c: mark core_kernel_text notrace
    tools/lib/lockdep: Reduce MAX_LOCK_DEPTH to avoid overflowing lock_chain/: Depth
    parisc/mm: Ensure IRQs are off in switch_mm()
    parisc: DMA API: return error instead of BUG_ON for dma ops on non dma devs
    parisc: use compat_sys_keyctl()
    parisc: Report SIGSEGV instead of SIGBUS when running out of stack
    irqchip/gic-v3: Fix out-of-bound access in gic_set_affinity
    cfg80211: Check if PMKID attribute is of expected size
    cfg80211: Validate frequencies nested in NL80211_ATTR_SCAN_FREQUENCIES
    cfg80211: Define nla_policy for NL80211_ATTR_LOCAL_MESH_POWER_MODE
    brcmfmac: fix possible buffer overflow in brcmf_cfg80211_mgmt_tx()
    rds: tcp: use sock_create_lite() to create the accept socket
    vrf: fix bug_on triggered by rx when destroying a vrf
    net: ipv6: Compare lwstate in detecting duplicate nexthops
    ipv6: dad: don't remove dynamic addresses if link is down
    net: handle NAPI_GRO_FREE_STOLEN_HEAD case also in napi_frags_finish()
    bpf: prevent leaking pointer via xadd on unpriviledged
    net: prevent sign extension in dev_get_stats()
    tcp: reset sk_rx_dst in tcp_disconnect()
    net: dp83640: Avoid NULL pointer dereference.
    ipv6: avoid unregistering inet6_dev for loopback
    net/phy: micrel: configure intterupts after autoneg workaround
    net: sched: Fix one possible panic when no destroy callback
    net_sched: fix error recovery at qdisc creation
Linux 4.4.77
    saa7134: fix warm Medion 7134 EEPROM read
    x86/mm/pat: Don't report PAT on CPUs that don't support it
    ext4: check return value of kstrtoull correctly in reserved_clusters_store
    staging: comedi: fix clean-up of comedi_class in comedi_init()
    staging: vt6556: vnt_start Fix missing call to vnt_key_init_table.
    tcp: fix tcp_mark_head_lost to check skb len before fragmenting
    md: fix super_offset endianness in super_1_rdev_size_change
    md: fix incorrect use of lexx_to_cpu in does_sb_need_changing
    perf tools: Use readdir() instead of deprecated readdir_r() again
    perf tests: Remove wrong semicolon in while loop in CQM test
    perf trace: Do not process PERF_RECORD_LOST twice
    perf dwarf: Guard !x86_64 definitions under #ifdef else clause
    perf pmu: Fix misleadingly indented assignment (whitespace)
    perf annotate browser: Fix behaviour of Shift-Tab with nothing focussed
    perf tools: Remove duplicate const qualifier
    perf script: Use readdir() instead of deprecated readdir_r()
    perf thread_map: Use readdir() instead of deprecated readdir_r()
    perf tools: Use readdir() instead of deprecated readdir_r()
    perf bench numa: Avoid possible truncation when using snprintf()
    perf tests: Avoid possible truncation with dirent->d_name + snprintf
    perf scripting perl: Fix compile error with some perl5 versions
    perf thread_map: Correctly size buffer used with dirent->dt_name
    perf intel-pt: Use __fallthrough
    perf top: Use __fallthrough
    tools strfilter: Use __fallthrough
    tools string: Use __fallthrough in perf_atoll()
    tools include: Add a __fallthrough statement
    mqueue: fix a use-after-free in sys_mq_notify()
    RDMA/uverbs: Check port number supplied by user verbs cmds
    KEYS: Fix an error code in request_master_key()
    ath10k: override CE5 config for QCA9377
    x86/uaccess: Optimize copy_user_enhanced_fast_string() for short strings
    x86/tools: Fix gcc-7 warning in relocs.c
    gfs2: Fix glock rhashtable rcu bug
    USB: serial: qcserial: new Sierra Wireless EM7305 device ID
    USB: serial: option: add two Longcheer device ids
    pinctrl: sh-pfc: Update info pointer after SoC-specific init
    pinctrl: mxs: atomically switch mux and drive strength config
    pinctrl: sunxi: Fix SPDIF function name for A83T
    pinctrl: meson: meson8b: fix the NAND DQS pins
    pinctrl: sh-pfc: r8a7791: Fix SCIF2 pinmux data
    sysctl: report EINVAL if value is larger than UINT_MAX for proc_douintvec
    sysctl: don't print negative flag for proc_douintvec
    mac80211_hwsim: Replace bogus hrtimer clockid
    usb: Fix typo in the definition of Endpoint[out]Request
    usb: usbip: set buffer pointers to NULL after free
    Add USB quirk for HVR-950q to avoid intermittent device resets
    USB: serial: cp210x: add ID for CEL EM3588 USB ZigBee stick
    usb: dwc3: replace %p with %pK
    drm/virtio: don't leak bo on drm_gem_object_init failure
    tracing/kprobes: Allow to create probe with a module name starting with a digit
    mm: fix classzone_idx underflow in shrink_zones()
    bgmac: reset & enable Ethernet core before using it
    driver core: platform: fix race condition with driver_override
    fs: completely ignore unknown open flags
    fs: add a VALID_OPEN_FLAGS
Linux 4.4.76
    KVM: nVMX: Fix exception injection
    KVM: x86: zero base3 of unusable segments
    KVM: x86/vPMU: fix undefined shift in intel_pmu_refresh()
    KVM: x86: fix emulation of RSM and IRET instructions
    cpufreq: s3c2416: double free on driver init error path
    iommu/amd: Fix incorrect error handling in amd_iommu_bind_pasid()
    iommu: Handle default domain attach failure
    iommu/vt-d: Don't over-free page table directories
    ocfs2: o2hb: revert hb threshold to keep compatible
    x86/mm: Fix flush_tlb_page() on Xen
    x86/mpx: Correctly report do_mpx_bt_fault() failures to user-space
    ARM: 8685/1: ensure memblock-limit is pmd-aligned
    ARM64/ACPI: Fix BAD_MADT_GICC_ENTRY() macro implementation
    sched/loadavg: Avoid loadavg spikes caused by delayed NO_HZ accounting
    watchdog: bcm281xx: Fix use of uninitialized spinlock.
    xfrm: Oops on error in pfkey_msg2xfrm_state()
    xfrm: NULL dereference on allocation failure
    xfrm: fix stack access out of bounds with CONFIG_XFRM_SUB_POLICY
    jump label: fix passing kbuild_cflags when checking for asm goto support
    ravb: Fix use-after-free on `ifconfig eth0 down`
    sctp: check af before verify address in sctp_addr_id2transport
    net/mlx4_core: Eliminate warning messages for SRQ_LIMIT under SRIOV
    perf probe: Fix to show correct locations for events on modules
    be2net: fix status check in be_cmd_pmac_add()
    s390/ctl_reg: make __ctl_load a full memory barrier
    swiotlb: ensure that page-sized mappings are page-aligned
    coredump: Ensure proper size of sparse core files
    x86/mpx: Use compatible types in comparison to fix sparse error
    mac80211: initialize SMPS field in HT capabilities
    spi: davinci: use dma_mapping_error()
    scsi: lpfc: avoid double free of resource identifiers
    HID: i2c-hid: Add sleep between POWER ON and RESET
    kernel/panic.c: add missing \n
    ibmveth: Add a proper check for the availability of the checksum features
    vxlan: do not age static remote mac entries
    virtio_net: fix PAGE_SIZE > 64k
    vfio/spapr: fail tce_iommu_attach_group() when iommu_data is null
    drm/amdgpu: check ring being ready before using
    net: dsa: Check return value of phy_connect_direct()
    amd-xgbe: Check xgbe_init() return code
    platform/x86: ideapad-laptop: handle ACPI event 1
    scsi: virtio_scsi: Reject commands when virtqueue is broken
    xen-netfront: Fix Rx stall during network stress and OOM
    swiotlb-xen: update dev_addr after swapping pages
    virtio_console: fix a crash in config_work_handler
    Btrfs: fix truncate down when no_holes feature is enabled
    gianfar: Do not reuse pages from emergency reserve
    powerpc/eeh: Enable IO path on permanent error
    net: bgmac: Remove superflous netif_carrier_on()
    net: bgmac: Start transmit queue in bgmac_open
    net: bgmac: Fix SOF bit checking
    bgmac: Fix reversed test of build_skb() return value.
    mtd: bcm47xxpart: don't fail because of bit-flips
    bgmac: fix a missing check for build_skb
    mtd: bcm47xxpart: limit scanned flash area on BCM47XX (MIPS) only
    MIPS: ralink: fix MT7628 wled_an pinmux gpio
    MIPS: ralink: fix MT7628 pinmux typos
    MIPS: ralink: Fix invalid assignment of SoC type
    MIPS: ralink: fix USB frequency scaling
    MIPS: ralink: MT7688 pinmux fixes
    net: korina: Fix NAPI versus resources freeing
    MIPS: ath79: fix regression in PCI window initialization
    net: mvneta: Fix for_each_present_cpu usage
    ARM: dts: BCM5301X: Correct GIC_PPI interrupt flags
    qla2xxx: Fix erroneous invalid handle message
    scsi: lpfc: Set elsiocb contexts to NULL after freeing it
    scsi: sd: Fix wrong DPOFUA disable in sd_read_cache_type
    KVM: x86: fix fixing of hypercalls
    mm: numa: avoid waiting on freed migrated pages
    block: fix module reference leak on put_disk() call for cgroups throttle
    sysctl: enable strict writes
    usb: gadget: f_fs: Fix possibe deadlock
    drm/vmwgfx: Free hash table allocated by cmdbuf managed res mgr
    ALSA: hda - set input_path bitmap to zero after moving it to new place
    ALSA: hda - Fix endless loop of codec configure
    MIPS: Fix IRQ tracing & lockdep when rescheduling
    MIPS: pm-cps: Drop manual cache-line alignment of ready_count
    MIPS: Avoid accidental raw backtrace
    mm, swap_cgroup: reschedule when neeed in swap_cgroup_swapoff()
    drm/ast: Handle configuration without P2A bridge
    NFSv4: fix a reference leak caused WARNING messages
    netfilter: synproxy: fix conntrackd interaction
    netfilter: xt_TCPMSS: add more sanity tests on tcph->doff
    rtnetlink: add IFLA_GROUP to ifla_policy
    ipv6: Do not leak throw route references
    sfc: provide dummy definitions of vswitch functions
    net: 8021q: Fix one possible panic caused by BUG_ON in free_netdev
    decnet: always not take dst->__refcnt when inserting dst into hash table
    net/mlx5: Wait for FW readiness before initializing command interface
    ipv6: fix calling in6_ifa_hold incorrectly for dad work
    igmp: add a missing spin_lock_init()
    igmp: acquire pmc lock for ip_mc_clear_src()
    net: caif: Fix a sleep-in-atomic bug in cfpkt_create_pfx
    Fix an intermittent pr_emerg warning about lo becoming free.
    af_unix: Add sockaddr length checks before accessing sa_family in bind and connect handlers
    net: Zero ifla_vf_info in rtnl_fill_vfinfo()
    decnet: dn_rtmsg: Improve input length sanitization in dnrmg_receive_user_skb
    net: don't call strlen on non-terminated string in dev_set_alias()
    ipv6: release dst on error in ip6_dst_lookup_tail
Linux 4.4.75
    nvme: apply DELAY_BEFORE_CHK_RDY quirk at probe time too
    nvme/quirk: Add a delay before checking for adapter readiness
    net: phy: fix marvell phy status reading
    net: phy: Initialize mdio clock at probe function
    usb: gadget: f_fs: avoid out of bounds access on comp_desc
    powerpc/slb: Force a full SLB flush when we insert for a bad EA
    mtd: spi-nor: fix spansion quad enable
    of: Add check to of_scan_flat_dt() before accessing initial_boot_params
    rxrpc: Fix several cases where a padded len isn't checked in ticket decode
    USB: usbip: fix nonconforming hub descriptor
    drm/amdgpu: adjust default display clock
    drm/amdgpu/atom: fix ps allocation size for EnableDispPowerGating
    drm/radeon: add a quirk for Toshiba Satellite L20-183
    drm/radeon: add a PX quirk for another K53TK variant
    iscsi-target: Reject immediate data underflow larger than SCSI transfer length
    target: Fix kref->refcount underflow in transport_cmd_finish_abort
    time: Fix clock->read(clock) race around clocksource changes
    Input: i8042 - add Fujitsu Lifebook AH544 to notimeout list
    powerpc/kprobes: Pause function_graph tracing during jprobes handling
    signal: Only reschedule timers on signals timers have sent
    HID: Add quirk for Dell PIXART OEM mouse
    CIFS: Improve readdir verbosity
    KVM: PPC: Book3S HV: Preserve userspace HTM state properly
    lib/cmdline.c: fix get_options() overflow while parsing ranges
    autofs: sanity check status reported with AUTOFS_DEV_IOCTL_FAIL
    fs/exec.c: account for argv/envp pointers
Linux 4.4.74
    mm: fix new crash in unmapped_area_topdown()
    Allow stack to grow up to address space limit
    mm: larger stack guard gap, between vmas
    alarmtimer: Rate limit periodic intervals
    MIPS: Fix bnezc/jialc return address calculation
    usb: dwc3: exynos fix axius clock error path to do cleanup
    alarmtimer: Prevent overflow of relative timers
    genirq: Release resources in __setup_irq() error path
    swap: cond_resched in swap_cgroup_prepare()
    mm/memory-failure.c: use compound_head() flags for huge pages
    USB: gadgetfs, dummy-hcd, net2280: fix locking for callbacks
    usb: xhci: ASMedia ASM1042A chipset need shorts TX quirk
    drivers/misc/c2port/c2port-duramar2150.c: checking for NULL instead of IS_ERR()
    usb: r8a66597-hcd: decrease timeout
    usb: r8a66597-hcd: select a different endpoint on timeout
    USB: gadget: dummy_hcd: fix hub-descriptor removable fields
    pvrusb2: reduce stack usage pvr2_eeprom_analyze()
    usb: core: fix potential memory leak in error path during hcd creation
    USB: hub: fix SS max number of ports
    iio: proximity: as3935: recalibrate RCO after resume
    staging: rtl8188eu: prevent an underflow in rtw_check_beacon_data()
    mfd: omap-usb-tll: Fix inverted bit use for USB TLL mode
    x86/mm/32: Set the '__vmalloc_start_set' flag in initmem_init()
    serial: efm32: Fix parity management in 'efm32_uart_console_get_options()'
    mac80211: fix IBSS presp allocation size
    mac80211: fix CSA in IBSS mode
    mac80211/wpa: use constant time memory comparison for MACs
    mac80211: don't look at the PM bit of BAR frames
    vb2: Fix an off by one error in 'vb2_plane_vaddr'
    cpufreq: conservative: Allow down_threshold to take values from 1 to 10
    can: gs_usb: fix memory leak in gs_cmd_reset()
    configfs: Fix race between create_link and configfs_rmdir
Linux 4.4.73
    sparc64: make string buffers large enough
    s390/kvm: do not rely on the ILC on kvm host protection fauls
    xtensa: don't use linux IRQ #0
    tipc: ignore requests when the connection state is not CONNECTED
    proc: add a schedule point in proc_pid_readdir()
    romfs: use different way to generate fsid for BLOCK or MTD
    sctp: sctp_addr_id2transport should verify the addr before looking up assoc
    r8152: avoid start_xmit to schedule napi when napi is disabled
    r8152: fix rtl8152_post_reset function
    r8152: re-schedule napi for tx
    nfs: Fix "Don't increment lock sequence ID after NFS4ERR_MOVED"
    ravb: unmap descriptors when freeing rings
    drm/ast: Fixed system hanged if disable P2A
    drm/nouveau: Don't enabling polling twice on runtime resume
    parisc, parport_gsc: Fixes for printk continuation lines
    net: adaptec: starfire: add checks for dma mapping errors
    pinctrl: berlin-bg4ct: fix the value for "sd1a" of pin SCRD0_CRD_PRES
    gianfar: synchronize DMA API usage by free_skb_rx_queue w/ gfar_new_page
    net/mlx4_core: Avoid command timeouts during VF driver device shutdown
    drm/nouveau/fence/g84-: protect against concurrent access to semaphore buffers
    drm/nouveau: prevent userspace from deleting client object
    ipv6: fix flow labels when the traffic class is non-0
    FS-Cache: Initialise stores_lock in netfs cookie
    fscache: Clear outstanding writes when disabling a cookie
    fscache: Fix dead object requeue
    ethtool: do not vzalloc(0) on registers dump
    log2: make order_base_2() behave correctly on const input value zero
    kasan: respect /proc/sys/kernel/traceoff_on_warning
    jump label: pass kbuild_cflags when checking for asm goto support
    PM / runtime: Avoid false-positive warnings from might_sleep_if()
    ipv6: Fix IPv6 packet loss in scenarios involving roaming + snooping switches
    i2c: piix4: Fix request_region size
    sierra_net: Add support for IPv6 and Dual-Stack Link Sense Indications
    sierra_net: Skip validating irrelevant fields for IDLE LSIs
    net: hns: Fix the device being used for dma mapping during TX
    NET: mkiss: Fix panic
    NET: Fix /proc/net/arp for AX.25
    ipv6: Inhibit IPv4-mapped src address on the wire.
    ipv6: Handle IPv4-mapped src to in6addr_any dst.
    net: xilinx_emaclite: fix receive buffer overflow
    net: xilinx_emaclite: fix freezes due to unordered I/O
    Call echo service immediately after socket reconnect
    staging: rtl8192e: rtl92e_fill_tx_desc fix write to mapped out memory.
    ARM: dts: imx6dl: Fix the VDD_ARM_CAP voltage for 396MHz operation
    partitions/msdos: FreeBSD UFS2 file systems are not recognized
    s390/vmem: fix identity mapping
Linux 4.4.72
    arm64: ensure extension of smp_store_release value
    arm64: armv8_deprecated: ensure extension of addr
    usercopy: Adjust tests to deal with SMAP/PAN
    RDMA/qib,hfi1: Fix MR reference count leak on write with immediate
    arm64: entry: improve data abort handling of tagged pointers
    arm64: hw_breakpoint: fix watchpoint matching for tagged pointers
    Make __xfs_xattr_put_listen preperly report errors.
    NFSv4: Don't perform cached access checks before we've OPENed the file
    NFS: Ensure we revalidate attributes before using execute_ok()
    mm: consider memblock reservations for deferred memory initialization sizing
    net: better skb->sender_cpu and skb->napi_id cohabitation
    serial: sh-sci: Fix panic when serial console and DMA are enabled
    tty: Drop krefs for interrupted tty lock
    drivers: char: mem: Fix wraparound check to allow mappings up to the end
    ASoC: Fix use-after-free at card unregistration
    ALSA: timer: Fix missing queue indices reset at SNDRV_TIMER_IOCTL_SELECT
    ALSA: timer: Fix race between read and ioctl
    drm/nouveau/tmr: fully separate alarm execution/pending lists
    drm/vmwgfx: Make sure backup_handle is always valid
    drm/vmwgfx: limit the number of mip levels in vmw_gb_surface_define_ioctl()
    drm/vmwgfx: Handle vmalloc() failure in vmw_local_fifo_reserve()
    perf/core: Drop kernel samples even though :u is specified
    powerpc/hotplug-mem: Fix missing endian conversion of aa_index
    powerpc/numa: Fix percpu allocations to be NUMA aware
    powerpc/eeh: Avoid use after free in eeh_handle_special_event()
    scsi: qla2xxx: don't disable a not previously enabled PCI device
    KVM: arm/arm64: Handle possible NULL stage2 pud when ageing pages
    btrfs: fix memory leak in update_space_info failure path
    btrfs: use correct types for page indices in btrfs_page_exists_in_range
    cxl: Fix error path on bad ioctl
    ufs_getfrag_block(): we only grab ->truncate_mutex on block creation path
    ufs_extend_tail(): fix the braino in calling conventions of ufs_new_fragments()
    ufs: set correct ->s_maxsize
    ufs: restore maintaining ->i_blocks
    fix ufs_isblockset()
    ufs: restore proper tail allocation
    fs: add i_blocksize()
    cpuset: consider dying css as offline
    Input: elantech - add Fujitsu Lifebook E546/E557 to force crc_enabled
    drm/msm: Expose our reservation object when exporting a dmabuf.
    target: Re-add check to reject control WRITEs with overflow data
    cpufreq: cpufreq_register_driver() should return -ENODEV if init fails
    stackprotector: Increase the per-task stack canary's random range from 32 bits to 64 bits on 64-bit platforms
    random: properly align get_random_int_hash
    drivers: char: random: add get_random_long()
    iio: proximity: as3935: fix AS3935_INT mask
    iio: light: ltr501 Fix interchanged als/ps register field
    staging/lustre/lov: remove set_fs() call from lov_getstripe()
    usb: chipidea: debug: check before accessing ci_role
    usb: chipidea: udc: fix NULL pointer dereference if udc_start failed
    usb: gadget: f_mass_storage: Serialize wake and sleep execution
    ext4: fix fdatasync(2) after extent manipulation operations
    ext4: keep existing extra fields when inode expands
    ext4: fix SEEK_HOLE
    xen-netfront: cast grant table reference first to type int
    xen-netfront: do not cast grant table reference to signed short
    xen/privcmd: Support correctly 64KB page granularity when mapping memory
    dmaengine: ep93xx: Always start from BASE0
    dmaengine: usb-dmac: Fix DMAOR AE bit definition
    KVM: async_pf: avoid async pf injection when in guest mode
    arm: KVM: Allow unaligned accesses at HYP
    KVM: cpuid: Fix read/write out-of-bounds vulnerability in cpuid emulation
    kvm: async_pf: fix rcu_irq_enter() with irqs enabled
    nfsd: Fix up the "supattr_exclcreat" attributes
    nfsd4: fix null dereference on replay
    drm/amdgpu/ci: disable mclk switching for high refresh rates (v2)
    crypto: gcm - wait for crypto op not signal safe
    KEYS: fix freeing uninitialized memory in key_update()
    KEYS: fix dereferencing NULL payload with nonzero length
    ptrace: Properly initialize ptracer_cred on fork
    serial: ifx6x60: fix use-after-free on module unload
    arch/sparc: support NR_CPUS = 4096
    sparc64: delete old wrap code
    sparc64: new context wrap
    sparc64: add per-cpu mm of secondary contexts
    sparc64: redefine first version
    sparc64: combine activate_mm and switch_mm
    sparc64: reset mm cpumask after wrap
    sparc: Machine description indices can vary
    sparc64: mm: fix copy_tsb to correctly copy huge page TSBs
    net: bridge: start hello timer only if device is up
    net: ethoc: enable NAPI before poll may be scheduled
    net: ping: do not abuse udp_poll()
    ipv6: Fix leak in ipv6_gso_segment().
    vxlan: fix use-after-free on deletion
    tcp: disallow cwnd undo when switching congestion control
    cxgb4: avoid enabling napi twice to the same queue
    ipv6: xfrm: Handle errors reported by xfrm6_find_1stfragopt()
    bnx2x: Fix Multi-Cos
Linux 4.4.71
    xfs: only return -errno or success from attr ->put_listent
    xfs: in _attrlist_by_handle, copy the cursor back to userspace
    xfs: fix unaligned access in xfs_btree_visit_blocks
    xfs: bad assertion for delalloc an extent that start at i_size
    xfs: fix indlen accounting error on partial delalloc conversion
    xfs: wait on new inodes during quotaoff dquot release
    xfs: update ag iterator to support wait on new inodes
    xfs: support ability to wait on new inodes
    xfs: fix up quotacheck buffer list error handling
    xfs: prevent multi-fsb dir readahead from reading random blocks
    xfs: handle array index overrun in xfs_dir2_leaf_readbuf()
    xfs: fix over-copying of getbmap parameters from userspace
    xfs: fix off-by-one on max nr_pages in xfs_find_get_desired_pgoff()
    xfs: Fix missed holes in SEEK_HOLE implementation
    mlock: fix mlock count can not decrease in race condition
    mm/migrate: fix refcount handling when !hugepage_migration_supported()
    drm/gma500/psb: Actually use VBT mode when it is found
    slub/memcg: cure the brainless abuse of sysfs attributes
    ALSA: hda - apply STAC_9200_DELL_M22 quirk for Dell Latitude D430
    pcmcia: remove left-over %Z format
    drm/radeon: Unbreak HPD handling for r600+
    drm/radeon/ci: disable mclk switching for high refresh rates (v2)
    scsi: mpt3sas: Force request partial completion alignment
    HID: wacom: Have wacom_tpc_irq guard against possible NULL dereference
    mmc: sdhci-iproc: suppress spurious interrupt with Multiblock read
    i2c: i2c-tiny-usb: fix buffer not being DMA capable
    vlan: Fix tcp checksum offloads in Q-in-Q vlans
    net: phy: marvell: Limit errata to 88m1101
    netem: fix skb_orphan_partial()
    ipv4: add reference counting to metrics
    sctp: fix ICMP processing if skb is non-linear
    tcp: avoid fastopen API to be used on AF_UNSPEC
    virtio-net: enable TSO/checksum offloads for Q-in-Q vlans
    be2net: Fix offload features for Q-in-Q packets
    ipv6: fix out of bound writes in __ip6_append_data()
    bridge: start hello_timer when enabling KERNEL_STP in br_stp_start
    qmi_wwan: add another Lenovo EM74xx device ID
    bridge: netlink: check vlan_default_pvid range
    ipv6: Check ip6_find_1stfragopt() return value properly.
    ipv6: Prevent overrun when parsing v6 header options
    net: Improve handling of failures on link and route dumps
    tcp: eliminate negative reordering in tcp_clean_rtx_queue
    sctp: do not inherit ipv6_{mc|ac|fl}_list from parent
    sctp: fix src address selection if using secondary addresses for ipv6
    tcp: avoid fragmenting peculiar skbs in SACK
    s390/qeth: avoid null pointer dereference on OSN
    s390/qeth: unbreak OSM and OSN support
    s390/qeth: handle sysfs error during initialization
    ipv6/dccp: do not inherit ipv6_mc_list from parent
    dccp/tcp: do not inherit mc_list from parent
    sparc: Fix -Wstringop-overflow warning

Bug: 62730977
Change-Id: Ifca755d82f9e4b11016f6660298c2c1b073bfb3a
Signed-off-by: Thierry Strudel <tstrudel@google.com>
2017-09-20 16:42:37 -07:00
Thierry Strudel
ad09c07fbf Merged linux-4.4.60 into android-msm-wahoo-4.4
Linux 4.4.60
    padata: avoid race in reordering
    blk: Ensure users for current->bio_list can see the full list.
    blk: improve order of bio handling in generic_make_request()
    power: reset: at91-poweroff: timely shutdown LPDDR memories
    KVM: kvm_io_bus_unregister_dev() should never fail
    rtc: s35390a: improve irq handling
    rtc: s35390a: implement reset routine as suggested by the reference
    rtc: s35390a: make sure all members in the output are set
    rtc: s35390a: fix reading out alarm
    MIPS: Lantiq: Fix cascaded IRQ setup
    mm, hugetlb: use pte_present() instead of pmd_present() in follow_huge_pmd()
    drm/radeon: Override fpfn for all VRAM placements in radeon_evict_flags
    KVM: x86: clear bus pointer when destroyed
    USB: fix linked-list corruption in rh_call_control()
    tty/serial: atmel: fix TX path in atmel_console_write()
    tty/serial: atmel: fix race condition (TX+DMA)
    ACPI: Do not create a platform_device for IOAPIC/IOxAPIC
    ACPI: Fix incompatibility with mcount-based function graph tracing
    ASoC: atmel-classd: fix audio clock rate
    ALSA: hda - fix a problem for lineout on a Dell AIO machine
    ALSA: seq: Fix race during FIFO resize
    scsi: libsas: fix ata xfer length
    scsi: sg: check length passed to SG_NEXT_CMD_LEN
    scsi: mpt3sas: fix hang on ata passthrough commands
    xen/setup: Don't relocate p2m over existing one
    libceph: force GFP_NOIO for socket allocations
Linux 4.4.59
    sched/rt: Add a missing rescheduling point
    fscrypt: remove broken support for detecting keyring key revocation
    metag/ptrace: Reject partial NT_METAG_RPIPE writes
    metag/ptrace: Provide default TXSTATUS for short NT_PRSTATUS
    metag/ptrace: Preserve previous registers for short regset write
    sparc/ptrace: Preserve previous registers for short regset write
    mips/ptrace: Preserve previous registers for short regset write
    h8300/ptrace: Fix incorrect register transfer count
    c6x/ptrace: Remove useless PTRACE_SETREGSET implementation
    pinctrl: qcom: Don't clear status bit on irq_unmask
    virtio_balloon: init 1st buffer in stats vq
    xfrm_user: validate XFRM_MSG_NEWAE incoming ESN size harder
    xfrm_user: validate XFRM_MSG_NEWAE XFRMA_REPLAY_ESN_VAL replay_window
    xfrm: policy: init locks early
Linux 4.4.58
    crypto: algif_hash - avoid zero-sized array
    fbcon: Fix vc attr at deinit
    serial: 8250_pci: Detach low-level driver during PCI error recovery
    ACPI / blacklist: Make Dell Latitude 3350 ethernet work
    ACPI / blacklist: add _REV quirks for Dell Precision 5520 and 3520
    uvcvideo: uvc_scan_fallback() for webcams with broken chain
    s390/zcrypt: Introduce CEX6 toleration
    block: allow WRITE_SAME commands with the SG_IO ioctl
    vfio/spapr: Postpone allocation of userspace version of TCE table
    PCI: Do any VF BAR updates before enabling the BARs
    PCI: Ignore BAR updates on virtual functions
    PCI: Update BARs using property bits appropriate for type
    PCI: Don't update VF BARs while VF memory space is enabled
    PCI: Decouple IORESOURCE_ROM_ENABLE and PCI_ROM_ADDRESS_ENABLE
    PCI: Add comments about ROM BAR updating
    PCI: Remove pci_resource_bar() and pci_iov_resource_bar()
    PCI: Separate VF BAR updates from standard BAR updates
    x86/hyperv: Handle unknown NMIs on one CPU when unknown_nmi_panic
    igb: add i211 to i210 PHY workaround
    igb: Workaround for igb i210 firmware issue
    xen: do not re-use pirq number cached in pci device msi msg data
    xfs: clear _XBF_PAGES from buffers when readahead page
    USB: usbtmc: add missing endpoint sanity check
    nl80211: fix dumpit error path RTNL deadlocks
    xfs: fix up xfs_swap_extent_forks inline extent handling
    xfs: don't allow di_size with high bit set
    libceph: don't set weight to IN when OSD is destroyed
    raid10: increment write counter after bio is split
    cpufreq: Restore policy min/max limits on CPU online
    ARM: dts: at91: sama5d2: add dma properties to UART nodes
    ARM: at91: pm: cpu_idle: switch DDR to power-down mode
    iommu/vt-d: Fix NULL pointer dereference in device_to_iommu
    xen/acpi: upload PM state from init-domain to Xen
    mmc: sdhci: Do not disable interrupts while waiting for clock
    ext4: mark inode dirty after converting inline directory
    parport: fix attempt to write duplicate procfiles
    iio: hid-sensor-trigger: Change get poll value function order to avoid sensor properties losing after resume from S3
    iio: adc: ti_am335x_adc: fix fifo overrun recovery
    mmc: ushc: fix NULL-deref at probe
    uwb: hwa-rc: fix NULL-deref at probe
    uwb: i1480-dfu: fix NULL-deref at probe
    usb: hub: Fix crash after failure to read BOS descriptor
    usb: musb: cppi41: don't check early-TX-interrupt for Isoch transfer
    USB: wusbcore: fix NULL-deref at probe
    USB: idmouse: fix NULL-deref at probe
    USB: lvtest: fix NULL-deref at probe
    USB: uss720: fix NULL-deref at probe
    usb-core: Add LINEAR_FRAME_INTR_BINTERVAL USB quirk
    usb: gadget: f_uvc: Fix SuperSpeed companion descriptor's wBytesPerInterval
    ACM gadget: fix endianness in notifications
    USB: serial: qcserial: add Dell DW5811e
    USB: serial: option: add Quectel UC15, UC20, EC21, and EC25 modems
    ALSA: hda - Adding a group of pin definition to fix headset problem
    ALSA: ctxfi: Fix the incorrect check of dma_set_mask() call
    ALSA: seq: Fix racy cell insertions during snd_seq_pool_done()
    Input: sur40 - validate number of endpoints before using them
    Input: kbtab - validate number of endpoints before using them
    Input: cm109 - validate number of endpoints before using them
    Input: yealink - validate number of endpoints before using them
    Input: hanwang - validate number of endpoints before using them
    Input: ims-pcu - validate number of endpoints before using them
    Input: iforce - validate number of endpoints before using them
    Input: i8042 - add noloop quirk for Dell Embedded Box PC 3000
    Input: elan_i2c - add ASUS EeeBook X205TA special touchpad fw
    tcp: initialize icsk_ack.lrcvtime at session start time
    socket, bpf: fix sk_filter use after free in sk_clone_lock
    ipv4: provide stronger user input validation in nl_fib_input()
    net: bcmgenet: remove bcmgenet_internal_phy_setup()
    net/mlx5e: Count LRO packets correctly
    net/mlx5: Increase number of max QPs in default profile
    net: unix: properly re-increment inflight counter of GC discarded candidates
    amd-xgbe: Fix jumbo MTU processing on newer hardware
    net: properly release sk_frag.page
    net: bcmgenet: Do not suspend PHY if Wake-on-LAN is enabled
    net/openvswitch: Set the ipv6 source tunnel key address attribute correctly
 Linux 4.4.57
    ext4: fix fencepost in s_first_meta_bg validation
    percpu: acquire pcpu_lock when updating pcpu_nr_empty_pop_pages
    gfs2: Avoid alignment hole in struct lm_lockname
    isdn/gigaset: fix NULL-deref at probe
    target: Fix VERIFY_16 handling in sbc_parse_cdb
    scsi: libiscsi: add lock around task lists to fix list corruption regression
    scsi: lpfc: Add shutdown method for kexec
    target/pscsi: Fix TYPE_TAPE + TYPE_MEDIMUM_CHANGER export
    md/raid1/10: fix potential deadlock
    powerpc/boot: Fix zImage TOC alignment
    cpufreq: Fix and clean up show_cpuinfo_cur_freq()
    perf/core: Fix event inheritance on fork()
    give up on gcc ilog2() constant optimizations
    kernek/fork.c: allocate idle task for a CPU always on its local node
    hv_netvsc: use skb_get_hash() instead of a homegrown implementation
    tpm_tis: Use devm_free_irq not free_irq
    drm/amdgpu: add missing irq.h include
    s390/pci: fix use after free in dma_init
    KVM: PPC: Book3S PR: Fix illegal opcode emulation
    xen/qspinlock: Don't kick CPU if IRQ is not initialized
    Drivers: hv: avoid vfree() on crash
    Drivers: hv: balloon: don't crash when memory is added in non-sorted order
    pinctrl: cherryview: Do not mask all interrupts in probe
    ACPI / video: skip evaluating _DOD when it does not exist
    cxlflash: Increase cmd_per_lun for better throughput
    crypto: mcryptd - Fix load failure
    crypto: cryptd - Assign statesize properly
    crypto: ghash-clmulni - Fix load failure
    USB: don't free bandwidth_mutex too early
    usb: core: hub: hub_port_init lock controller instead of bus

Bug: 62730977
Change-Id: Id5edc4c2c4cf300956116a6011eeef04264bb82a
Signed-off-by: Thierry Strudel <tstrudel@google.com>
2017-09-20 14:16:49 -07:00
Alex Williamson
3457c04594 vfio: New external user group/file match
commit 5d6dee80a1e94cc284d03e06d930e60e8d3ecf7d upstream.

At the point where the kvm-vfio pseudo device wants to release its
vfio group reference, we can't always acquire a new reference to make
that happen.  The group can be in a state where we wouldn't allow a
new reference to be added.  This new helper function allows a caller
to match a file to a group to facilitate this.  Given a file and
group, report if they match.  Thus the caller needs to already have a
group reference to match to the file.  This allows the deletion of a
group without acquiring a new reference.

Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
Reviewed-by: Eric Auger <eric.auger@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Tested-by: Eric Auger <eric.auger@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-07-27 15:06:07 -07:00
David Hildenbrand
42462d23e6 KVM: kvm_io_bus_unregister_dev() should never fail
commit 90db10434b163e46da413d34db8d0e77404cc645 upstream.

No caller currently checks the return value of
kvm_io_bus_unregister_dev(). This is evil, as all callers silently go on
freeing their device. A stale reference will remain in the io_bus,
getting at least used again, when the iobus gets teared down on
kvm_destroy_vm() - leading to use after free errors.

There is nothing the callers could do, except retrying over and over
again.

So let's simply remove the bus altogether, print an error and make
sure no one can access this broken bus again (returning -ENOMEM on any
attempt to access it).

Fixes: e93f8a0f82 ("KVM: convert io_bus to SRCU")
Reported-by: Dmitry Vyukov <dvyukov@google.com>
Reviewed-by: Cornelia Huck <cornelia.huck@de.ibm.com>
Signed-off-by: David Hildenbrand <david@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-04-08 09:53:32 +02:00
Peter Xu
3eb392056a KVM: x86: clear bus pointer when destroyed
commit df630b8c1e851b5e265dc2ca9c87222e342c093b upstream.

When releasing the bus, let's clear the bus pointers to mark it out. If
any further device unregister happens on this bus, we know that we're
done if we found the bus being released already.

Signed-off-by: Peter Xu <peterx@redhat.com>
Signed-off-by: Radim Krčmář <rkrcmar@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-04-08 09:53:31 +02:00
Alex Shi
261e8dbdb9 Merge tag 'v4.4.44' into linux-linaro-lsk-v4.4
This is the 4.4.44 stable release
2017-01-22 12:01:41 +08:00
Wanpeng Li
34a55c9d4a KVM: eventfd: fix NULL deref irqbypass consumer
commit 4f3dbdf47e150016aacd734e663347fcaa768303 upstream.

Reported syzkaller:

    BUG: unable to handle kernel NULL pointer dereference at 0000000000000008
    IP: irq_bypass_unregister_consumer+0x9d/0xb70 [irqbypass]
    PGD 0

    Oops: 0002 [#1] SMP
    CPU: 1 PID: 125 Comm: kworker/1:1 Not tainted 4.9.0+ #1
    Workqueue: kvm-irqfd-cleanup irqfd_shutdown [kvm]
    task: ffff9bbe0dfbb900 task.stack: ffffb61802014000
    RIP: 0010:irq_bypass_unregister_consumer+0x9d/0xb70 [irqbypass]
    Call Trace:
     irqfd_shutdown+0x66/0xa0 [kvm]
     process_one_work+0x16b/0x480
     worker_thread+0x4b/0x500
     kthread+0x101/0x140
     ? process_one_work+0x480/0x480
     ? kthread_create_on_node+0x60/0x60
     ret_from_fork+0x25/0x30
    RIP: irq_bypass_unregister_consumer+0x9d/0xb70 [irqbypass] RSP: ffffb61802017e20
    CR2: 0000000000000008

The syzkaller folks reported a NULL pointer dereference that due to
unregister an consumer which fails registration before. The syzkaller
creates two VMs w/ an equal eventfd occasionally. So the second VM
fails to register an irqbypass consumer. It will make irqfd as inactive
and queue an workqueue work to shutdown irqfd and unregister the irqbypass
consumer when eventfd is closed. However, the second consumer has been
initialized though it fails registration. So the token(same as the first
VM's) is taken to unregister the consumer through the workqueue, the
consumer of the first VM is found and unregistered, then NULL deref incurred
in the path of deleting consumer from the consumers list.

This patch fixes it by making irq_bypass_register/unregister_consumer()
looks for the consumer entry based on consumer pointer itself instead of
token matching.

Reported-by: Dmitry Vyukov <dvyukov@google.com>
Suggested-by: Alex Williamson <alex.williamson@redhat.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: Radim Krčmář <rkrcmar@redhat.com>
Cc: Dmitry Vyukov <dvyukov@google.com>
Cc: Alex Williamson <alex.williamson@redhat.com>
Signed-off-by: Wanpeng Li <wanpeng.li@hotmail.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-01-19 20:17:19 +01:00
Marc Zyngier
f65bf332f0 arm64: KVM: Turn system register numbers to an enum
Having the system register numbers as #defines has been a pain
since day one, as the ordering is pretty fragile, and moving
things around leads to renumbering and epic conflict resolutions.

Now that we're mostly acessing the sysreg file in C, an enum is
a much better type to use, and we can clean things up a bit.

Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
Acked-by: Christoffer Dall <christoffer.dall@linaro.org>
(cherry picked from commit 9d8415d6c148a16b6d906a96f0596851d7e4d607)
Signed-off-by: Alex Shi <alex.shi@linaro.org>
2016-11-09 22:15:49 +08:00
Marc Zyngier
ac185e4487 KVM: arm/arm64: vgic-v3: Make the LR indexing macro public
We store GICv3 LRs in reverse order so that the CPU can save/restore
them in rever order as well (don't ask why, the design is crazy),
and yet generate memory traffic that doesn't completely suck.

We need this macro to be available to the C version of save/restore.

Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
(cherry picked from commit 3c13b8f435acb452eac62d966148a8b6fa92151f)
Signed-off-by: Alex Shi <alex.shi@linaro.org>
2016-11-09 22:15:40 +08:00
Jim Mattson
144941bd99 KVM: nVMX: Fix memory corruption when using VMCS shadowing
commit 2f1fe81123f59271bddda673b60116bde9660385 upstream.

When freeing the nested resources of a vcpu, there is an assumption that
the vcpu's vmcs01 is the current VMCS on the CPU that executes
nested_release_vmcs12(). If this assumption is violated, the vcpu's
vmcs01 may be made active on multiple CPUs at the same time, in
violation of Intel's specification. Moreover, since the vcpu's vmcs01 is
not VMCLEARed on every CPU on which it is active, it can linger in a
CPU's VMCS cache after it has been freed and potentially
repurposed. Subsequent eviction from the CPU's VMCS cache on a capacity
miss can result in memory corruption.

It is not sufficient for vmx_free_vcpu() to call vmx_load_vmcs01(). If
the vcpu in question was last loaded on a different CPU, it must be
migrated to the current CPU before calling vmx_load_vmcs01().

Signed-off-by: Jim Mattson <jmattson@google.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-08-20 18:09:18 +02:00
Xiubo Li
54f87e16e0 kvm: Fix irq route entries exceeding KVM_MAX_IRQ_ROUTES
commit caf1ff26e1aa178133df68ac3d40815fed2187d9 upstream.

These days, we experienced one guest crash with 8 cores and 3 disks,
with qemu error logs as bellow:

qemu-system-x86_64: /build/qemu-2.0.0/kvm-all.c:984:
kvm_irqchip_commit_routes: Assertion `ret == 0' failed.

And then we found one patch(bdf026317d) in qemu tree, which said
could fix this bug.

Execute the following script will reproduce the BUG quickly:

irq_affinity.sh
========================================================================

vda_irq_num=25
vdb_irq_num=27
while [ 1 ]
do
    for irq in {1,2,4,8,10,20,40,80}
        do
            echo $irq > /proc/irq/$vda_irq_num/smp_affinity
            echo $irq > /proc/irq/$vdb_irq_num/smp_affinity
            dd if=/dev/vda of=/dev/zero bs=4K count=100 iflag=direct
            dd if=/dev/vdb of=/dev/zero bs=4K count=100 iflag=direct
        done
done
========================================================================

The following qemu log is added in the qemu code and is displayed when
this bug reproduced:

kvm_irqchip_commit_routes: max gsi: 1008, nr_allocated_irq_routes: 1024,
irq_routes->nr: 1024, gsi_count: 1024.

That's to say when irq_routes->nr == 1024, there are 1024 routing entries,
but in the kernel code when routes->nr >= 1024, will just return -EINVAL;

The nr is the number of the routing entries which is in of
[1 ~ KVM_MAX_IRQ_ROUTES], not the index in [0 ~ KVM_MAX_IRQ_ROUTES - 1].

This patch fix the BUG above.

Signed-off-by: Xiubo Li <lixiubo@cmss.chinamobile.com>
Signed-off-by: Wei Tang <tangwei@cmss.chinamobile.com>
Signed-off-by: Zhang Zhuoyu <zhangzhuoyu@cmss.chinamobile.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-07-27 09:47:31 -07:00
Paolo Bonzini
2cb77b0ad4 KVM: irqfd: fix NULL pointer dereference in kvm_irq_map_gsi
commit c622a3c21ede892e370b56e1ceb9eb28f8bbda6b upstream.

Found by syzkaller:

    BUG: unable to handle kernel NULL pointer dereference at 0000000000000120
    IP: [<ffffffffa0797202>] kvm_irq_map_gsi+0x12/0x90 [kvm]
    PGD 6f80b067 PUD b6535067 PMD 0
    Oops: 0000 [#1] SMP
    CPU: 3 PID: 4988 Comm: a.out Not tainted 4.4.9-300.fc23.x86_64 #1
    [...]
    Call Trace:
     [<ffffffffa0795f62>] irqfd_update+0x32/0xc0 [kvm]
     [<ffffffffa0796c7c>] kvm_irqfd+0x3dc/0x5b0 [kvm]
     [<ffffffffa07943f4>] kvm_vm_ioctl+0x164/0x6f0 [kvm]
     [<ffffffff81241648>] do_vfs_ioctl+0x298/0x480
     [<ffffffff812418a9>] SyS_ioctl+0x79/0x90
     [<ffffffff817a1062>] tracesys_phase2+0x84/0x89
    Code: b5 71 a7 e0 5b 41 5c 41 5d 5d f3 c3 66 66 66 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 44 00 00 55 48 8b 8f 10 2e 00 00 31 c0 48 89 e5 <39> 91 20 01 00 00 76 6a 48 63 d2 48 8b 94 d1 28 01 00 00 48 85
    RIP  [<ffffffffa0797202>] kvm_irq_map_gsi+0x12/0x90 [kvm]
     RSP <ffff8800926cbca8>
    CR2: 0000000000000120

Testcase:

    #include <unistd.h>
    #include <sys/syscall.h>
    #include <string.h>
    #include <stdint.h>
    #include <linux/kvm.h>
    #include <fcntl.h>
    #include <sys/ioctl.h>

    long r[26];

    int main()
    {
        memset(r, -1, sizeof(r));
        r[2] = open("/dev/kvm", 0);
        r[3] = ioctl(r[2], KVM_CREATE_VM, 0);

        struct kvm_irqfd ifd;
        ifd.fd = syscall(SYS_eventfd2, 5, 0);
        ifd.gsi = 3;
        ifd.flags = 2;
        ifd.resamplefd = ifd.fd;
        r[25] = ioctl(r[3], KVM_IRQFD, &ifd);
        return 0;
    }

Reported-by: Dmitry Vyukov <dvyukov@google.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Radim Krčmář <rkrcmar@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-06-24 10:18:18 -07:00
Marc Zyngier
5716a93fef KVM: arm/arm64: Handle forward time correction gracefully
commit 1c5631c73fc2261a5df64a72c155cb53dcdc0c45 upstream.

On a host that runs NTP, corrections can have a direct impact on
the background timer that we program on the behalf of a vcpu.

In particular, NTP performing a forward correction will result in
a timer expiring sooner than expected from a guest point of view.
Not a big deal, we kick the vcpu anyway.

But on wake-up, the vcpu thread is going to perform a check to
find out whether or not it should block. And at that point, the
timer check is going to say "timer has not expired yet, go back
to sleep". This results in the timer event being lost forever.

There are multiple ways to handle this. One would be record that
the timer has expired and let kvm_cpu_has_pending_timer return
true in that case, but that would be fairly invasive. Another is
to check for the "short sleep" condition in the hrtimer callback,
and restart the timer for the remaining time when the condition
is detected.

This patch implements the latter, with a bit of refactoring in
order to avoid too much code duplication.

Reported-by: Alexander Graf <agraf@suse.de>
Reviewed-by: Alexander Graf <agraf@suse.de>
Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
Signed-off-by: Christoffer Dall <christoffer.dall@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-05-04 14:48:40 -07:00
Paolo Bonzini
4e2fa4bbba KVM: fix spin_lock_init order on x86
commit e9ad4ec8379ad1ba6f68b8ca1c26b50b5ae0a327 upstream.

Moving the initialization earlier is needed in 4.6 because
kvm_arch_init_vm is now using mmu_lock, causing lockdep to
complain:

[  284.440294] INFO: trying to register non-static key.
[  284.445259] the code is fine but needs lockdep annotation.
[  284.450736] turning off the locking correctness validator.
...
[  284.528318]  [<ffffffff810aecc3>] lock_acquire+0xd3/0x240
[  284.533733]  [<ffffffffa0305aa0>] ? kvm_page_track_register_notifier+0x20/0x60 [kvm]
[  284.541467]  [<ffffffff81715581>] _raw_spin_lock+0x41/0x80
[  284.546960]  [<ffffffffa0305aa0>] ? kvm_page_track_register_notifier+0x20/0x60 [kvm]
[  284.554707]  [<ffffffffa0305aa0>] kvm_page_track_register_notifier+0x20/0x60 [kvm]
[  284.562281]  [<ffffffffa02ece70>] kvm_mmu_init_vm+0x20/0x30 [kvm]
[  284.568381]  [<ffffffffa02dbf7a>] kvm_arch_init_vm+0x1ea/0x200 [kvm]
[  284.574740]  [<ffffffffa02bff3f>] kvm_dev_ioctl+0xbf/0x4d0 [kvm]

However, it also helps fixing a preexisting problem, which is why this
patch is also good for stable kernels: kvm_create_vm was incrementing
current->mm->mm_count but not decrementing it at the out_err label (in
case kvm_init_mmu_notifier failed).  The new initialization order makes
it possible to add the required mmdrop without adding a new error label.

Reported-by: Borislav Petkov <bp@alien8.de>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-04-12 09:08:34 -07:00
David Matlack
c9e1bbef7e kvm: cap halt polling at exactly halt_poll_ns
commit 313f636d5c490c9741d3f750dc8da33029edbc6b upstream.

When growing halt-polling, there is no check that the poll time exceeds
the limit. It's possible for vcpu->halt_poll_ns grow once past
halt_poll_ns, and stay there until a halt which takes longer than
vcpu->halt_poll_ns. For example, booting a Linux guest with
halt_poll_ns=11000:

 ... kvm:kvm_halt_poll_ns: vcpu 0: halt_poll_ns 0 (shrink 10000)
 ... kvm:kvm_halt_poll_ns: vcpu 0: halt_poll_ns 10000 (grow 0)
 ... kvm:kvm_halt_poll_ns: vcpu 0: halt_poll_ns 20000 (grow 10000)

Signed-off-by: David Matlack <dmatlack@google.com>
Fixes: aca6ff29c4
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-03-16 08:42:58 -07:00
Mark Rutland
d62cca1106 KVM: arm/arm64: vgic: Ensure bitmaps are long enough
commit 236cf17c2502007a9d2dda3c39fb0d9a6bd03cc2 upstream.

When we allocate bitmaps in vgic_vcpu_init_maps, we divide the number of
bits we need by 8 to figure out how many bytes to allocate. However,
bitmap elements are always accessed as unsigned longs, and if we didn't
happen to allocate a size such that size % sizeof(unsigned long) == 0,
bitmap accesses may go past the end of the allocation.

When using KASAN (which does byte-granular access checks), this results
in a continuous stream of BUGs whenever these bitmaps are accessed:

=============================================================================
BUG kmalloc-128 (Tainted: G    B          ): kasan: bad access detected
-----------------------------------------------------------------------------

INFO: Allocated in vgic_init.part.25+0x55c/0x990 age=7493 cpu=3 pid=1730
INFO: Slab 0xffffffbde6d5da40 objects=16 used=15 fp=0xffffffc935769700 flags=0x4000000000000080
INFO: Object 0xffffffc935769500 @offset=1280 fp=0x          (null)

Bytes b4 ffffffc9357694f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
Object ffffffc935769500: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
Object ffffffc935769510: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
Object ffffffc935769520: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
Object ffffffc935769530: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
Object ffffffc935769540: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
Object ffffffc935769550: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
Object ffffffc935769560: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
Object ffffffc935769570: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
Padding ffffffc9357695b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
Padding ffffffc9357695c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
Padding ffffffc9357695d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
Padding ffffffc9357695e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
Padding ffffffc9357695f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
CPU: 3 PID: 1740 Comm: kvm-vcpu-0 Tainted: G    B           4.4.0+ #17
Hardware name: ARM Juno development board (r1) (DT)
Call trace:
[<ffffffc00008e770>] dump_backtrace+0x0/0x280
[<ffffffc00008ea04>] show_stack+0x14/0x20
[<ffffffc000726360>] dump_stack+0x100/0x188
[<ffffffc00030d324>] print_trailer+0xfc/0x168
[<ffffffc000312294>] object_err+0x3c/0x50
[<ffffffc0003140fc>] kasan_report_error+0x244/0x558
[<ffffffc000314548>] __asan_report_load8_noabort+0x48/0x50
[<ffffffc000745688>] __bitmap_or+0xc0/0xc8
[<ffffffc0000d9e44>] kvm_vgic_flush_hwstate+0x1bc/0x650
[<ffffffc0000c514c>] kvm_arch_vcpu_ioctl_run+0x2ec/0xa60
[<ffffffc0000b9a6c>] kvm_vcpu_ioctl+0x474/0xa68
[<ffffffc00036b7b0>] do_vfs_ioctl+0x5b8/0xcb0
[<ffffffc00036bf34>] SyS_ioctl+0x8c/0xa0
[<ffffffc000086cb0>] el0_svc_naked+0x24/0x28
Memory state around the buggy address:
 ffffffc935769400: 00 00 fc fc fc fc fc fc fc fc fc fc fc fc fc fc
 ffffffc935769480: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
>ffffffc935769500: 04 fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
                   ^
 ffffffc935769580: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
 ffffffc935769600: 00 00 00 00 fc fc fc fc fc fc fc fc fc fc fc fc
==================================================================

Fix the issue by always allocating a multiple of sizeof(unsigned long),
as we do elsewhere in the vgic code.

Fixes: c1bfb577a ("arm/arm64: KVM: vgic: switch to dynamic allocation")
Acked-by: Marc Zyngier <marc.zyngier@arm.com>
Acked-by: Christoffer Dall <christoffer.dall@linaro.org>
Signed-off-by: Mark Rutland <mark.rutland@arm.com>
Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-03-03 15:07:29 -08:00
Christian Borntraeger
85212a3690 KVM: async_pf: do not warn on page allocation failures
commit d7444794a02ff655eda87e3cc54e86b940e7736f upstream.

In async_pf we try to allocate with NOWAIT to get an element quickly
or fail. This code also handle failures gracefully. Lets silence
potential page allocation failures under load.

qemu-system-s39: page allocation failure: order:0,mode:0x2200000
[...]
Call Trace:
([<00000000001146b8>] show_trace+0xf8/0x148)
[<000000000011476a>] show_stack+0x62/0xe8
[<00000000004a36b8>] dump_stack+0x70/0x98
[<0000000000272c3a>] warn_alloc_failed+0xd2/0x148
[<000000000027709e>] __alloc_pages_nodemask+0x94e/0xb38
[<00000000002cd36a>] new_slab+0x382/0x400
[<00000000002cf7ac>] ___slab_alloc.constprop.30+0x2dc/0x378
[<00000000002d03d0>] kmem_cache_alloc+0x160/0x1d0
[<0000000000133db4>] kvm_setup_async_pf+0x6c/0x198
[<000000000013dee8>] kvm_arch_vcpu_ioctl_run+0xd48/0xd58
[<000000000012fcaa>] kvm_vcpu_ioctl+0x372/0x690
[<00000000002f66f6>] do_vfs_ioctl+0x3be/0x510
[<00000000002f68ec>] SyS_ioctl+0xa4/0xb8
[<0000000000781c5e>] system_call+0xd6/0x264
[<000003ffa24fa06a>] 0x3ffa24fa06a

Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
Reviewed-by: Dominik Dingel <dingel@linux.vnet.ibm.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-03-03 15:07:29 -08:00
Andre Przywara
b3e336de65 KVM: arm/arm64: Fix reference to uninitialised VGIC
commit b3aff6ccbb1d25e506b60ccd9c559013903f3464 upstream.

Commit 4b4b4512da ("arm/arm64: KVM: Rework the arch timer to use
level-triggered semantics") brought the virtual architected timer
closer to the VGIC. There is one occasion were we don't properly
check for the VGIC actually having been initialized before, but
instead go on to check the active state of some IRQ number.
If userland hasn't instantiated a virtual GIC, we end up with a
kernel NULL pointer dereference:
=========
Unable to handle kernel NULL pointer dereference at virtual address 00000000
pgd = ffffffc9745c5000
[00000000] *pgd=00000009f631e003, *pud=00000009f631e003, *pmd=0000000000000000
Internal error: Oops: 96000006 [#2] PREEMPT SMP
Modules linked in:
CPU: 0 PID: 2144 Comm: kvm_simplest-ar Tainted: G      D 4.5.0-rc2+ #1300
Hardware name: ARM Juno development board (r1) (DT)
task: ffffffc976da8000 ti: ffffffc976e28000 task.ti: ffffffc976e28000
PC is at vgic_bitmap_get_irq_val+0x78/0x90
LR is at kvm_vgic_map_is_active+0xac/0xc8
pc : [<ffffffc0000b7e28>] lr : [<ffffffc0000b972c>] pstate: 20000145
....
=========

Fix this by bailing out early of kvm_timer_flush_hwstate() if we don't
have a VGIC at all.

Reported-by: Cosmin Gorgovan <cosmin@linux-geek.org>
Acked-by: Marc Zyngier <marc.zyngier@arm.com>
Signed-off-by: Andre Przywara <andre.przywara@arm.com>
Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-02-25 12:01:20 -08:00
Christoffer Dall
fdec12c12e KVM: arm/arm64: vgic: Fix kvm_vgic_map_is_active's dist check
External inputs to the vgic from time to time need to poke into the
state of a virtual interrupt, the prime example is the architected timer
code.

Since the IRQ's active state can be represented in two places; the LR or
the distributor, we first loop over the LRs but if not active in the LRs
we just return if *any* IRQ is active on the VCPU in question.

This is of course bogus, as we should check if the specific IRQ in
quesiton is active on the distributor instead.

Reported-by: Eric Auger <eric.auger@linaro.org>
Acked-by: Marc Zyngier <marc.zyngier@arm.com>
Signed-off-by: Christoffer Dall <christoffer.dall@linaro.org>
Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
2015-12-11 16:33:31 +00:00
Christoffer Dall
9f958c11b7 KVM: arm/arm64: vgic: Trust the LR state for HW IRQs
We were probing the physial distributor state for the active state of a
HW virtual IRQ, because we had seen evidence that the LR state was not
cleared when the guest deactivated a virtual interrupted.

However, this issue turned out to be a software bug in the GIC, which
was solved by: 84aab5e68c2a5e1e18d81ae8308c3ce25d501b29
(KVM: arm/arm64: arch_timer: Preserve physical dist. active
state on LR.active, 2015-11-24)

Therefore, get rid of the complexities and just look at the LR.

Reviewed-by: Marc Zyngier <marc.zyngier@arm.com>
Signed-off-by: Christoffer Dall <christoffer.dall@linaro.org>
2015-11-24 18:08:37 +01:00
Christoffer Dall
0e3dfda91d KVM: arm/arm64: arch_timer: Preserve physical dist. active state on LR.active
We were incorrectly removing the active state from the physical
distributor on the timer interrupt when the timer output level was
deasserted.  We shouldn't be doing this without considering the virtual
interrupt's active state, because the architecture requires that when an
LR has the HW bit set and the pending or active bits set, then the
physical interrupt must also have the corresponding bits set.

This addresses an issue where we have been observing an inconsistency
between the LR state and the physical distributor state where the LR
state was active and the physical distributor was not active, which
shouldn't happen.

Reviewed-by: Marc Zyngier <marc.zyngier@arm.com>
Signed-off-by: Christoffer Dall <christoffer.dall@linaro.org>
2015-11-24 18:07:40 +01:00
Linus Torvalds
933425fb00 Merge tag 'for-linus' of git://git.kernel.org/pub/scm/virt/kvm/kvm
Pull KVM updates from Paolo Bonzini:
 "First batch of KVM changes for 4.4.

  s390:
     A bunch of fixes and optimizations for interrupt and time handling.

  PPC:
     Mostly bug fixes.

  ARM:
     No big features, but many small fixes and prerequisites including:

      - a number of fixes for the arch-timer

      - introducing proper level-triggered semantics for the arch-timers

      - a series of patches to synchronously halt a guest (prerequisite
        for IRQ forwarding)

      - some tracepoint improvements

      - a tweak for the EL2 panic handlers

      - some more VGIC cleanups getting rid of redundant state

  x86:
     Quite a few changes:

      - support for VT-d posted interrupts (i.e. PCI devices can inject
        interrupts directly into vCPUs).  This introduces a new
        component (in virt/lib/) that connects VFIO and KVM together.
        The same infrastructure will be used for ARM interrupt
        forwarding as well.

      - more Hyper-V features, though the main one Hyper-V synthetic
        interrupt controller will have to wait for 4.5.  These will let
        KVM expose Hyper-V devices.

      - nested virtualization now supports VPID (same as PCID but for
        vCPUs) which makes it quite a bit faster

      - for future hardware that supports NVDIMM, there is support for
        clflushopt, clwb, pcommit

      - support for "split irqchip", i.e.  LAPIC in kernel +
        IOAPIC/PIC/PIT in userspace, which reduces the attack surface of
        the hypervisor

      - obligatory smattering of SMM fixes

      - on the guest side, stable scheduler clock support was rewritten
        to not require help from the hypervisor"

* tag 'for-linus' of git://git.kernel.org/pub/scm/virt/kvm/kvm: (123 commits)
  KVM: VMX: Fix commit which broke PML
  KVM: x86: obey KVM_X86_QUIRK_CD_NW_CLEARED in kvm_set_cr0()
  KVM: x86: allow RSM from 64-bit mode
  KVM: VMX: fix SMEP and SMAP without EPT
  KVM: x86: move kvm_set_irq_inatomic to legacy device assignment
  KVM: device assignment: remove pointless #ifdefs
  KVM: x86: merge kvm_arch_set_irq with kvm_set_msi_inatomic
  KVM: x86: zero apic_arb_prio on reset
  drivers/hv: share Hyper-V SynIC constants with userspace
  KVM: x86: handle SMBASE as physical address in RSM
  KVM: x86: add read_phys to x86_emulate_ops
  KVM: x86: removing unused variable
  KVM: don't pointlessly leave KVM_COMPAT=y in non-KVM configs
  KVM: arm/arm64: Merge vgic_set_lr() and vgic_sync_lr_elrsr()
  KVM: arm/arm64: Clean up vgic_retire_lr() and surroundings
  KVM: arm/arm64: Optimize away redundant LR tracking
  KVM: s390: use simple switch statement as multiplexer
  KVM: s390: drop useless newline in debugging data
  KVM: s390: SCA must not cross page boundaries
  KVM: arm: Do not indent the arguments of DECLARE_BITMAP
  ...
2015-11-05 16:26:26 -08:00
Paolo Bonzini
b97e6de9c9 KVM: x86: merge kvm_arch_set_irq with kvm_set_msi_inatomic
We do not want to do too much work in atomic context, in particular
not walking all the VCPUs of the virtual machine.  So we want
to distinguish the architecture-specific injection function for irqfd
from kvm_set_msi.  Since it's still empty, reuse the newly added
kvm_arch_set_irq and rename it to kvm_arch_set_irq_inatomic.

Reviewed-by: Radim Krčmář <rkrcmar@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2015-11-04 16:24:35 +01:00