commit e5dc37a098176b75c646baaef2abba15e722d530
Author: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Date:   Tue Nov 21 10:24:36 2017 +0100

    Linux 4.13.15

commit c0e8b149d390187c0f16ea0770c0cff4bd7fb8bc
Author: Hans de Goede <hdegoede@redhat.com>
Date:   Thu Nov 2 10:30:13 2017 +0100

    staging: rtl8188eu: Revert 4 commits breaking ARP
    
    commit 66d32fdcbf03851724a8b551d490ae1ddfe6eef2 upstream.
    
    Commit 2ba8444c97b1 ("staging:r8188eu: move IV/ICV trimming into
    decrypt() and also place it after rtl88eu_mon_recv_hook()") breaks ARP.
    
    After this commit ssh-ing to a laptop with r8188eu wifi no longer works
    if the machine connecting has never communicated with the laptop before.
    This is 100% reproducable using "arp -d <ipv4> && ssh <ipv4>" to ssh to
    a laptop with r8188eu wifi.
    
    This commit reverts 4 commits in total:
    
    1. Commit 79650ffde38e ("staging:r8188eu: trim IV/ICV fields in
       validate_recv_data_frame()")
    This commit depends on 2 of the other commits being reverted.
    
    2. Commit 02b19b4c4920 ("staging:r8188eu: inline unprotect_frame() in
       mon_recv_decrypted_recv()")
    The inline code is wrong the un-inlined version contains:
            if (skb->len < hdr_len + iv_len + icv_len)
                    return;
            ...
    Where as the inline-ed code introduced by this commit does:
            if (skb->len < hdr_len + iv_len + icv_len) {
                    ...
    Note the same check, but now to actually continue doing ... instead
    of to not do it, so this commit is no good.
    
    3. Commit d86e16da6a5d ("staging:r8188eu: use different mon_recv_decrypted()
       inside rtl88eu_mon_recv_hook() and rtl88eu_mon_xmit_hook().")
    This commit introduced a 1:1 copy of a function so that one of the
    2 copies can be modified in the 2 commits we're already reverting.
    
    4. Commit 2ba8444c97b1 ("staging:r8188eu: move IV/ICV trimming into
       decrypt() and also place it after rtl88eu_mon_recv_hook()")
    This is the commit actually breaking ARP.
    
    Note this commit is a straight-forward squash of the revert of these
    4 commits, without any changes.
    
    Cc: Ivan Safonov <insafonov@gmail.com>
    Signed-off-by: Hans de Goede <hdegoede@redhat.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 19920331c80af2c01dbfe6b7dcd4bdc79a589aac
Author: Hans de Goede <hdegoede@redhat.com>
Date:   Thu Oct 12 20:10:25 2017 +0200

    staging: vboxvideo: Fix reporting invalid suggested-offset-properties
    
    commit ce10d7b4e8e3574b9616e54a09d64521b9aeb8b6 upstream.
    
    The x and y hints receives from the host are unsigned 32 bit integers and
    they get set to -1 (0xffffffff) when invalid. Before this commit the
    vboxvideo driver was storing them in an u16 causing the -1 to be truncated
    to 65535 which, once reported to userspace, was breaking gnome 3.26+
    in Wayland mode.
    
    This commit stores the host values in 32 bit variables, removing the
    truncation and checks for -1, replacing it with 0 as -1 is not a valid
    suggested-offset-property value. Likewise the properties are now
    initialized to 0 instead of -1, since -1 is not a valid value.
    This fixes gnome 3.26+ in Wayland mode not working with the vboxvideo
    driver.
    
    Reported-by: Gianfranco Costamagna <locutusofborg@debian.org>
    Cc: Michael Thayer <michael.thayer@oracle.com>
    Signed-off-by: Hans de Goede <hdegoede@redhat.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 8a21d7f17bddbf496a06b4d91a29f2476be6c37a
Author: Johan Hovold <johan@kernel.org>
Date:   Sun Oct 29 13:01:33 2017 +0100

    staging: greybus: spilib: fix use-after-free after deregistration
    
    commit 770b03c2ca4aa44d226cf248f86aa23e546147d0 upstream.
    
    Remove erroneous spi_master_put() after controller deregistration which
    would access the already freed spi controller.
    
    Note that spi_unregister_master() drops our only controller reference.
    
    Fixes: ba3e67001b42 ("greybus: SPI: convert to a gpbridge driver")
    Signed-off-by: Johan Hovold <johan@kernel.org>
    Reviewed-by: Rui Miguel Silva <rmfrfs@gmail.com>
    Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 0f003bb5010fd9a2dc71809183370656c94eca34
Author: Gilad Ben-Yossef <gilad@benyossef.com>
Date:   Mon Oct 30 13:38:03 2017 +0000

    staging: ccree: fix 64 bit scatter/gather DMA ops
    
    commit e0b3f39092a1cff5548cbaf40096ec25e7721de6 upstream.
    
    Fix a wrong offset used in splitting a 64 DMA address to MSB/LSB
    parts needed for scatter/gather HW descriptors causing operations
    relying on them to fail on 64 bit platforms.
    
    Fixes: c6f7f2f4591f ("staging: ccree: refactor LLI access macros")
    Reported-by: Stuart Yoder <stuart.yoder@arm.com>
    Signed-off-by: Gilad Ben-Yossef <gilad@benyossef.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit c52278a636018cb8fa39b2538c6da5d35e6515f7
Author: Huacai Chen <chenhc@lemote.com>
Date:   Mon Nov 6 08:43:03 2017 +0800

    staging: sm750fb: Fix parameter mistake in poke32
    
    commit 16808dcf605e6302319a8c3266789b76d4c0983b upstream.
    
    In commit c075b6f2d357ea9 ("staging: sm750fb: Replace POKE32 and PEEK32
    by inline functions"), POKE32 has been replaced by the inline function
    poke32. But it exchange the "addr" and "data" parameters by mistake, so
    fix it.
    
    Fixes: c075b6f2d357ea9 ("staging: sm750fb: Replace POKE32 and PEEK32 by inline functions"),
    Signed-off-by: Huacai Chen <chenhc@lemote.com>
    Signed-off-by: Liangliang Huang <huangll@lemote.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 274f1097b2041506a6a3ab21c1d3a01897b34b65
Author: Aditya Shankar <aditya.shankar@microchip.com>
Date:   Fri Nov 3 14:26:27 2017 +0530

    staging: wilc1000: Fix bssid buffer offset in Txq
    
    commit 1bbf6a6d4091affb27ec0a19d7aa7887ce72f610 upstream.
    
    Commit 46949b48568b ("staging: wilc1000: New cfg packet
    format in handle_set_wfi_drv_handler") updated the frame
    format sent from host to the firmware. The code to update
    the bssid offset in the new frame was part of a second
    patch in the series which did not make it in and thus
    causes connection problems after associating to an AP.
    
    This fix adds the proper offset of the bssid value in the
    Tx queue buffer to fix the connection issues.
    
    Fixes: 46949b48568b ("staging: wilc1000: New cfg packet format in handle_set_wfi_drv_handler")
    Signed-off-by: Aditya Shankar <Aditya.Shankar@microchip.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 8604c6181edd1a62a6bf1f07261b547e6a74afe1
Author: Jason Gerecke <killertofu@gmail.com>
Date:   Wed Oct 18 08:27:13 2017 -0700

    HID: wacom: generic: Recognize WACOM_HID_WD_PEN as a type of pen collection
    
    commit 885e89f601a52cc6fb025b009df58ba83d142734 upstream.
    
    The WACOM_PEN_FIELD macro is used to determine if a given HID field should be
    associated with pen input. This field includes several known collection types
    that Wacom pen data is contained in, but the WACOM_HID_WD_PEN application
    collection type is notably missing. This can result in fields within this
    kind of collection being completely ignored by the `wacom_usage_mapping`
    function, preventing the later '*_event' functions from being notified about
    changes to their value.
    
    Fixes: c9c095874a ("HID: wacom: generic: Support and use 'Custom HID' mode and usages")
    Fixes: ac2423c975 ("HID: wacom: generic: add vendor defined touch")
    Reviewed-by: Ping Cheng <ping.cheng@wacom.com>
    Reviewed-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
    Signed-off-by: Jason Gerecke <jason.gerecke@wacom.com>
    Signed-off-by: Jiri Kosina <jkosina@suse.cz>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 8c4738583b6858dccac3ef2ac7bea920a3a0cd8d
Author: Sébastien Szymanski <sebastien.szymanski@armadeus.com>
Date:   Thu Nov 2 12:12:43 2017 +0100

    HID: cp2112: add HIDRAW dependency
    
    commit cde3076bdc38bf436e517a379759a9092c6ffd4f upstream.
    
    Otherwise, with HIDRAW=n, the probe function crashes because of null
    dereference of hdev->hidraw.
    
    Fixes: 42cb6b35b9e6 ("HID: cp2112: use proper hidraw name with minor number")
    Signed-off-by: Sébastien Szymanski <sebastien.szymanski@armadeus.com>
    Acked-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
    Signed-off-by: Jiri Kosina <jkosina@suse.cz>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 9a9f503038b7a103bcdc3bb4447d6c94b0aaeadd
Author: Hans de Goede <hdegoede@redhat.com>
Date:   Mon Oct 30 14:07:37 2017 +0100

    platform/x86: peaq_wmi: Fix missing terminating entry for peaq_dmi_table
    
    commit d6fa71f1c003fb2bc824276bb424a4171f9a717f upstream.
    
    Add missing terminating entry to peaq_dmi_table.
    
    Fixes: 3b95206110a2 ("platform/x86: peaq-wmi: Add DMI check before ...")
    Reported-by: Fengguang Wu <fengguang.wu@intel.com>
    Signed-off-by: Hans de Goede <hdegoede@redhat.com>
    Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit ea6af85855b6758b8bd77d9521a5e651dc36dfc9
Author: Hans de Goede <hdegoede@redhat.com>
Date:   Thu Oct 5 20:04:04 2017 +0200

    platform/x86: peaq-wmi: Add DMI check before binding to the WMI interface
    
    commit 3b95206110a2c13076c3a7fa8ddeae36c2dbcf42 upstream.
    
    It seems that the WMI GUID used by the PEAQ 2-in-1 WMI hotkeys is not
    as unique as a GUID should be and is used on some other devices too.
    
    This is causing spurious key-press reports on these other devices.
    
    This commits adds a DMI check to the PEAQ 2-in-1 WMI hotkeys driver to
    ensure that it is actually running on a PEAQ 2-in-1, fixing the
    spurious key-presses on these other devices.
    
    BugLink: https://bugzilla.redhat.com/show_bug.cgi?id=1497861
    BugLink: https://bugzilla.suse.com/attachment.cgi?id=743182
    Signed-off-by: Hans de Goede <hdegoede@redhat.com>
    Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 56190dc9c05e58b0e809f6001dc5cc8159d6a32f
Author: Yazen Ghannam <yazen.ghannam@amd.com>
Date:   Mon Nov 6 18:46:32 2017 +0100

    x86/MCE/AMD: Always give panic severity for UC errors in kernel context
    
    commit d65dfc81bb3894fdb68cbc74bbf5fb48d2354071 upstream.
    
    The AMD severity grading function was introduced in kernel 4.1. The
    current logic can possibly give MCE_AR_SEVERITY for uncorrectable
    errors in kernel context. The system may then get stuck in a loop as
    memory_failure() will try to handle the bad kernel memory and find it
    busy.
    
    Return MCE_PANIC_SEVERITY for all UC errors IN_KERNEL context on AMD
    systems.
    
    After:
    
      b2f9d678e28c ("x86/mce: Check for faults tagged in EXTABLE_CLASS_FAULT exception table entries")
    
    was accepted in v4.6, this issue was masked because of the tail-end attempt
    at kernel mode recovery in the #MC handler.
    
    However, uncorrectable errors IN_KERNEL context should always be considered
    unrecoverable and cause a panic.
    
    Signed-off-by: Yazen Ghannam <yazen.ghannam@amd.com>
    Signed-off-by: Borislav Petkov <bp@suse.de>
    Cc: Linus Torvalds <torvalds@linux-foundation.org>
    Cc: Peter Zijlstra <peterz@infradead.org>
    Cc: Thomas Gleixner <tglx@linutronix.de>
    Cc: Tony Luck <tony.luck@intel.com>
    Cc: linux-edac <linux-edac@vger.kernel.org>
    Fixes: bf80bbd7dcf5 (x86/mce: Add an AMD severities-grading function)
    Link: http://lkml.kernel.org/r/20171106174633.13576-1-bp@alien8.de
    Signed-off-by: Ingo Molnar <mingo@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit f44814f17cb8165d5147f28f0ac1dfc01294a30f
Author: Andy Lutomirski <luto@kernel.org>
Date:   Sat Nov 4 04:19:48 2017 -0700

    selftests/x86/protection_keys: Fix syscall NR redefinition warnings
    
    commit 693cb5580fdb026922363aa103add64b3ecd572e upstream.
    
    On new enough glibc, the pkey syscalls numbers are available.  Check
    first before defining them to avoid warnings like:
    
    protection_keys.c:198:0: warning: "SYS_pkey_alloc" redefined
    
    Signed-off-by: Andy Lutomirski <luto@kernel.org>
    Cc: Borislav Petkov <bpetkov@suse.de>
    Cc: Dave Hansen <dave.hansen@intel.com>
    Cc: Linus Torvalds <torvalds@linux-foundation.org>
    Cc: Peter Zijlstra <peterz@infradead.org>
    Cc: Thomas Gleixner <tglx@linutronix.de>
    Link: http://lkml.kernel.org/r/1fbef53a9e6befb7165ff855fc1a7d4788a191d6.1509794321.git.luto@kernel.org
    Signed-off-by: Ingo Molnar <mingo@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 3ebf0608d9f7f32f4ecde00d7bfdc2a6a098f06d
Author: Johan Hovold <johan@kernel.org>
Date:   Wed Oct 11 14:02:58 2017 +0200

    USB: serial: garmin_gps: fix memory leak on probe errors
    
    commit 74d471b598444b7f2d964930f7234779c80960a0 upstream.
    
    Make sure to free the port private data before returning after a failed
    probe attempt.
    
    Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
    Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Signed-off-by: Johan Hovold <johan@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 031bd81488143bfdc51d38b88ee85898dfd4c2e6
Author: Johan Hovold <johan@kernel.org>
Date:   Wed Oct 11 14:02:57 2017 +0200

    USB: serial: garmin_gps: fix I/O after failed probe and remove
    
    commit 19a565d9af6e0d828bd0d521d3bafd5017f4ce52 upstream.
    
    Make sure to stop any submitted interrupt and bulk-out URBs before
    returning after failed probe and when the port is being unbound to avoid
    later NULL-pointer dereferences in the completion callbacks.
    
    Also fix up the related and broken I/O cancellation on failed open and
    on close. (Note that port->write_urb was never submitted.)
    
    Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
    Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Signed-off-by: Johan Hovold <johan@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 8eb1108ad8fe1efb84644210c67d1c2c2b263c6a
Author: Douglas Fischer <douglas.fischer@outlook.com>
Date:   Sun Oct 29 23:29:55 2017 +0000

    USB: serial: qcserial: add pid/vid for Sierra Wireless EM7355 fw update
    
    commit 771394a54148f18926ca86414e51c69eda27d0cd upstream.
    
    Add USB PID/VID for Sierra Wireless EM7355 LTE modem QDL firmware update
    mode.
    
    Signed-off-by: Douglas Fischer <douglas.fischer@outlook.com>
    Signed-off-by: Johan Hovold <johan@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit fab970bea2895ac7deedc2699b0c267333b3342e
Author: Lu Baolu <baolu.lu@linux.intel.com>
Date:   Tue Nov 7 10:28:16 2017 +0800

    USB: serial: Change DbC debug device binding ID
    
    commit 12f28144cf2cf69e1520e238eee7c384719ca44b upstream.
    
    The product ID for "Linux USB GDB Target device" has been
    changed. Change the driver binding table accordingly.
    
    This patch should be back-ported to kernels as old as v4.12,
    that contain the commit 57fb47279a04 ("usb/serial: Add DBC
    debug device support to usb_debug").
    
    Cc: Johan Hovold <johan@kernel.org>
    Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit ee8a16f894629d494c7a8f5ac3f3d699eef4b3ec
Author: Johan Hovold <johan@kernel.org>
Date:   Thu Oct 12 10:54:21 2017 +0200

    USB: serial: metro-usb: stop I/O after failed open
    
    commit 2339536d229df25c71c0900fc619289229bfecf6 upstream.
    
    Make sure to kill the interrupt-in URB after a failed open request.
    Apart from saving power (and avoiding stale input after a later
    successful open), this also prevents a NULL-deref in the completion
    handler if the port is manually unbound.
    
    Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Fixes: 704577861d5e ("USB: serial: metro-usb: get data from device in Uni-Directional mode.")
    Signed-off-by: Johan Hovold <johan@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 6ba8cd35c91401224f34fa937dfe3ead007274dc
Author: Andrew Gabbasov <andrew_gabbasov@mentor.com>
Date:   Wed Nov 8 10:13:15 2017 -0700

    usb: gadget: f_fs: Fix use-after-free in ffs_free_inst
    
    commit cdafb6d8b8da7fde266f79b3287ac221aa841879 upstream.
    
    KASAN enabled configuration reports an error
    
    BUG: KASAN: use-after-free in ffs_free_inst+... [usb_f_fs] at addr ...
    Write of size 8 by task ...
    
    This is observed after "ffs-test" is run and interrupted. If after that
    functionfs is unmounted and g_ffs module is unloaded, that use-after-free
    occurs during g_ffs module removal.
    
    Although the report indicates ffs_free_inst() function, the actual
    use-after-free condition occurs in _ffs_free_dev() function, which
    is probably inlined into ffs_free_inst().
    
    This happens due to keeping the ffs_data reference in device structure
    during functionfs unmounting, while ffs_data itself is freed as no longer
    needed. The fix is to clear that reference in ffs_closed() function,
    which is a counterpart of ffs_ready(), where the reference is stored.
    
    Fixes: 3262ad824307 ("usb: gadget: f_fs: Stop ffs_closed NULL pointer dereference")
    Signed-off-by: Andrew Gabbasov <andrew_gabbasov@mentor.com>
    Acked-by: Felipe Balbi <felipe.balbi@linux.intel.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit cc809dde8c8fc4c0af3938307a5d8f6a4a4be2fb
Author: Bernhard Rosenkraenzer <bernhard.rosenkranzer@linaro.org>
Date:   Fri Nov 3 16:46:02 2017 +0100

    USB: Add delay-init quirk for Corsair K70 LUX keyboards
    
    commit a0fea6027f19c62727315aba1a7fae75a9caa842 upstream.
    
    Without this patch, K70 LUX keyboards don't work, saying
    usb 3-3: unable to read config index 0 descriptor/all
    usb 3-3: can't read configurations, error -110
    usb usb3-port3: unable to enumerate USB device
    
    Signed-off-by: Bernhard Rosenkraenzer <Bernhard.Rosenkranzer@linaro.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit bd643f60f80c6ba92dc5430d872700e71dd39ad0
Author: Alan Stern <stern@rowland.harvard.edu>
Date:   Wed Nov 8 12:23:17 2017 -0500

    USB: usbfs: compute urb->actual_length for isochronous
    
    commit 2ef47001b3ee3ded579b7532ebdcf8680e4d8c54 upstream.
    
    The USB kerneldoc says that the actual_length field "is read in
    non-iso completion functions", but the usbfs driver uses it for all
    URB types in processcompl().  Since not all of the host controller
    drivers set actual_length for isochronous URBs, programs using usbfs
    with some host controllers don't work properly.  For example, Minas
    reports that a USB camera controlled by libusb doesn't work properly
    with a dwc2 controller.
    
    It doesn't seem worthwhile to change the HCDs and the documentation,
    since the in-kernel USB class drivers evidently don't rely on
    actual_length for isochronous transfers.  The easiest solution is for
    usbfs to calculate the actual_length value for itself, by adding up
    the lengths of the individual packets in an isochronous transfer.
    
    Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
    CC: Minas Harutyunyan <Minas.Harutyunyan@synopsys.com>
    Reported-and-tested-by: wlf <wulf@rock-chips.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 80bc8107eedf4fe4f59152d43acde71fe9ef3a9b
Author: Lu Baolu <baolu.lu@linux.intel.com>
Date:   Tue Nov 7 10:28:15 2017 +0800

    USB: early: Use new USB product ID and strings for DbC device
    
    commit c67678ec78eff9cf1e7e997fe6c37c9fcccfc5b8 upstream.
    
    The DbC register set defines an interface for system software
    to specify the vendor id and product id for the debug device.
    These two values will be presented by the debug device in its
    device descriptor idVendor and idProduct fields.
    
    The current used product ID is a place holder. We now have a
    valid one. The description strings are changed accordingly.
    
    This patch should be back-ported to kernels as old as v4.12,
    that contain the commit aeb9dd1de98c ("usb/early: Add driver
    for xhci debug capability").
    
    Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 38957dc97f3039c0dc35c7ecde848c3ea9a54e9b
Author: Eric Biggers <ebiggers@google.com>
Date:   Sun Nov 5 18:30:46 2017 -0800

    crypto: dh - Don't permit 'key' or 'g' size longer than 'p'
    
    commit ccd9888f14a8019c0bbdeeae758aba1f58693712 upstream.
    
    The "qat-dh" DH implementation assumes that 'key' and 'g' can be copied
    into a buffer with size 'p_size'.  However it was never checked that
    that was actually the case, which most likely allowed users to cause a
    buffer underflow via KEYCTL_DH_COMPUTE.
    
    Fix this by updating crypto_dh_decode_key() to verify this precondition
    for all DH implementations.
    
    Fixes: c9839143ebbf ("crypto: qat - Add DH support")
    Signed-off-by: Eric Biggers <ebiggers@google.com>
    Reviewed-by: Tudor Ambarus <tudor.ambarus@microchip.com>
    Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 208116d5b7390720b5922413f05209947700a28c
Author: Eric Biggers <ebiggers@google.com>
Date:   Sun Nov 5 18:30:45 2017 -0800

    crypto: dh - Don't permit 'p' to be 0
    
    commit 199512b1234f09e44d592153ec82b44212b2f0c4 upstream.
    
    If 'p' is 0 for the software Diffie-Hellman implementation, then
    dh_max_size() returns 0.  In the case of KEYCTL_DH_COMPUTE, this causes
    ZERO_SIZE_PTR to be passed to sg_init_one(), which with
    CONFIG_DEBUG_SG=y triggers the 'BUG_ON(!virt_addr_valid(buf));' in
    sg_set_buf().
    
    Fix this by making crypto_dh_decode_key() reject 0 for 'p'.  p=0 makes
    no sense for any DH implementation because 'p' is supposed to be a prime
    number.  Moreover, 'mod 0' is not mathematically defined.
    
    Bug report:
    
        kernel BUG at ./include/linux/scatterlist.h:140!
        invalid opcode: 0000 [#1] SMP KASAN
        CPU: 0 PID: 27112 Comm: syz-executor2 Not tainted 4.14.0-rc7-00010-gf5dbb5d0ce32-dirty #7
        Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.10.3-20171021_125229-anatol 04/01/2014
        task: ffff88006caac0c0 task.stack: ffff88006c7c8000
        RIP: 0010:sg_set_buf include/linux/scatterlist.h:140 [inline]
        RIP: 0010:sg_init_one+0x1b3/0x240 lib/scatterlist.c:156
        RSP: 0018:ffff88006c7cfb08 EFLAGS: 00010216
        RAX: 0000000000010000 RBX: ffff88006c7cfe30 RCX: 00000000000064ee
        RDX: ffffffff81cf64c3 RSI: ffffc90000d72000 RDI: ffffffff92e937e0
        RBP: ffff88006c7cfb30 R08: ffffed000d8f9fab R09: ffff88006c7cfd30
        R10: 0000000000000005 R11: ffffed000d8f9faa R12: ffff88006c7cfd30
        R13: 0000000000000000 R14: 0000000000000010 R15: ffff88006c7cfc50
        FS:  00007fce190fa700(0000) GS:ffff88003ea00000(0000) knlGS:0000000000000000
        CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
        CR2: 00007fffc6b33db8 CR3: 000000003cf64000 CR4: 00000000000006f0
        Call Trace:
         __keyctl_dh_compute+0xa95/0x19b0 security/keys/dh.c:360
         keyctl_dh_compute+0xac/0x100 security/keys/dh.c:434
         SYSC_keyctl security/keys/keyctl.c:1745 [inline]
         SyS_keyctl+0x72/0x2c0 security/keys/keyctl.c:1641
         entry_SYSCALL_64_fastpath+0x1f/0xbe
        RIP: 0033:0x4585c9
        RSP: 002b:00007fce190f9bd8 EFLAGS: 00000216 ORIG_RAX: 00000000000000fa
        RAX: ffffffffffffffda RBX: 0000000000738020 RCX: 00000000004585c9
        RDX: 000000002000d000 RSI: 0000000020000ff4 RDI: 0000000000000017
        RBP: 0000000000000046 R08: 0000000020008000 R09: 0000000000000000
        R10: 0000000000000000 R11: 0000000000000216 R12: 00007fff6e610cde
        R13: 00007fff6e610cdf R14: 00007fce190fa700 R15: 0000000000000000
        Code: 03 0f b6 14 02 48 89 f8 83 e0 07 83 c0 03 38 d0 7c 04 84 d2 75 33 5b 45 89 6c 24 14 41 5c 41 5d 41 5e 41 5f 5d c3 e8 fd 8f 68 ff <0f> 0b e8 f6 8f 68 ff 0f 0b e8 ef 8f 68 ff 0f 0b e8 e8 8f 68 ff 20
        RIP: sg_set_buf include/linux/scatterlist.h:140 [inline] RSP: ffff88006c7cfb08
        RIP: sg_init_one+0x1b3/0x240 lib/scatterlist.c:156 RSP: ffff88006c7cfb08
    
    Fixes: 802c7f1c84e4 ("crypto: dh - Add DH software implementation")
    Reviewed-by: Tudor Ambarus <tudor.ambarus@microchip.com>
    Signed-off-by: Eric Biggers <ebiggers@google.com>
    Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 81eabe0af17631acf193c84ec785ca92fd98ad08
Author: Eric Biggers <ebiggers@google.com>
Date:   Sun Nov 5 18:30:44 2017 -0800

    crypto: dh - Fix double free of ctx->p
    
    commit 12d41a023efb01b846457ccdbbcbe2b65a87d530 upstream.
    
    When setting the secret with the software Diffie-Hellman implementation,
    if allocating 'g' failed (e.g. if it was longer than
    MAX_EXTERN_MPI_BITS), then 'p' was freed twice: once immediately, and
    once later when the crypto_kpp tfm was destroyed.
    
    Fix it by using dh_free_ctx() (renamed to dh_clear_ctx()) in the error
    paths, as that correctly sets the pointers to NULL.
    
    KASAN report:
    
        MPI: mpi too large (32760 bits)
        ==================================================================
        BUG: KASAN: use-after-free in mpi_free+0x131/0x170
        Read of size 4 at addr ffff88006c7cdf90 by task reproduce_doubl/367
    
        CPU: 1 PID: 367 Comm: reproduce_doubl Not tainted 4.14.0-rc7-00040-g05298abde6fe #7
        Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS Bochs 01/01/2011
        Call Trace:
         dump_stack+0xb3/0x10b
         ? mpi_free+0x131/0x170
         print_address_description+0x79/0x2a0
         ? mpi_free+0x131/0x170
         kasan_report+0x236/0x340
         ? akcipher_register_instance+0x90/0x90
         __asan_report_load4_noabort+0x14/0x20
         mpi_free+0x131/0x170
         ? akcipher_register_instance+0x90/0x90
         dh_exit_tfm+0x3d/0x140
         crypto_kpp_exit_tfm+0x52/0x70
         crypto_destroy_tfm+0xb3/0x250
         __keyctl_dh_compute+0x640/0xe90
         ? kasan_slab_free+0x12f/0x180
         ? dh_data_from_key+0x240/0x240
         ? key_create_or_update+0x1ee/0xb20
         ? key_instantiate_and_link+0x440/0x440
         ? lock_contended+0xee0/0xee0
         ? kfree+0xcf/0x210
         ? SyS_add_key+0x268/0x340
         keyctl_dh_compute+0xb3/0xf1
         ? __keyctl_dh_compute+0xe90/0xe90
         ? SyS_add_key+0x26d/0x340
         ? entry_SYSCALL_64_fastpath+0x5/0xbe
         ? trace_hardirqs_on_caller+0x3f4/0x560
         SyS_keyctl+0x72/0x2c0
         entry_SYSCALL_64_fastpath+0x1f/0xbe
        RIP: 0033:0x43ccf9
        RSP: 002b:00007ffeeec96158 EFLAGS: 00000246 ORIG_RAX: 00000000000000fa
        RAX: ffffffffffffffda RBX: 000000000248b9b9 RCX: 000000000043ccf9
        RDX: 00007ffeeec96170 RSI: 00007ffeeec96160 RDI: 0000000000000017
        RBP: 0000000000000046 R08: 0000000000000000 R09: 0248b9b9143dc936
        R10: 0000000000001000 R11: 0000000000000246 R12: 0000000000000000
        R13: 0000000000409670 R14: 0000000000409700 R15: 0000000000000000
    
        Allocated by task 367:
         save_stack_trace+0x16/0x20
         kasan_kmalloc+0xeb/0x180
         kmem_cache_alloc_trace+0x114/0x300
         mpi_alloc+0x4b/0x230
         mpi_read_raw_data+0xbe/0x360
         dh_set_secret+0x1dc/0x460
         __keyctl_dh_compute+0x623/0xe90
         keyctl_dh_compute+0xb3/0xf1
         SyS_keyctl+0x72/0x2c0
         entry_SYSCALL_64_fastpath+0x1f/0xbe
    
        Freed by task 367:
         save_stack_trace+0x16/0x20
         kasan_slab_free+0xab/0x180
         kfree+0xb5/0x210
         mpi_free+0xcb/0x170
         dh_set_secret+0x2d7/0x460
         __keyctl_dh_compute+0x623/0xe90
         keyctl_dh_compute+0xb3/0xf1
         SyS_keyctl+0x72/0x2c0
         entry_SYSCALL_64_fastpath+0x1f/0xbe
    
    Fixes: 802c7f1c84e4 ("crypto: dh - Add DH software implementation")
    Signed-off-by: Eric Biggers <ebiggers@google.com>
    Reviewed-by: Tudor Ambarus <tudor.ambarus@microchip.com>
    Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 1cad93dbb3f1d2db13bc10c448624381f5e4a1cb
Author: Leif Liddy <leif.linux@gmail.com>
Date:   Sat Jul 8 20:55:32 2017 +0200

    Bluetooth: btusb: fix QCA Rome suspend/resume
    
    commit fd865802c66bc451dc515ed89360f84376ce1a56 upstream.
    
    There's been numerous reported instances where BTUSB_QCA_ROME
    bluetooth controllers stop functioning upon resume from suspend. These
    devices seem to be losing power during suspend. Patch will detect a status
    change on resume and perform a reset.
    
    Signed-off-by: Leif Liddy <leif.linux@gmail.com>
    Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
    Cc: Kai Heng Feng <kai.heng.feng@canonical.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 02a260a31257c653af31570faf4e07ad3dbe81f9
Author: Andrey Konovalov <andreyknvl@google.com>
Date:   Thu Nov 2 10:38:21 2017 -0400

    media: dib0700: fix invalid dvb_detach argument
    
    commit eb0c19942288569e0ae492476534d5a485fb8ab4 upstream.
    
    dvb_detach(arg) calls symbol_put_addr(arg), where arg should be a pointer
    to a function. Right now a pointer to state->dib7000p_ops is passed to
    dvb_detach(), which causes a BUG() in symbol_put_addr() as discovered by
    syzkaller. Pass state->dib7000p_ops.set_wbd_ref instead.
    
    ------------[ cut here ]------------
    kernel BUG at kernel/module.c:1081!
    invalid opcode: 0000 [#1] PREEMPT SMP KASAN
    Modules linked in:
    CPU: 1 PID: 1151 Comm: kworker/1:1 Tainted: G        W
    4.14.0-rc1-42251-gebb2c2437d80 #224
    Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS Bochs 01/01/2011
    Workqueue: usb_hub_wq hub_event
    task: ffff88006a336300 task.stack: ffff88006a7c8000
    RIP: 0010:symbol_put_addr+0x54/0x60 kernel/module.c:1083
    RSP: 0018:ffff88006a7ce210 EFLAGS: 00010246
    RAX: 0000000000000000 RBX: ffff880062a8d190 RCX: 0000000000000000
    RDX: dffffc0000000020 RSI: ffffffff85876d60 RDI: ffff880062a8d190
    RBP: ffff88006a7ce218 R08: 1ffff1000d4f9c12 R09: 1ffff1000d4f9ae4
    R10: 1ffff1000d4f9bed R11: 0000000000000000 R12: ffff880062a8d180
    R13: 00000000ffffffed R14: ffff880062a8d190 R15: ffff88006947c000
    FS:  0000000000000000(0000) GS:ffff88006c900000(0000) knlGS:0000000000000000
    CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
    CR2: 00007f6416532000 CR3: 00000000632f5000 CR4: 00000000000006e0
    Call Trace:
     stk7070p_frontend_attach+0x515/0x610
    drivers/media/usb/dvb-usb/dib0700_devices.c:1013
     dvb_usb_adapter_frontend_init+0x32b/0x660
    drivers/media/usb/dvb-usb/dvb-usb-dvb.c:286
     dvb_usb_adapter_init drivers/media/usb/dvb-usb/dvb-usb-init.c:86
     dvb_usb_init drivers/media/usb/dvb-usb/dvb-usb-init.c:162
     dvb_usb_device_init+0xf70/0x17f0 drivers/media/usb/dvb-usb/dvb-usb-init.c:277
     dib0700_probe+0x171/0x5a0 drivers/media/usb/dvb-usb/dib0700_core.c:886
     usb_probe_interface+0x35d/0x8e0 drivers/usb/core/driver.c:361
     really_probe drivers/base/dd.c:413
     driver_probe_device+0x610/0xa00 drivers/base/dd.c:557
     __device_attach_driver+0x230/0x290 drivers/base/dd.c:653
     bus_for_each_drv+0x161/0x210 drivers/base/bus.c:463
     __device_attach+0x26e/0x3d0 drivers/base/dd.c:710
     device_initial_probe+0x1f/0x30 drivers/base/dd.c:757
     bus_probe_device+0x1eb/0x290 drivers/base/bus.c:523
     device_add+0xd0b/0x1660 drivers/base/core.c:1835
     usb_set_configuration+0x104e/0x1870 drivers/usb/core/message.c:1932
     generic_probe+0x73/0xe0 drivers/usb/core/generic.c:174
     usb_probe_device+0xaf/0xe0 drivers/usb/core/driver.c:266
     really_probe drivers/base/dd.c:413
     driver_probe_device+0x610/0xa00 drivers/base/dd.c:557
     __device_attach_driver+0x230/0x290 drivers/base/dd.c:653
     bus_for_each_drv+0x161/0x210 drivers/base/bus.c:463
     __device_attach+0x26e/0x3d0 drivers/base/dd.c:710
     device_initial_probe+0x1f/0x30 drivers/base/dd.c:757
     bus_probe_device+0x1eb/0x290 drivers/base/bus.c:523
     device_add+0xd0b/0x1660 drivers/base/core.c:1835
     usb_new_device+0x7b8/0x1020 drivers/usb/core/hub.c:2457
     hub_port_connect drivers/usb/core/hub.c:4903
     hub_port_connect_change drivers/usb/core/hub.c:5009
     port_event drivers/usb/core/hub.c:5115
     hub_event+0x194d/0x3740 drivers/usb/core/hub.c:5195
     process_one_work+0xc7f/0x1db0 kernel/workqueue.c:2119
     worker_thread+0x221/0x1850 kernel/workqueue.c:2253
     kthread+0x3a1/0x470 kernel/kthread.c:231
     ret_from_fork+0x2a/0x40 arch/x86/entry/entry_64.S:431
    Code: ff ff 48 85 c0 74 24 48 89 c7 e8 48 ea ff ff bf 01 00 00 00 e8
    de 20 e3 ff 65 8b 05 b7 2f c2 7e 85 c0 75 c9 e8 f9 0b c1 ff eb c2 <0f>
    0b 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 44 00 00 48 b8 00 00
    RIP: symbol_put_addr+0x54/0x60 RSP: ffff88006a7ce210
    ---[ end trace b75b357739e7e116 ]---
    
    Signed-off-by: Andrey Konovalov <andreyknvl@google.com>
    Cc: Ben Hutchings <ben.hutchings@codethink.co.uk>
    Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 442cc6c4c54fdeb402a425b37265a09c5d393af3
Author: Arvind Yadav <arvind.yadav.cs@gmail.com>
Date:   Mon Oct 9 20:14:48 2017 +0200

    media: imon: Fix null-ptr-deref in imon_probe
    
    commit 58fd55e838276a0c13d1dc7c387f90f25063cbf3 upstream.
    
    It seems that the return value of usb_ifnum_to_if() can be NULL and
    needs to be checked.
    
    Signed-off-by: Arvind Yadav <arvind.yadav.cs@gmail.com>
    Tested-by: Andrey Konovalov <andreyknvl@google.com>
    Signed-off-by: Sean Young <sean@mess.org>
    Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
    Cc: Ben Hutchings <ben.hutchings@codethink.co.uk>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>