From: Greg Kroah-Hartman Date: Mon, 16 Nov 2020 19:26:43 +0000 (+0100) Subject: 4.9-stable patches X-Git-Tag: v4.4.244~35 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=507055803404287cccfec3eb99a9e119c6024cf1;p=thirdparty%2Fkernel%2Fstable-queue.git 4.9-stable patches added patches: drm-gma500-fix-out-of-bounds-access-to-struct-drm_device.vblank.patch pinctrl-amd-fix-incorrect-way-to-disable-debounce-filter.patch pinctrl-amd-use-higher-precision-for-512-rtcclk.patch swiotlb-fix-x86-don-t-panic-if-can-not-alloc-buffer-for-swiotlb.patch --- diff --git a/queue-4.9/drm-gma500-fix-out-of-bounds-access-to-struct-drm_device.vblank.patch b/queue-4.9/drm-gma500-fix-out-of-bounds-access-to-struct-drm_device.vblank.patch new file mode 100644 index 00000000000..e2b51395fe1 --- /dev/null +++ b/queue-4.9/drm-gma500-fix-out-of-bounds-access-to-struct-drm_device.vblank.patch @@ -0,0 +1,120 @@ +From 06ad8d339524bf94b89859047822c31df6ace239 Mon Sep 17 00:00:00 2001 +From: Thomas Zimmermann +Date: Thu, 5 Nov 2020 20:02:56 +0100 +Subject: drm/gma500: Fix out-of-bounds access to struct drm_device.vblank[] + +From: Thomas Zimmermann + +commit 06ad8d339524bf94b89859047822c31df6ace239 upstream. + +The gma500 driver expects 3 pipelines in several it's IRQ functions. +Accessing struct drm_device.vblank[], this fails with devices that only +have 2 pipelines. An example KASAN report is shown below. + + [ 62.267688] ================================================================== + [ 62.268856] BUG: KASAN: slab-out-of-bounds in psb_irq_postinstall+0x250/0x3c0 [gma500_gfx] + [ 62.269450] Read of size 1 at addr ffff8880012bc6d0 by task systemd-udevd/285 + [ 62.269949] + [ 62.270192] CPU: 0 PID: 285 Comm: systemd-udevd Tainted: G E 5.10.0-rc1-1-default+ #572 + [ 62.270807] Hardware name: /DN2800MT, BIOS MTCDT10N.86A.0164.2012.1213.1024 12/13/2012 + [ 62.271366] Call Trace: + [ 62.271705] dump_stack+0xae/0xe5 + [ 62.272180] print_address_description.constprop.0+0x17/0xf0 + [ 62.272987] ? psb_irq_postinstall+0x250/0x3c0 [gma500_gfx] + [ 62.273474] __kasan_report.cold+0x20/0x38 + [ 62.273989] ? psb_irq_postinstall+0x250/0x3c0 [gma500_gfx] + [ 62.274460] kasan_report+0x3a/0x50 + [ 62.274891] psb_irq_postinstall+0x250/0x3c0 [gma500_gfx] + [ 62.275380] drm_irq_install+0x131/0x1f0 + <...> + [ 62.300751] Allocated by task 285: + [ 62.301223] kasan_save_stack+0x1b/0x40 + [ 62.301731] __kasan_kmalloc.constprop.0+0xbf/0xd0 + [ 62.302293] drmm_kmalloc+0x55/0x100 + [ 62.302773] drm_vblank_init+0x77/0x210 + +Resolve the issue by only handling vblank entries up to the number of +CRTCs. + +I'm adding a Fixes tag for reference, although the bug has been present +since the driver's initial commit. + +Signed-off-by: Thomas Zimmermann +Reviewed-by: Daniel Vetter +Fixes: 5c49fd3aa0ab ("gma500: Add the core DRM files and headers") +Cc: Alan Cox +Cc: Dave Airlie +Cc: Patrik Jakobsson +Cc: dri-devel@lists.freedesktop.org +Cc: stable@vger.kernel.org#v3.3+ +Link: https://patchwork.freedesktop.org/patch/msgid/20201105190256.3893-1-tzimmermann@suse.de +Signed-off-by: Greg Kroah-Hartman + +--- + drivers/gpu/drm/gma500/psb_irq.c | 34 ++++++++++++---------------------- + 1 file changed, 12 insertions(+), 22 deletions(-) + +--- a/drivers/gpu/drm/gma500/psb_irq.c ++++ b/drivers/gpu/drm/gma500/psb_irq.c +@@ -350,6 +350,7 @@ int psb_irq_postinstall(struct drm_devic + { + struct drm_psb_private *dev_priv = dev->dev_private; + unsigned long irqflags; ++ unsigned int i; + + spin_lock_irqsave(&dev_priv->irqmask_lock, irqflags); + +@@ -362,20 +363,12 @@ int psb_irq_postinstall(struct drm_devic + PSB_WVDC32(dev_priv->vdc_irq_mask, PSB_INT_ENABLE_R); + PSB_WVDC32(0xFFFFFFFF, PSB_HWSTAM); + +- if (dev->vblank[0].enabled) +- psb_enable_pipestat(dev_priv, 0, PIPE_VBLANK_INTERRUPT_ENABLE); +- else +- psb_disable_pipestat(dev_priv, 0, PIPE_VBLANK_INTERRUPT_ENABLE); +- +- if (dev->vblank[1].enabled) +- psb_enable_pipestat(dev_priv, 1, PIPE_VBLANK_INTERRUPT_ENABLE); +- else +- psb_disable_pipestat(dev_priv, 1, PIPE_VBLANK_INTERRUPT_ENABLE); +- +- if (dev->vblank[2].enabled) +- psb_enable_pipestat(dev_priv, 2, PIPE_VBLANK_INTERRUPT_ENABLE); +- else +- psb_disable_pipestat(dev_priv, 2, PIPE_VBLANK_INTERRUPT_ENABLE); ++ for (i = 0; i < dev->num_crtcs; ++i) { ++ if (dev->vblank[i].enabled) ++ psb_enable_pipestat(dev_priv, i, PIPE_VBLANK_INTERRUPT_ENABLE); ++ else ++ psb_disable_pipestat(dev_priv, i, PIPE_VBLANK_INTERRUPT_ENABLE); ++ } + + if (dev_priv->ops->hotplug_enable) + dev_priv->ops->hotplug_enable(dev, true); +@@ -388,6 +381,7 @@ void psb_irq_uninstall(struct drm_device + { + struct drm_psb_private *dev_priv = dev->dev_private; + unsigned long irqflags; ++ unsigned int i; + + spin_lock_irqsave(&dev_priv->irqmask_lock, irqflags); + +@@ -396,14 +390,10 @@ void psb_irq_uninstall(struct drm_device + + PSB_WVDC32(0xFFFFFFFF, PSB_HWSTAM); + +- if (dev->vblank[0].enabled) +- psb_disable_pipestat(dev_priv, 0, PIPE_VBLANK_INTERRUPT_ENABLE); +- +- if (dev->vblank[1].enabled) +- psb_disable_pipestat(dev_priv, 1, PIPE_VBLANK_INTERRUPT_ENABLE); +- +- if (dev->vblank[2].enabled) +- psb_disable_pipestat(dev_priv, 2, PIPE_VBLANK_INTERRUPT_ENABLE); ++ for (i = 0; i < dev->num_crtcs; ++i) { ++ if (dev->vblank[i].enabled) ++ psb_disable_pipestat(dev_priv, i, PIPE_VBLANK_INTERRUPT_ENABLE); ++ } + + dev_priv->vdc_irq_mask &= _PSB_IRQ_SGX_FLAG | + _PSB_IRQ_MSVDX_FLAG | diff --git a/queue-4.9/pinctrl-amd-fix-incorrect-way-to-disable-debounce-filter.patch b/queue-4.9/pinctrl-amd-fix-incorrect-way-to-disable-debounce-filter.patch new file mode 100644 index 00000000000..2a0a654495d --- /dev/null +++ b/queue-4.9/pinctrl-amd-fix-incorrect-way-to-disable-debounce-filter.patch @@ -0,0 +1,44 @@ +From 06abe8291bc31839950f7d0362d9979edc88a666 Mon Sep 17 00:00:00 2001 +From: Coiby Xu +Date: Fri, 6 Nov 2020 07:19:09 +0800 +Subject: pinctrl: amd: fix incorrect way to disable debounce filter + +From: Coiby Xu + +commit 06abe8291bc31839950f7d0362d9979edc88a666 upstream. + +The correct way to disable debounce filter is to clear bit 5 and 6 +of the register. + +Cc: stable@vger.kerne.org +Signed-off-by: Coiby Xu +Reviewed-by: Hans de Goede +Cc: Hans de Goede +Link: https://lore.kernel.org/linux-gpio/df2c008b-e7b5-4fdd-42ea-4d1c62b52139@redhat.com/ +Link: https://lore.kernel.org/r/20201105231912.69527-2-coiby.xu@gmail.com +Signed-off-by: Linus Walleij +Signed-off-by: Greg Kroah-Hartman + +--- + drivers/pinctrl/pinctrl-amd.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +--- a/drivers/pinctrl/pinctrl-amd.c ++++ b/drivers/pinctrl/pinctrl-amd.c +@@ -150,14 +150,14 @@ static int amd_gpio_set_debounce(struct + pin_reg |= BIT(DB_TMR_OUT_UNIT_OFF); + pin_reg |= BIT(DB_TMR_LARGE_OFF); + } else { +- pin_reg &= ~DB_CNTRl_MASK; ++ pin_reg &= ~(DB_CNTRl_MASK << DB_CNTRL_OFF); + ret = -EINVAL; + } + } else { + pin_reg &= ~BIT(DB_TMR_OUT_UNIT_OFF); + pin_reg &= ~BIT(DB_TMR_LARGE_OFF); + pin_reg &= ~DB_TMR_OUT_MASK; +- pin_reg &= ~DB_CNTRl_MASK; ++ pin_reg &= ~(DB_CNTRl_MASK << DB_CNTRL_OFF); + } + writel(pin_reg, gpio_dev->base + offset * 4); + spin_unlock_irqrestore(&gpio_dev->lock, flags); diff --git a/queue-4.9/pinctrl-amd-use-higher-precision-for-512-rtcclk.patch b/queue-4.9/pinctrl-amd-use-higher-precision-for-512-rtcclk.patch new file mode 100644 index 00000000000..ba004696254 --- /dev/null +++ b/queue-4.9/pinctrl-amd-use-higher-precision-for-512-rtcclk.patch @@ -0,0 +1,40 @@ +From c64a6a0d4a928c63e5bc3b485552a8903a506c36 Mon Sep 17 00:00:00 2001 +From: Coiby Xu +Date: Fri, 6 Nov 2020 07:19:10 +0800 +Subject: pinctrl: amd: use higher precision for 512 RtcClk + +From: Coiby Xu + +commit c64a6a0d4a928c63e5bc3b485552a8903a506c36 upstream. + +RTC is 32.768kHz thus 512 RtcClk equals 15625 usec. The documentation +likely has dropped precision and that's why the driver mistakenly took +the slightly deviated value. + +Cc: stable@vger.kernel.org +Reported-by: Andy Shevchenko +Suggested-by: Andy Shevchenko +Suggested-by: Hans de Goede +Signed-off-by: Coiby Xu +Reviewed-by: Andy Shevchenko +Reviewed-by: Hans de Goede +Link: https://lore.kernel.org/linux-gpio/2f4706a1-502f-75f0-9596-cc25b4933b6c@redhat.com/ +Link: https://lore.kernel.org/r/20201105231912.69527-3-coiby.xu@gmail.com +Signed-off-by: Linus Walleij +Signed-off-by: Greg Kroah-Hartman + +--- + drivers/pinctrl/pinctrl-amd.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/drivers/pinctrl/pinctrl-amd.c ++++ b/drivers/pinctrl/pinctrl-amd.c +@@ -140,7 +140,7 @@ static int amd_gpio_set_debounce(struct + pin_reg |= BIT(DB_TMR_OUT_UNIT_OFF); + pin_reg &= ~BIT(DB_TMR_LARGE_OFF); + } else if (debounce < 250000) { +- time = debounce / 15600; ++ time = debounce / 15625; + pin_reg |= time & DB_TMR_OUT_MASK; + pin_reg &= ~BIT(DB_TMR_OUT_UNIT_OFF); + pin_reg |= BIT(DB_TMR_LARGE_OFF); diff --git a/queue-4.9/series b/queue-4.9/series index 336d2121ee1..53ca22070ac 100644 --- a/queue-4.9/series +++ b/queue-4.9/series @@ -46,3 +46,7 @@ usb-cdc-acm-add-disable_echo-for-renesas-usb-download-mode.patch mei-protect-mei_cl_mtu-from-null-dereference.patch ocfs2-initialize-ip_next_orphan.patch don-t-dump-the-threads-that-had-been-already-exiting-when-zapped.patch +drm-gma500-fix-out-of-bounds-access-to-struct-drm_device.vblank.patch +pinctrl-amd-use-higher-precision-for-512-rtcclk.patch +pinctrl-amd-fix-incorrect-way-to-disable-debounce-filter.patch +swiotlb-fix-x86-don-t-panic-if-can-not-alloc-buffer-for-swiotlb.patch diff --git a/queue-4.9/swiotlb-fix-x86-don-t-panic-if-can-not-alloc-buffer-for-swiotlb.patch b/queue-4.9/swiotlb-fix-x86-don-t-panic-if-can-not-alloc-buffer-for-swiotlb.patch new file mode 100644 index 00000000000..c252718cca5 --- /dev/null +++ b/queue-4.9/swiotlb-fix-x86-don-t-panic-if-can-not-alloc-buffer-for-swiotlb.patch @@ -0,0 +1,76 @@ +From e9696d259d0fb5d239e8c28ca41089838ea76d13 Mon Sep 17 00:00:00 2001 +From: Stefano Stabellini +Date: Mon, 26 Oct 2020 17:02:14 -0700 +Subject: swiotlb: fix "x86: Don't panic if can not alloc buffer for swiotlb" + +From: Stefano Stabellini + +commit e9696d259d0fb5d239e8c28ca41089838ea76d13 upstream. + +kernel/dma/swiotlb.c:swiotlb_init gets called first and tries to +allocate a buffer for the swiotlb. It does so by calling + + memblock_alloc_low(PAGE_ALIGN(bytes), PAGE_SIZE); + +If the allocation must fail, no_iotlb_memory is set. + +Later during initialization swiotlb-xen comes in +(drivers/xen/swiotlb-xen.c:xen_swiotlb_init) and given that io_tlb_start +is != 0, it thinks the memory is ready to use when actually it is not. + +When the swiotlb is actually needed, swiotlb_tbl_map_single gets called +and since no_iotlb_memory is set the kernel panics. + +Instead, if swiotlb-xen.c:xen_swiotlb_init knew the swiotlb hadn't been +initialized, it would do the initialization itself, which might still +succeed. + +Fix the panic by setting io_tlb_start to 0 on swiotlb initialization +failure, and also by setting no_iotlb_memory to false on swiotlb +initialization success. + +Fixes: ac2cbab21f31 ("x86: Don't panic if can not alloc buffer for swiotlb") + +Reported-by: Elliott Mitchell +Tested-by: Elliott Mitchell +Signed-off-by: Stefano Stabellini +Reviewed-by: Christoph Hellwig +Cc: stable@vger.kernel.org +Signed-off-by: Konrad Rzeszutek Wilk +Signed-off-by: Greg Kroah-Hartman + +--- + lib/swiotlb.c | 6 +++++- + 1 file changed, 5 insertions(+), 1 deletion(-) + +--- a/lib/swiotlb.c ++++ b/lib/swiotlb.c +@@ -199,6 +199,7 @@ int __init swiotlb_init_with_tbl(char *t + io_tlb_orig_addr[i] = INVALID_PHYS_ADDR; + } + io_tlb_index = 0; ++ no_iotlb_memory = false; + + if (verbose) + swiotlb_print_info(); +@@ -229,9 +230,11 @@ swiotlb_init(int verbose) + if (vstart && !swiotlb_init_with_tbl(vstart, io_tlb_nslabs, verbose)) + return; + +- if (io_tlb_start) ++ if (io_tlb_start) { + memblock_free_early(io_tlb_start, + PAGE_ALIGN(io_tlb_nslabs << IO_TLB_SHIFT)); ++ io_tlb_start = 0; ++ } + pr_warn("Cannot allocate buffer"); + no_iotlb_memory = true; + } +@@ -330,6 +333,7 @@ swiotlb_late_init_with_tbl(char *tlb, un + io_tlb_orig_addr[i] = INVALID_PHYS_ADDR; + } + io_tlb_index = 0; ++ no_iotlb_memory = false; + + swiotlb_print_info(); +