--- /dev/null
+From 240630e61870e62e39a97225048f9945848fa5f5 Mon Sep 17 00:00:00 2001
+From: Hans de Goede <hdegoede@redhat.com>
+Date: Sun, 1 Jul 2018 12:15:46 +0200
+Subject: ahci: Disable LPM on Lenovo 50 series laptops with a too old BIOS
+
+From: Hans de Goede <hdegoede@redhat.com>
+
+commit 240630e61870e62e39a97225048f9945848fa5f5 upstream.
+
+There have been several reports of LPM related hard freezes about once
+a day on multiple Lenovo 50 series models. Strange enough these reports
+where not disk model specific as LPM issues usually are and some users
+with the exact same disk + laptop where seeing them while other users
+where not seeing these issues.
+
+It turns out that enabling LPM triggers a firmware bug somewhere, which
+has been fixed in later BIOS versions.
+
+This commit adds a new ahci_broken_lpm() function and a new ATA_FLAG_NO_LPM
+for dealing with this.
+
+The ahci_broken_lpm() function contains DMI match info for the 4 models
+which are known to be affected by this and the DMI BIOS date field for
+known good BIOS versions. If the BIOS date is older then the one in the
+table LPM will be disabled and a warning will be printed.
+
+Note the BIOS dates are for known good versions, some older versions may
+work too, but we don't know for sure, the table is using dates from BIOS
+versions for which users have confirmed that upgrading to that version
+makes the problem go away.
+
+Unfortunately I've been unable to get hold of the reporter who reported
+that BIOS version 2.35 fixed the problems on the W541 for him. I've been
+able to verify the DMI_SYS_VENDOR and DMI_PRODUCT_VERSION from an older
+dmidecode, but I don't know the exact BIOS date as reported in the DMI.
+Lenovo keeps a changelog with dates in their release notes, but the
+dates there are the release dates not the build dates which are in DMI.
+So I've chosen to set the date to which we compare to one day past the
+release date of the 2.34 BIOS. I plan to fix this with a follow up
+commit once I've the necessary info.
+
+Cc: stable@vger.kernel.org
+Signed-off-by: Hans de Goede <hdegoede@redhat.com>
+Signed-off-by: Tejun Heo <tj@kernel.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/ata/ahci.c | 59 ++++++++++++++++++++++++++++++++++++++++++++++
+ drivers/ata/libata-core.c | 3 ++
+ include/linux/libata.h | 1
+ 3 files changed, 63 insertions(+)
+
+--- a/drivers/ata/ahci.c
++++ b/drivers/ata/ahci.c
+@@ -1229,6 +1229,59 @@ static bool ahci_broken_suspend(struct p
+ return strcmp(buf, dmi->driver_data) < 0;
+ }
+
++static bool ahci_broken_lpm(struct pci_dev *pdev)
++{
++ static const struct dmi_system_id sysids[] = {
++ /* Various Lenovo 50 series have LPM issues with older BIOSen */
++ {
++ .matches = {
++ DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
++ DMI_MATCH(DMI_PRODUCT_VERSION, "ThinkPad X250"),
++ },
++ .driver_data = "20180406", /* 1.31 */
++ },
++ {
++ .matches = {
++ DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
++ DMI_MATCH(DMI_PRODUCT_VERSION, "ThinkPad L450"),
++ },
++ .driver_data = "20180420", /* 1.28 */
++ },
++ {
++ .matches = {
++ DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
++ DMI_MATCH(DMI_PRODUCT_VERSION, "ThinkPad T450s"),
++ },
++ .driver_data = "20180315", /* 1.33 */
++ },
++ {
++ .matches = {
++ DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
++ DMI_MATCH(DMI_PRODUCT_VERSION, "ThinkPad W541"),
++ },
++ /*
++ * Note date based on release notes, 2.35 has been
++ * reported to be good, but I've been unable to get
++ * a hold of the reporter to get the DMI BIOS date.
++ * TODO: fix this.
++ */
++ .driver_data = "20180310", /* 2.35 */
++ },
++ { } /* terminate list */
++ };
++ const struct dmi_system_id *dmi = dmi_first_match(sysids);
++ int year, month, date;
++ char buf[9];
++
++ if (!dmi)
++ return false;
++
++ dmi_get_date(DMI_BIOS_DATE, &year, &month, &date);
++ snprintf(buf, sizeof(buf), "%04d%02d%02d", year, month, date);
++
++ return strcmp(buf, dmi->driver_data) < 0;
++}
++
+ static bool ahci_broken_online(struct pci_dev *pdev)
+ {
+ #define ENCODE_BUSDEVFN(bus, slot, func) \
+@@ -1588,6 +1641,12 @@ static int ahci_init_one(struct pci_dev
+ "quirky BIOS, skipping spindown on poweroff\n");
+ }
+
++ if (ahci_broken_lpm(pdev)) {
++ pi.flags |= ATA_FLAG_NO_LPM;
++ dev_warn(&pdev->dev,
++ "BIOS update required for Link Power Management support\n");
++ }
++
+ if (ahci_broken_suspend(pdev)) {
+ hpriv->flags |= AHCI_HFLAG_NO_SUSPEND;
+ dev_warn(&pdev->dev,
+--- a/drivers/ata/libata-core.c
++++ b/drivers/ata/libata-core.c
+@@ -2209,6 +2209,9 @@ int ata_dev_configure(struct ata_device
+ (id[ATA_ID_SATA_CAPABILITY] & 0xe) == 0x2)
+ dev->horkage |= ATA_HORKAGE_NOLPM;
+
++ if (ap->flags & ATA_FLAG_NO_LPM)
++ dev->horkage |= ATA_HORKAGE_NOLPM;
++
+ if (dev->horkage & ATA_HORKAGE_NOLPM) {
+ ata_dev_warn(dev, "LPM support broken, forcing max_power\n");
+ dev->link->ap->target_lpm_policy = ATA_LPM_MAX_POWER;
+--- a/include/linux/libata.h
++++ b/include/linux/libata.h
+@@ -210,6 +210,7 @@ enum {
+ ATA_FLAG_SLAVE_POSS = (1 << 0), /* host supports slave dev */
+ /* (doesn't imply presence) */
+ ATA_FLAG_SATA = (1 << 1),
++ ATA_FLAG_NO_LPM = (1 << 2), /* host not happy with LPM */
+ ATA_FLAG_NO_LOG_PAGE = (1 << 5), /* do not issue log page read */
+ ATA_FLAG_NO_ATAPI = (1 << 6), /* No ATAPI support */
+ ATA_FLAG_PIO_DMA = (1 << 7), /* PIO cmds via DMA */
--- /dev/null
+From a0341fc1981a950c1e902ab901e98f60e0e243f3 Mon Sep 17 00:00:00 2001
+From: Jann Horn <jannh@google.com>
+Date: Sat, 7 Jul 2018 04:16:33 +0200
+Subject: ibmasm: don't write out of bounds in read handler
+
+From: Jann Horn <jannh@google.com>
+
+commit a0341fc1981a950c1e902ab901e98f60e0e243f3 upstream.
+
+This read handler had a lot of custom logic and wrote outside the bounds of
+the provided buffer. This could lead to kernel and userspace memory
+corruption. Just use simple_read_from_buffer() with a stack buffer.
+
+Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
+Cc: stable@vger.kernel.org
+Signed-off-by: Jann Horn <jannh@google.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/misc/ibmasm/ibmasmfs.c | 27 +++------------------------
+ 1 file changed, 3 insertions(+), 24 deletions(-)
+
+--- a/drivers/misc/ibmasm/ibmasmfs.c
++++ b/drivers/misc/ibmasm/ibmasmfs.c
+@@ -507,35 +507,14 @@ static int remote_settings_file_close(st
+ static ssize_t remote_settings_file_read(struct file *file, char __user *buf, size_t count, loff_t *offset)
+ {
+ void __iomem *address = (void __iomem *)file->private_data;
+- unsigned char *page;
+- int retval;
+ int len = 0;
+ unsigned int value;
+-
+- if (*offset < 0)
+- return -EINVAL;
+- if (count == 0 || count > 1024)
+- return 0;
+- if (*offset != 0)
+- return 0;
+-
+- page = (unsigned char *)__get_free_page(GFP_KERNEL);
+- if (!page)
+- return -ENOMEM;
++ char lbuf[20];
+
+ value = readl(address);
+- len = sprintf(page, "%d\n", value);
+-
+- if (copy_to_user(buf, page, len)) {
+- retval = -EFAULT;
+- goto exit;
+- }
+- *offset += len;
+- retval = len;
++ len = snprintf(lbuf, sizeof(lbuf), "%d\n", value);
+
+-exit:
+- free_page((unsigned long)page);
+- return retval;
++ return simple_read_from_buffer(buf, count, offset, lbuf, len);
+ }
+
+ static ssize_t remote_settings_file_write(struct file *file, const char __user *ubuff, size_t count, loff_t *offset)
--- /dev/null
+From 523402fa9101090c91d2033b7ebdfdcf65880488 Mon Sep 17 00:00:00 2001
+From: Paul Burton <paul.burton@mips.com>
+Date: Thu, 5 Jul 2018 14:37:52 -0700
+Subject: MIPS: Fix ioremap() RAM check
+
+From: Paul Burton <paul.burton@mips.com>
+
+commit 523402fa9101090c91d2033b7ebdfdcf65880488 upstream.
+
+We currently attempt to check whether a physical address range provided
+to __ioremap() may be in use by the page allocator by examining the
+value of PageReserved for each page in the region - lowmem pages not
+marked reserved are presumed to be in use by the page allocator, and
+requests to ioremap them fail.
+
+The way we check this has been broken since commit 92923ca3aace ("mm:
+meminit: only set page reserved in the memblock region"), because
+memblock will typically not have any knowledge of non-RAM pages and
+therefore those pages will not have the PageReserved flag set. Thus when
+we attempt to ioremap a region outside of RAM we incorrectly fail
+believing that the region is RAM that may be in use.
+
+In most cases ioremap() on MIPS will take a fast-path to use the
+unmapped kseg1 or xkphys virtual address spaces and never hit this path,
+so the only way to hit it is for a MIPS32 system to attempt to ioremap()
+an address range in lowmem with flags other than _CACHE_UNCACHED.
+Perhaps the most straightforward way to do this is using
+ioremap_uncached_accelerated(), which is how the problem was discovered.
+
+Fix this by making use of walk_system_ram_range() to test the address
+range provided to __ioremap() against only RAM pages, rather than all
+lowmem pages. This means that if we have a lowmem I/O region, which is
+very common for MIPS systems, we're free to ioremap() address ranges
+within it. A nice bonus is that the test is no longer limited to lowmem.
+
+The approach here matches the way x86 performed the same test after
+commit c81c8a1eeede ("x86, ioremap: Speed up check for RAM pages") until
+x86 moved towards a slightly more complicated check using walk_mem_res()
+for unrelated reasons with commit 0e4c12b45aa8 ("x86/mm, resource: Use
+PAGE_KERNEL protection for ioremap of memory pages").
+
+Signed-off-by: Paul Burton <paul.burton@mips.com>
+Reported-by: Serge Semin <fancer.lancer@gmail.com>
+Tested-by: Serge Semin <fancer.lancer@gmail.com>
+Fixes: 92923ca3aace ("mm: meminit: only set page reserved in the memblock region")
+Cc: James Hogan <jhogan@kernel.org>
+Cc: Ralf Baechle <ralf@linux-mips.org>
+Cc: linux-mips@linux-mips.org
+Cc: stable@vger.kernel.org # v4.2+
+Patchwork: https://patchwork.linux-mips.org/patch/19786/
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ arch/mips/mm/ioremap.c | 37 +++++++++++++++++++++++++------------
+ 1 file changed, 25 insertions(+), 12 deletions(-)
+
+--- a/arch/mips/mm/ioremap.c
++++ b/arch/mips/mm/ioremap.c
+@@ -9,6 +9,7 @@
+ #include <linux/module.h>
+ #include <asm/addrspace.h>
+ #include <asm/byteorder.h>
++#include <linux/ioport.h>
+ #include <linux/sched.h>
+ #include <linux/slab.h>
+ #include <linux/vmalloc.h>
+@@ -97,6 +98,20 @@ static int remap_area_pages(unsigned lon
+ return error;
+ }
+
++static int __ioremap_check_ram(unsigned long start_pfn, unsigned long nr_pages,
++ void *arg)
++{
++ unsigned long i;
++
++ for (i = 0; i < nr_pages; i++) {
++ if (pfn_valid(start_pfn + i) &&
++ !PageReserved(pfn_to_page(start_pfn + i)))
++ return 1;
++ }
++
++ return 0;
++}
++
+ /*
+ * Generic mapping function (not visible outside):
+ */
+@@ -115,8 +130,8 @@ static int remap_area_pages(unsigned lon
+
+ void __iomem * __ioremap(phys_addr_t phys_addr, phys_addr_t size, unsigned long flags)
+ {
++ unsigned long offset, pfn, last_pfn;
+ struct vm_struct * area;
+- unsigned long offset;
+ phys_addr_t last_addr;
+ void * addr;
+
+@@ -136,18 +151,16 @@ void __iomem * __ioremap(phys_addr_t phy
+ return (void __iomem *) CKSEG1ADDR(phys_addr);
+
+ /*
+- * Don't allow anybody to remap normal RAM that we're using..
++ * Don't allow anybody to remap RAM that may be allocated by the page
++ * allocator, since that could lead to races & data clobbering.
+ */
+- if (phys_addr < virt_to_phys(high_memory)) {
+- char *t_addr, *t_end;
+- struct page *page;
+-
+- t_addr = __va(phys_addr);
+- t_end = t_addr + (size - 1);
+-
+- for(page = virt_to_page(t_addr); page <= virt_to_page(t_end); page++)
+- if(!PageReserved(page))
+- return NULL;
++ pfn = PFN_DOWN(phys_addr);
++ last_pfn = PFN_DOWN(last_addr);
++ if (walk_system_ram_range(pfn, last_pfn - pfn + 1, NULL,
++ __ioremap_check_ram) == 1) {
++ WARN_ONCE(1, "ioremap on RAM at %pa - %pa\n",
++ &phys_addr, &last_addr);
++ return NULL;
+ }
+
+ /*
--- /dev/null
+mips-fix-ioremap-ram-check.patch
+ibmasm-don-t-write-out-of-bounds-in-read-handler.patch
+vmw_balloon-fix-inflation-with-batching.patch
+ahci-disable-lpm-on-lenovo-50-series-laptops-with-a-too-old-bios.patch
+usb-serial-ch341-fix-type-promotion-bug-in-ch341_control_in.patch
+usb-serial-cp210x-add-another-usb-id-for-qivicon-zigbee-stick.patch
+usb-serial-keyspan_pda-fix-modem-status-error-handling.patch
+usb-yurex-fix-out-of-bounds-uaccess-in-read-handler.patch
+usb-serial-mos7840-fix-status-register-error-handling.patch
+usb-quirks-add-delay-quirks-for-corsair-strafe.patch
+xhci-xhci-mem-off-by-one-in-xhci_stream_id_to_ring.patch
--- /dev/null
+From bba57eddadda936c94b5dccf73787cb9e159d0a5 Mon Sep 17 00:00:00 2001
+From: Nico Sneck <snecknico@gmail.com>
+Date: Mon, 2 Jul 2018 19:26:07 +0300
+Subject: usb: quirks: add delay quirks for Corsair Strafe
+
+From: Nico Sneck <snecknico@gmail.com>
+
+commit bba57eddadda936c94b5dccf73787cb9e159d0a5 upstream.
+
+Corsair Strafe appears to suffer from the same issues
+as the Corsair Strafe RGB.
+Apply the same quirks (control message delay and init delay)
+that the RGB version has to 1b1c:1b15.
+
+With these quirks in place the keyboard works correctly upon
+booting the system, and no longer requires reattaching the device.
+
+Signed-off-by: Nico Sneck <snecknico@gmail.com>
+Cc: stable <stable@vger.kernel.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/usb/core/quirks.c | 4 ++++
+ 1 file changed, 4 insertions(+)
+
+--- a/drivers/usb/core/quirks.c
++++ b/drivers/usb/core/quirks.c
+@@ -231,6 +231,10 @@ static const struct usb_device_id usb_qu
+ /* Corsair K70 RGB */
+ { USB_DEVICE(0x1b1c, 0x1b13), .driver_info = USB_QUIRK_DELAY_INIT },
+
++ /* Corsair Strafe */
++ { USB_DEVICE(0x1b1c, 0x1b15), .driver_info = USB_QUIRK_DELAY_INIT |
++ USB_QUIRK_DELAY_CTRL_MSG },
++
+ /* Corsair Strafe RGB */
+ { USB_DEVICE(0x1b1c, 0x1b20), .driver_info = USB_QUIRK_DELAY_INIT |
+ USB_QUIRK_DELAY_CTRL_MSG },
--- /dev/null
+From e33eab9ded328ccc14308afa51b5be7cbe78d30b Mon Sep 17 00:00:00 2001
+From: Dan Carpenter <dan.carpenter@oracle.com>
+Date: Wed, 4 Jul 2018 12:29:38 +0300
+Subject: USB: serial: ch341: fix type promotion bug in ch341_control_in()
+
+From: Dan Carpenter <dan.carpenter@oracle.com>
+
+commit e33eab9ded328ccc14308afa51b5be7cbe78d30b upstream.
+
+The "r" variable is an int and "bufsize" is an unsigned int so the
+comparison is type promoted to unsigned. If usb_control_msg() returns a
+negative that is treated as a high positive value and the error handling
+doesn't work.
+
+Fixes: 2d5a9c72d0c4 ("USB: serial: ch341: fix control-message error handling")
+Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
+Cc: stable <stable@vger.kernel.org>
+Signed-off-by: Johan Hovold <johan@kernel.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/usb/serial/ch341.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+--- a/drivers/usb/serial/ch341.c
++++ b/drivers/usb/serial/ch341.c
+@@ -118,7 +118,7 @@ static int ch341_control_in(struct usb_d
+ r = usb_control_msg(dev, usb_rcvctrlpipe(dev, 0), request,
+ USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_IN,
+ value, index, buf, bufsize, DEFAULT_TIMEOUT);
+- if (r < bufsize) {
++ if (r < (int)bufsize) {
+ if (r >= 0) {
+ dev_err(&dev->dev,
+ "short control message received (%d < %u)\n",
--- /dev/null
+From 367b160fe4717c14a2a978b6f9ffb75a7762d3ed Mon Sep 17 00:00:00 2001
+From: Olli Salonen <olli.salonen@iki.fi>
+Date: Wed, 4 Jul 2018 14:07:42 +0300
+Subject: USB: serial: cp210x: add another USB ID for Qivicon ZigBee stick
+
+From: Olli Salonen <olli.salonen@iki.fi>
+
+commit 367b160fe4717c14a2a978b6f9ffb75a7762d3ed upstream.
+
+There are two versions of the Qivicon Zigbee stick in circulation. This
+adds the second USB ID to the cp210x driver.
+
+Signed-off-by: Olli Salonen <olli.salonen@iki.fi>
+Cc: stable <stable@vger.kernel.org>
+Signed-off-by: Johan Hovold <johan@kernel.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/usb/serial/cp210x.c | 1 +
+ 1 file changed, 1 insertion(+)
+
+--- a/drivers/usb/serial/cp210x.c
++++ b/drivers/usb/serial/cp210x.c
+@@ -145,6 +145,7 @@ static const struct usb_device_id id_tab
+ { USB_DEVICE(0x10C4, 0x8977) }, /* CEL MeshWorks DevKit Device */
+ { USB_DEVICE(0x10C4, 0x8998) }, /* KCF Technologies PRN */
+ { USB_DEVICE(0x10C4, 0x89A4) }, /* CESINEL FTBC Flexible Thyristor Bridge Controller */
++ { USB_DEVICE(0x10C4, 0x89FB) }, /* Qivicon ZigBee USB Radio Stick */
+ { USB_DEVICE(0x10C4, 0x8A2A) }, /* HubZ dual ZigBee and Z-Wave dongle */
+ { USB_DEVICE(0x10C4, 0x8A5E) }, /* CEL EM3588 ZigBee USB Stick Long Range */
+ { USB_DEVICE(0x10C4, 0x8B34) }, /* Qivicon ZigBee USB Radio Stick */
--- /dev/null
+From 01b3cdfca263a17554f7b249d20a247b2a751521 Mon Sep 17 00:00:00 2001
+From: Johan Hovold <johan@kernel.org>
+Date: Wed, 4 Jul 2018 17:02:16 +0200
+Subject: USB: serial: keyspan_pda: fix modem-status error handling
+
+From: Johan Hovold <johan@kernel.org>
+
+commit 01b3cdfca263a17554f7b249d20a247b2a751521 upstream.
+
+Fix broken modem-status error handling which could lead to bits of slab
+data leaking to user space.
+
+Fixes: 3b36a8fd6777 ("usb: fix uninitialized variable warning in keyspan_pda")
+Cc: stable <stable@vger.kernel.org> # 2.6.27
+Signed-off-by: Johan Hovold <johan@kernel.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/usb/serial/keyspan_pda.c | 4 +++-
+ 1 file changed, 3 insertions(+), 1 deletion(-)
+
+--- a/drivers/usb/serial/keyspan_pda.c
++++ b/drivers/usb/serial/keyspan_pda.c
+@@ -373,8 +373,10 @@ static int keyspan_pda_get_modem_info(st
+ 3, /* get pins */
+ USB_TYPE_VENDOR|USB_RECIP_INTERFACE|USB_DIR_IN,
+ 0, 0, data, 1, 2000);
+- if (rc >= 0)
++ if (rc == 1)
+ *value = *data;
++ else if (rc >= 0)
++ rc = -EIO;
+
+ kfree(data);
+ return rc;
--- /dev/null
+From 794744abfffef8b1f3c0c8a4896177d6d13d653d Mon Sep 17 00:00:00 2001
+From: Johan Hovold <johan@kernel.org>
+Date: Wed, 4 Jul 2018 17:02:17 +0200
+Subject: USB: serial: mos7840: fix status-register error handling
+
+From: Johan Hovold <johan@kernel.org>
+
+commit 794744abfffef8b1f3c0c8a4896177d6d13d653d upstream.
+
+Add missing transfer-length sanity check to the status-register
+completion handler to avoid leaking bits of uninitialised slab data to
+user space.
+
+Fixes: 3f5429746d91 ("USB: Moschip 7840 USB-Serial Driver")
+Cc: stable <stable@vger.kernel.org> # 2.6.19
+Signed-off-by: Johan Hovold <johan@kernel.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/usb/serial/mos7840.c | 3 +++
+ 1 file changed, 3 insertions(+)
+
+--- a/drivers/usb/serial/mos7840.c
++++ b/drivers/usb/serial/mos7840.c
+@@ -482,6 +482,9 @@ static void mos7840_control_callback(str
+ }
+
+ dev_dbg(dev, "%s urb buffer size is %d\n", __func__, urb->actual_length);
++ if (urb->actual_length < 1)
++ goto out;
++
+ dev_dbg(dev, "%s mos7840_port->MsrLsr is %d port %d\n", __func__,
+ mos7840_port->MsrLsr, mos7840_port->port_num);
+ data = urb->transfer_buffer;
--- /dev/null
+From f1e255d60ae66a9f672ff9a207ee6cd8e33d2679 Mon Sep 17 00:00:00 2001
+From: Jann Horn <jannh@google.com>
+Date: Fri, 6 Jul 2018 17:12:56 +0200
+Subject: USB: yurex: fix out-of-bounds uaccess in read handler
+
+From: Jann Horn <jannh@google.com>
+
+commit f1e255d60ae66a9f672ff9a207ee6cd8e33d2679 upstream.
+
+In general, accessing userspace memory beyond the length of the supplied
+buffer in VFS read/write handlers can lead to both kernel memory corruption
+(via kernel_read()/kernel_write(), which can e.g. be triggered via
+sys_splice()) and privilege escalation inside userspace.
+
+Fix it by using simple_read_from_buffer() instead of custom logic.
+
+Fixes: 6bc235a2e24a ("USB: add driver for Meywa-Denki & Kayac YUREX")
+Signed-off-by: Jann Horn <jannh@google.com>
+Cc: stable <stable@vger.kernel.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/usb/misc/yurex.c | 23 ++++++-----------------
+ 1 file changed, 6 insertions(+), 17 deletions(-)
+
+--- a/drivers/usb/misc/yurex.c
++++ b/drivers/usb/misc/yurex.c
+@@ -414,8 +414,7 @@ static ssize_t yurex_read(struct file *f
+ loff_t *ppos)
+ {
+ struct usb_yurex *dev;
+- int retval = 0;
+- int bytes_read = 0;
++ int len = 0;
+ char in_buffer[20];
+ unsigned long flags;
+
+@@ -423,26 +422,16 @@ static ssize_t yurex_read(struct file *f
+
+ mutex_lock(&dev->io_mutex);
+ if (!dev->interface) { /* already disconnected */
+- retval = -ENODEV;
+- goto exit;
++ mutex_unlock(&dev->io_mutex);
++ return -ENODEV;
+ }
+
+ spin_lock_irqsave(&dev->lock, flags);
+- bytes_read = snprintf(in_buffer, 20, "%lld\n", dev->bbu);
++ len = snprintf(in_buffer, 20, "%lld\n", dev->bbu);
+ spin_unlock_irqrestore(&dev->lock, flags);
+-
+- if (*ppos < bytes_read) {
+- if (copy_to_user(buffer, in_buffer + *ppos, bytes_read - *ppos))
+- retval = -EFAULT;
+- else {
+- retval = bytes_read - *ppos;
+- *ppos += bytes_read;
+- }
+- }
+-
+-exit:
+ mutex_unlock(&dev->io_mutex);
+- return retval;
++
++ return simple_read_from_buffer(buffer, count, ppos, in_buffer, len);
+ }
+
+ static ssize_t yurex_write(struct file *file, const char __user *user_buffer,
--- /dev/null
+From 90d72ce079791399ac255c75728f3c9e747b093d Mon Sep 17 00:00:00 2001
+From: Nadav Amit <namit@vmware.com>
+Date: Mon, 2 Jul 2018 19:27:13 -0700
+Subject: vmw_balloon: fix inflation with batching
+
+From: Nadav Amit <namit@vmware.com>
+
+commit 90d72ce079791399ac255c75728f3c9e747b093d upstream.
+
+Embarrassingly, the recent fix introduced worse problem than it solved,
+causing the balloon not to inflate. The VM informed the hypervisor that
+the pages for lock/unlock are sitting in the wrong address, as it used
+the page that is used the uninitialized page variable.
+
+Fixes: b23220fe054e9 ("vmw_balloon: fixing double free when batching mode is off")
+Cc: stable@vger.kernel.org
+Reviewed-by: Xavier Deguillard <xdeguillard@vmware.com>
+Signed-off-by: Nadav Amit <namit@vmware.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/misc/vmw_balloon.c | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+--- a/drivers/misc/vmw_balloon.c
++++ b/drivers/misc/vmw_balloon.c
+@@ -467,7 +467,7 @@ static int vmballoon_send_batched_lock(s
+ unsigned int num_pages, bool is_2m_pages, unsigned int *target)
+ {
+ unsigned long status;
+- unsigned long pfn = page_to_pfn(b->page);
++ unsigned long pfn = PHYS_PFN(virt_to_phys(b->batch_page));
+
+ STATS_INC(b->stats.lock[is_2m_pages]);
+
+@@ -515,7 +515,7 @@ static bool vmballoon_send_batched_unloc
+ unsigned int num_pages, bool is_2m_pages, unsigned int *target)
+ {
+ unsigned long status;
+- unsigned long pfn = page_to_pfn(b->page);
++ unsigned long pfn = PHYS_PFN(virt_to_phys(b->batch_page));
+
+ STATS_INC(b->stats.unlock[is_2m_pages]);
+
--- /dev/null
+From 313db3d6488bb03b61b99de9dbca061f1fd838e1 Mon Sep 17 00:00:00 2001
+From: Dan Carpenter <dan.carpenter@oracle.com>
+Date: Wed, 4 Jul 2018 12:48:53 +0300
+Subject: xhci: xhci-mem: off by one in xhci_stream_id_to_ring()
+
+From: Dan Carpenter <dan.carpenter@oracle.com>
+
+commit 313db3d6488bb03b61b99de9dbca061f1fd838e1 upstream.
+
+The > should be >= here so that we don't read one element beyond the end
+of the ep->stream_info->stream_rings[] array.
+
+Fixes: e9df17eb1408 ("USB: xhci: Correct assumptions about number of rings per endpoint.")
+Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
+Cc: stable <stable@vger.kernel.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/usb/host/xhci-mem.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+--- a/drivers/usb/host/xhci-mem.c
++++ b/drivers/usb/host/xhci-mem.c
+@@ -638,7 +638,7 @@ struct xhci_ring *xhci_stream_id_to_ring
+ if (!ep->stream_info)
+ return NULL;
+
+- if (stream_id > ep->stream_info->num_streams)
++ if (stream_id >= ep->stream_info->num_streams)
+ return NULL;
+ return ep->stream_info->stream_rings[stream_id];
+ }