From: Greg Kroah-Hartman Date: Thu, 18 May 2017 07:46:15 +0000 (+0200) Subject: 4.4-stable patches X-Git-Tag: v3.18.54~16 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=f03fb5213aa9fc1ffacce60ca17bf75085ef3467;p=thirdparty%2Fkernel%2Fstable-queue.git 4.4-stable patches added patches: bluetooth-fix-user-channel-for-32bit-userspace-on-64bit-kernel.patch bluetooth-hci_bcm-add-missing-tty-device-sanity-check.patch bluetooth-hci_intel-add-missing-tty-device-sanity-check.patch serial-omap-fix-runtime-pm-handling-on-unbind.patch serial-omap-suspend-device-on-probe-errors.patch serial-samsung-use-right-device-for-dma-mapping-calls.patch tty-pty-fix-ldisc-flush-after-userspace-become-aware-of-the-data-already.patch --- diff --git a/queue-4.4/bluetooth-fix-user-channel-for-32bit-userspace-on-64bit-kernel.patch b/queue-4.4/bluetooth-fix-user-channel-for-32bit-userspace-on-64bit-kernel.patch new file mode 100644 index 00000000000..e2529f2cfcb --- /dev/null +++ b/queue-4.4/bluetooth-fix-user-channel-for-32bit-userspace-on-64bit-kernel.patch @@ -0,0 +1,35 @@ +From ab89f0bdd63a3721f7cd3f064f39fc4ac7ca14d4 Mon Sep 17 00:00:00 2001 +From: Szymon Janc +Date: Mon, 24 Apr 2017 18:25:04 -0700 +Subject: Bluetooth: Fix user channel for 32bit userspace on 64bit kernel + +From: Szymon Janc + +commit ab89f0bdd63a3721f7cd3f064f39fc4ac7ca14d4 upstream. + +Running 32bit userspace on 64bit kernel results in MSG_CMSG_COMPAT being +defined as 0x80000000. This results in sendmsg failure if used from 32bit +userspace running on 64bit kernel. Fix this by accounting for MSG_CMSG_COMPAT +in flags check in hci_sock_sendmsg. + +Signed-off-by: Szymon Janc +Signed-off-by: Marko Kiiskila +Signed-off-by: Marcel Holtmann +Signed-off-by: Greg Kroah-Hartman + +--- + net/bluetooth/hci_sock.c | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +--- a/net/bluetooth/hci_sock.c ++++ b/net/bluetooth/hci_sock.c +@@ -1164,7 +1164,8 @@ static int hci_sock_sendmsg(struct socke + if (msg->msg_flags & MSG_OOB) + return -EOPNOTSUPP; + +- if (msg->msg_flags & ~(MSG_DONTWAIT|MSG_NOSIGNAL|MSG_ERRQUEUE)) ++ if (msg->msg_flags & ~(MSG_DONTWAIT|MSG_NOSIGNAL|MSG_ERRQUEUE| ++ MSG_CMSG_COMPAT)) + return -EINVAL; + + if (len < 4 || len > HCI_MAX_FRAME_SIZE) diff --git a/queue-4.4/bluetooth-hci_bcm-add-missing-tty-device-sanity-check.patch b/queue-4.4/bluetooth-hci_bcm-add-missing-tty-device-sanity-check.patch new file mode 100644 index 00000000000..ac09d2ebb12 --- /dev/null +++ b/queue-4.4/bluetooth-hci_bcm-add-missing-tty-device-sanity-check.patch @@ -0,0 +1,44 @@ +From 95065a61e9bf25fb85295127fba893200c2bbbd8 Mon Sep 17 00:00:00 2001 +From: Johan Hovold +Date: Wed, 29 Mar 2017 18:15:27 +0200 +Subject: Bluetooth: hci_bcm: add missing tty-device sanity check + +From: Johan Hovold + +commit 95065a61e9bf25fb85295127fba893200c2bbbd8 upstream. + +Make sure to check the tty-device pointer before looking up the sibling +platform device to avoid dereferencing a NULL-pointer when the tty is +one end of a Unix98 pty. + +Fixes: 0395ffc1ee05 ("Bluetooth: hci_bcm: Add PM for BCM devices") +Cc: Frederic Danis +Signed-off-by: Johan Hovold +Signed-off-by: Marcel Holtmann +Signed-off-by: Greg Kroah-Hartman + +--- + drivers/bluetooth/hci_bcm.c | 5 ++++- + 1 file changed, 4 insertions(+), 1 deletion(-) + +--- a/drivers/bluetooth/hci_bcm.c ++++ b/drivers/bluetooth/hci_bcm.c +@@ -287,6 +287,9 @@ static int bcm_open(struct hci_uart *hu) + + hu->priv = bcm; + ++ if (!hu->tty->dev) ++ goto out; ++ + mutex_lock(&bcm_device_lock); + list_for_each(p, &bcm_device_list) { + struct bcm_device *dev = list_entry(p, struct bcm_device, list); +@@ -307,7 +310,7 @@ static int bcm_open(struct hci_uart *hu) + } + + mutex_unlock(&bcm_device_lock); +- ++out: + return 0; + } + diff --git a/queue-4.4/bluetooth-hci_intel-add-missing-tty-device-sanity-check.patch b/queue-4.4/bluetooth-hci_intel-add-missing-tty-device-sanity-check.patch new file mode 100644 index 00000000000..950219e22ee --- /dev/null +++ b/queue-4.4/bluetooth-hci_intel-add-missing-tty-device-sanity-check.patch @@ -0,0 +1,74 @@ +From dcb9cfaa5ea9aa0ec08aeb92582ccfe3e4c719a9 Mon Sep 17 00:00:00 2001 +From: Johan Hovold +Date: Wed, 29 Mar 2017 18:15:28 +0200 +Subject: Bluetooth: hci_intel: add missing tty-device sanity check + +From: Johan Hovold + +commit dcb9cfaa5ea9aa0ec08aeb92582ccfe3e4c719a9 upstream. + +Make sure to check the tty-device pointer before looking up the sibling +platform device to avoid dereferencing a NULL-pointer when the tty is +one end of a Unix98 pty. + +Fixes: 74cdad37cd24 ("Bluetooth: hci_intel: Add runtime PM support") +Fixes: 1ab1f239bf17 ("Bluetooth: hci_intel: Add support for platform driver") +Cc: Loic Poulain +Signed-off-by: Johan Hovold +Signed-off-by: Marcel Holtmann +Signed-off-by: Greg Kroah-Hartman + +--- + drivers/bluetooth/hci_intel.c | 13 ++++++++++++- + 1 file changed, 12 insertions(+), 1 deletion(-) + +--- a/drivers/bluetooth/hci_intel.c ++++ b/drivers/bluetooth/hci_intel.c +@@ -307,6 +307,9 @@ static int intel_set_power(struct hci_ua + struct list_head *p; + int err = -ENODEV; + ++ if (!hu->tty->dev) ++ return err; ++ + mutex_lock(&intel_device_list_lock); + + list_for_each(p, &intel_device_list) { +@@ -379,6 +382,9 @@ static void intel_busy_work(struct work_ + struct intel_data *intel = container_of(work, struct intel_data, + busy_work); + ++ if (!intel->hu->tty->dev) ++ return; ++ + /* Link is busy, delay the suspend */ + mutex_lock(&intel_device_list_lock); + list_for_each(p, &intel_device_list) { +@@ -913,6 +919,8 @@ done: + list_for_each(p, &intel_device_list) { + struct intel_device *dev = list_entry(p, struct intel_device, + list); ++ if (!hu->tty->dev) ++ break; + if (hu->tty->dev->parent == dev->pdev->dev.parent) { + if (device_may_wakeup(&dev->pdev->dev)) + idev = dev; +@@ -1094,6 +1102,9 @@ static int intel_enqueue(struct hci_uart + + BT_DBG("hu %p skb %p", hu, skb); + ++ if (!hu->tty->dev) ++ goto out_enqueue; ++ + /* Be sure our controller is resumed and potential LPM transaction + * completed before enqueuing any packet. + */ +@@ -1110,7 +1121,7 @@ static int intel_enqueue(struct hci_uart + } + } + mutex_unlock(&intel_device_list_lock); +- ++out_enqueue: + skb_queue_tail(&intel->txq, skb); + + return 0; diff --git a/queue-4.4/serial-omap-fix-runtime-pm-handling-on-unbind.patch b/queue-4.4/serial-omap-fix-runtime-pm-handling-on-unbind.patch new file mode 100644 index 00000000000..4fdb79c06ac --- /dev/null +++ b/queue-4.4/serial-omap-fix-runtime-pm-handling-on-unbind.patch @@ -0,0 +1,66 @@ +From 099bd73dc17ed77aa8c98323e043613b6e8f54fc Mon Sep 17 00:00:00 2001 +From: Johan Hovold +Date: Mon, 10 Apr 2017 11:21:38 +0200 +Subject: serial: omap: fix runtime-pm handling on unbind + +From: Johan Hovold + +commit 099bd73dc17ed77aa8c98323e043613b6e8f54fc upstream. + +An unbalanced and misplaced synchronous put was used to suspend the +device on driver unbind, something which with a likewise misplaced +pm_runtime_disable leads to external aborts when an open port is being +removed. + +Unhandled fault: external abort on non-linefetch (0x1028) at 0xfa024010 +... +[] (serial_omap_set_mctrl) from [] (uart_update_mctrl+0x50/0x60) +[] (uart_update_mctrl) from [] (uart_shutdown+0xbc/0x138) +[] (uart_shutdown) from [] (uart_hangup+0x94/0x190) +[] (uart_hangup) from [] (__tty_hangup+0x404/0x41c) +[] (__tty_hangup) from [] (tty_vhangup+0x1c/0x20) +[] (tty_vhangup) from [] (uart_remove_one_port+0xec/0x260) +[] (uart_remove_one_port) from [] (serial_omap_remove+0x40/0x60) +[] (serial_omap_remove) from [] (platform_drv_remove+0x34/0x4c) + +Fix this up by resuming the device before deregistering the port and by +suspending and disabling runtime pm only after the port has been +removed. + +Also make sure to disable autosuspend before disabling runtime pm so +that the usage count is balanced and device actually suspended before +returning. + +Note that due to a negative autosuspend delay being set in probe, the +unbalanced put would actually suspend the device on first driver unbind, +while rebinding and again unbinding would result in a negative +power.usage_count. + +Fixes: 7e9c8e7dbf3b ("serial: omap: make sure to suspend device before remove") +Cc: Felipe Balbi +Cc: Santosh Shilimkar +Signed-off-by: Johan Hovold +Acked-by: Tony Lindgren +Signed-off-by: Greg Kroah-Hartman + +--- + drivers/tty/serial/omap-serial.c | 6 +++++- + 1 file changed, 5 insertions(+), 1 deletion(-) + +--- a/drivers/tty/serial/omap-serial.c ++++ b/drivers/tty/serial/omap-serial.c +@@ -1725,9 +1725,13 @@ static int serial_omap_remove(struct pla + { + struct uart_omap_port *up = platform_get_drvdata(dev); + ++ pm_runtime_get_sync(up->dev); ++ ++ uart_remove_one_port(&serial_omap_reg, &up->port); ++ ++ pm_runtime_dont_use_autosuspend(up->dev); + pm_runtime_put_sync(up->dev); + pm_runtime_disable(up->dev); +- uart_remove_one_port(&serial_omap_reg, &up->port); + pm_qos_remove_request(&up->pm_qos_request); + device_init_wakeup(&dev->dev, false); + diff --git a/queue-4.4/serial-omap-suspend-device-on-probe-errors.patch b/queue-4.4/serial-omap-suspend-device-on-probe-errors.patch new file mode 100644 index 00000000000..2d68f0f5b5a --- /dev/null +++ b/queue-4.4/serial-omap-suspend-device-on-probe-errors.patch @@ -0,0 +1,38 @@ +From 77e6fe7fd2b7cba0bf2f2dc8cde51d7b9a35bf74 Mon Sep 17 00:00:00 2001 +From: Johan Hovold +Date: Mon, 10 Apr 2017 11:21:39 +0200 +Subject: serial: omap: suspend device on probe errors + +From: Johan Hovold + +commit 77e6fe7fd2b7cba0bf2f2dc8cde51d7b9a35bf74 upstream. + +Make sure to actually suspend the device before returning after a failed +(or deferred) probe. + +Note that autosuspend must be disabled before runtime pm is disabled in +order to balance the usage count due to a negative autosuspend delay as +well as to make the final put suspend the device synchronously. + +Fixes: 388bc2622680 ("omap-serial: Fix the error handling in the omap_serial probe") +Cc: Shubhrajyoti D +Signed-off-by: Johan Hovold +Acked-by: Tony Lindgren +Signed-off-by: Greg Kroah-Hartman + +--- + drivers/tty/serial/omap-serial.c | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +--- a/drivers/tty/serial/omap-serial.c ++++ b/drivers/tty/serial/omap-serial.c +@@ -1712,7 +1712,8 @@ static int serial_omap_probe(struct plat + return 0; + + err_add_port: +- pm_runtime_put(&pdev->dev); ++ pm_runtime_dont_use_autosuspend(&pdev->dev); ++ pm_runtime_put_sync(&pdev->dev); + pm_runtime_disable(&pdev->dev); + pm_qos_remove_request(&up->pm_qos_request); + device_init_wakeup(up->dev, false); diff --git a/queue-4.4/serial-samsung-use-right-device-for-dma-mapping-calls.patch b/queue-4.4/serial-samsung-use-right-device-for-dma-mapping-calls.patch new file mode 100644 index 00000000000..dae14e41c6a --- /dev/null +++ b/queue-4.4/serial-samsung-use-right-device-for-dma-mapping-calls.patch @@ -0,0 +1,78 @@ +From 768d64f491a530062ddad50e016fb27125f8bd7c Mon Sep 17 00:00:00 2001 +From: Marek Szyprowski +Date: Mon, 3 Apr 2017 08:20:59 +0200 +Subject: serial: samsung: Use right device for DMA-mapping calls + +From: Marek Szyprowski + +commit 768d64f491a530062ddad50e016fb27125f8bd7c upstream. + +Driver should provide its own struct device for all DMA-mapping calls instead +of extracting device pointer from DMA engine channel. Although this is harmless +from the driver operation perspective on ARM architecture, it is always good +to use the DMA mapping API in a proper way. This patch fixes following DMA API +debug warning: + +WARNING: CPU: 0 PID: 0 at lib/dma-debug.c:1241 check_sync+0x520/0x9f4 +samsung-uart 12c20000.serial: DMA-API: device driver tries to sync DMA memory it has not allocated [device address=0x000000006df0f580] [size=64 bytes] +Modules linked in: +CPU: 0 PID: 0 Comm: swapper/0 Not tainted 4.11.0-rc1-00137-g07ca963 #51 +Hardware name: SAMSUNG EXYNOS (Flattened Device Tree) +[] (unwind_backtrace) from [] (show_stack+0x20/0x24) +[] (show_stack) from [] (dump_stack+0x84/0xa0) +[] (dump_stack) from [] (__warn+0x14c/0x180) +[] (__warn) from [] (warn_slowpath_fmt+0x48/0x50) +[] (warn_slowpath_fmt) from [] (check_sync+0x520/0x9f4) +[] (check_sync) from [] (debug_dma_sync_single_for_device+0x88/0xc8) +[] (debug_dma_sync_single_for_device) from [] (s3c24xx_serial_start_tx_dma+0x100/0x2f8) +[] (s3c24xx_serial_start_tx_dma) from [] (s3c24xx_serial_tx_chars+0x198/0x33c) + +Reported-by: Seung-Woo Kim +Fixes: 62c37eedb74c8 ("serial: samsung: add dma reqest/release functions") +Signed-off-by: Marek Szyprowski +Reviewed-by: Bartlomiej Zolnierkiewicz +Reviewed-by: Krzysztof Kozlowski +Reviewed-by: Shuah Khan +Signed-off-by: Greg Kroah-Hartman + +--- + drivers/tty/serial/samsung.c | 9 ++++----- + 1 file changed, 4 insertions(+), 5 deletions(-) + +--- a/drivers/tty/serial/samsung.c ++++ b/drivers/tty/serial/samsung.c +@@ -900,14 +900,13 @@ static int s3c24xx_serial_request_dma(st + return -ENOMEM; + } + +- dma->rx_addr = dma_map_single(dma->rx_chan->device->dev, dma->rx_buf, ++ dma->rx_addr = dma_map_single(p->port.dev, dma->rx_buf, + dma->rx_size, DMA_FROM_DEVICE); + + spin_lock_irqsave(&p->port.lock, flags); + + /* TX buffer */ +- dma->tx_addr = dma_map_single(dma->tx_chan->device->dev, +- p->port.state->xmit.buf, ++ dma->tx_addr = dma_map_single(p->port.dev, p->port.state->xmit.buf, + UART_XMIT_SIZE, DMA_TO_DEVICE); + + spin_unlock_irqrestore(&p->port.lock, flags); +@@ -921,7 +920,7 @@ static void s3c24xx_serial_release_dma(s + + if (dma->rx_chan) { + dmaengine_terminate_all(dma->rx_chan); +- dma_unmap_single(dma->rx_chan->device->dev, dma->rx_addr, ++ dma_unmap_single(p->port.dev, dma->rx_addr, + dma->rx_size, DMA_FROM_DEVICE); + kfree(dma->rx_buf); + dma_release_channel(dma->rx_chan); +@@ -930,7 +929,7 @@ static void s3c24xx_serial_release_dma(s + + if (dma->tx_chan) { + dmaengine_terminate_all(dma->tx_chan); +- dma_unmap_single(dma->tx_chan->device->dev, dma->tx_addr, ++ dma_unmap_single(p->port.dev, dma->tx_addr, + UART_XMIT_SIZE, DMA_TO_DEVICE); + dma_release_channel(dma->tx_chan); + dma->tx_chan = NULL; diff --git a/queue-4.4/series b/queue-4.4/series index 1e4e206b8fe..d68b3a3c98c 100644 --- a/queue-4.4/series +++ b/queue-4.4/series @@ -41,3 +41,10 @@ cifs-fix-cifs_ioc_get_mnt_info-oops.patch cifs-add-misssing-sfm-mapping-for-doublequote.patch padata-free-correct-variable.patch arm64-kvm-fix-decoding-of-rt-rt2-when-trapping-aarch32-cp-accesses.patch +serial-samsung-use-right-device-for-dma-mapping-calls.patch +serial-omap-fix-runtime-pm-handling-on-unbind.patch +serial-omap-suspend-device-on-probe-errors.patch +tty-pty-fix-ldisc-flush-after-userspace-become-aware-of-the-data-already.patch +bluetooth-fix-user-channel-for-32bit-userspace-on-64bit-kernel.patch +bluetooth-hci_bcm-add-missing-tty-device-sanity-check.patch +bluetooth-hci_intel-add-missing-tty-device-sanity-check.patch diff --git a/queue-4.4/tty-pty-fix-ldisc-flush-after-userspace-become-aware-of-the-data-already.patch b/queue-4.4/tty-pty-fix-ldisc-flush-after-userspace-become-aware-of-the-data-already.patch new file mode 100644 index 00000000000..dafc9a4a375 --- /dev/null +++ b/queue-4.4/tty-pty-fix-ldisc-flush-after-userspace-become-aware-of-the-data-already.patch @@ -0,0 +1,83 @@ +From 77dae6134440420bac334581a3ccee94cee1c054 Mon Sep 17 00:00:00 2001 +From: Wang YanQing +Date: Wed, 22 Feb 2017 19:37:08 +0800 +Subject: tty: pty: Fix ldisc flush after userspace become aware of the data already + +From: Wang YanQing + +commit 77dae6134440420bac334581a3ccee94cee1c054 upstream. + +While using emacs, cat or others' commands in konsole with recent +kernels, I have met many times that CTRL-C freeze konsole. After +konsole freeze I can't type anything, then I have to open a new one, +it is very annoying. + +See bug report: +https://bugs.kde.org/show_bug.cgi?id=175283 + +The platform in that bug report is Solaris, but now the pty in linux +has the same problem or the same behavior as Solaris :) + +It has high possibility to trigger the problem follow steps below: +Note: In my test, BigFile is a text file whose size is bigger than 1G +1:open konsole +1:cat BigFile +2:CTRL-C + +After some digging, I find out the reason is that commit 1d1d14da12e7 +("pty: Fix buffer flush deadlock") changes the behavior of pty_flush_buffer. + +Thread A Thread B +-------- -------- +1:n_tty_poll return POLLIN + 2:CTRL-C trigger pty_flush_buffer + tty_buffer_flush + n_tty_flush_buffer +3:attempt to check count of chars: + ioctl(fd, TIOCINQ, &available) + available is equal to 0 + +4:read(fd, buffer, avaiable) + return 0 + +5:konsole close fd + +Yes, I know we could use the same patch included in the BUG report as +a workaround for linux platform too. But I think the data in ldisc is +belong to application of another side, we shouldn't clear it when we +want to flush write buffer of this side in pty_flush_buffer. So I think +it is better to disable ldisc flush in pty_flush_buffer, because its new +hehavior bring no benefit except that it mess up the behavior between +POLLIN, and TIOCINQ or FIONREAD. + +Also I find no flush_buffer function in others' tty driver has the +same behavior as current pty_flush_buffer. + +Fixes: 1d1d14da12e7 ("pty: Fix buffer flush deadlock") +Signed-off-by: Wang YanQing +Signed-off-by: Greg Kroah-Hartman + +--- + drivers/tty/pty.c | 7 +------ + 1 file changed, 1 insertion(+), 6 deletions(-) + +--- a/drivers/tty/pty.c ++++ b/drivers/tty/pty.c +@@ -216,16 +216,11 @@ static int pty_signal(struct tty_struct + static void pty_flush_buffer(struct tty_struct *tty) + { + struct tty_struct *to = tty->link; +- struct tty_ldisc *ld; + + if (!to) + return; + +- ld = tty_ldisc_ref(to); +- tty_buffer_flush(to, ld); +- if (ld) +- tty_ldisc_deref(ld); +- ++ tty_buffer_flush(to, NULL); + if (to->packet) { + spin_lock_irq(&tty->ctrl_lock); + tty->ctrl_status |= TIOCPKT_FLUSHWRITE;