From c2f1ff0fc123443a4e93ec2ed041684ebc088006 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Sun, 25 Sep 2022 09:40:50 +0200 Subject: [PATCH] 5.15-stable patches added patches: s390-dasd-fix-oops-in-dasd_alias_get_start_dev-due-to-missing-pavgroup.patch serial-create-uart_xmit_advance.patch serial-fsl_lpuart-reset-prior-to-registration.patch serial-tegra-tcu-use-uart_xmit_advance-fixes-icount.tx-accounting.patch serial-tegra-use-uart_xmit_advance-fixes-icount.tx-accounting.patch --- ...et_start_dev-due-to-missing-pavgroup.patch | 59 +++++++++++++++++ .../serial-create-uart_xmit_advance.patch | 51 +++++++++++++++ ...l_lpuart-reset-prior-to-registration.patch | 63 +++++++++++++++++++ ...t_advance-fixes-icount.tx-accounting.patch | 36 +++++++++++ ...t_advance-fixes-icount.tx-accounting.patch | 53 ++++++++++++++++ queue-5.15/series | 5 ++ 6 files changed, 267 insertions(+) create mode 100644 queue-5.15/s390-dasd-fix-oops-in-dasd_alias_get_start_dev-due-to-missing-pavgroup.patch create mode 100644 queue-5.15/serial-create-uart_xmit_advance.patch create mode 100644 queue-5.15/serial-fsl_lpuart-reset-prior-to-registration.patch create mode 100644 queue-5.15/serial-tegra-tcu-use-uart_xmit_advance-fixes-icount.tx-accounting.patch create mode 100644 queue-5.15/serial-tegra-use-uart_xmit_advance-fixes-icount.tx-accounting.patch diff --git a/queue-5.15/s390-dasd-fix-oops-in-dasd_alias_get_start_dev-due-to-missing-pavgroup.patch b/queue-5.15/s390-dasd-fix-oops-in-dasd_alias_get_start_dev-due-to-missing-pavgroup.patch new file mode 100644 index 00000000000..750f0976079 --- /dev/null +++ b/queue-5.15/s390-dasd-fix-oops-in-dasd_alias_get_start_dev-due-to-missing-pavgroup.patch @@ -0,0 +1,59 @@ +From db7ba07108a48c0f95b74fabbfd5d63e924f992d Mon Sep 17 00:00:00 2001 +From: Stefan Haberland +Date: Mon, 19 Sep 2022 17:49:31 +0200 +Subject: s390/dasd: fix Oops in dasd_alias_get_start_dev due to missing pavgroup + +From: Stefan Haberland + +commit db7ba07108a48c0f95b74fabbfd5d63e924f992d upstream. + +Fix Oops in dasd_alias_get_start_dev() function caused by the pavgroup +pointer being NULL. + +The pavgroup pointer is checked on the entrance of the function but +without the lcu->lock being held. Therefore there is a race window +between dasd_alias_get_start_dev() and _lcu_update() which sets +pavgroup to NULL with the lcu->lock held. + +Fix by checking the pavgroup pointer with lcu->lock held. + +Cc: # 2.6.25+ +Fixes: 8e09f21574ea ("[S390] dasd: add hyper PAV support to DASD device driver, part 1") +Signed-off-by: Stefan Haberland +Reviewed-by: Jan Hoeppner +Link: https://lore.kernel.org/r/20220919154931.4123002-2-sth@linux.ibm.com +Signed-off-by: Jens Axboe +Signed-off-by: Greg Kroah-Hartman +--- + drivers/s390/block/dasd_alias.c | 9 +++++++-- + 1 file changed, 7 insertions(+), 2 deletions(-) + +--- a/drivers/s390/block/dasd_alias.c ++++ b/drivers/s390/block/dasd_alias.c +@@ -675,12 +675,12 @@ int dasd_alias_remove_device(struct dasd + struct dasd_device *dasd_alias_get_start_dev(struct dasd_device *base_device) + { + struct dasd_eckd_private *alias_priv, *private = base_device->private; +- struct alias_pav_group *group = private->pavgroup; + struct alias_lcu *lcu = private->lcu; + struct dasd_device *alias_device; ++ struct alias_pav_group *group; + unsigned long flags; + +- if (!group || !lcu) ++ if (!lcu) + return NULL; + if (lcu->pav == NO_PAV || + lcu->flags & (NEED_UAC_UPDATE | UPDATE_PENDING)) +@@ -697,6 +697,11 @@ struct dasd_device *dasd_alias_get_start + } + + spin_lock_irqsave(&lcu->lock, flags); ++ group = private->pavgroup; ++ if (!group) { ++ spin_unlock_irqrestore(&lcu->lock, flags); ++ return NULL; ++ } + alias_device = group->next; + if (!alias_device) { + if (list_empty(&group->aliaslist)) { diff --git a/queue-5.15/serial-create-uart_xmit_advance.patch b/queue-5.15/serial-create-uart_xmit_advance.patch new file mode 100644 index 00000000000..ee018f585b7 --- /dev/null +++ b/queue-5.15/serial-create-uart_xmit_advance.patch @@ -0,0 +1,51 @@ +From e77cab77f2cb3a1ca2ba8df4af45bb35617ac16d Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= +Date: Thu, 1 Sep 2022 17:39:32 +0300 +Subject: serial: Create uart_xmit_advance() +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +From: Ilpo Järvinen + +commit e77cab77f2cb3a1ca2ba8df4af45bb35617ac16d upstream. + +A very common pattern in the drivers is to advance xmit tail +index and do bookkeeping of Tx'ed characters. Create +uart_xmit_advance() to handle it. + +Reviewed-by: Andy Shevchenko +Cc: stable +Signed-off-by: Ilpo Järvinen +Link: https://lore.kernel.org/r/20220901143934.8850-2-ilpo.jarvinen@linux.intel.com +Signed-off-by: Greg Kroah-Hartman +--- + include/linux/serial_core.h | 17 +++++++++++++++++ + 1 file changed, 17 insertions(+) + +--- a/include/linux/serial_core.h ++++ b/include/linux/serial_core.h +@@ -300,6 +300,23 @@ struct uart_state { + /* number of characters left in xmit buffer before we ask for more */ + #define WAKEUP_CHARS 256 + ++/** ++ * uart_xmit_advance - Advance xmit buffer and account Tx'ed chars ++ * @up: uart_port structure describing the port ++ * @chars: number of characters sent ++ * ++ * This function advances the tail of circular xmit buffer by the number of ++ * @chars transmitted and handles accounting of transmitted bytes (into ++ * @up's icount.tx). ++ */ ++static inline void uart_xmit_advance(struct uart_port *up, unsigned int chars) ++{ ++ struct circ_buf *xmit = &up->state->xmit; ++ ++ xmit->tail = (xmit->tail + chars) & (UART_XMIT_SIZE - 1); ++ up->icount.tx += chars; ++} ++ + struct module; + struct tty_driver; + diff --git a/queue-5.15/serial-fsl_lpuart-reset-prior-to-registration.patch b/queue-5.15/serial-fsl_lpuart-reset-prior-to-registration.patch new file mode 100644 index 00000000000..950406b3bf5 --- /dev/null +++ b/queue-5.15/serial-fsl_lpuart-reset-prior-to-registration.patch @@ -0,0 +1,63 @@ +From 60f361722ad2ae5ee667d0b0545d40c42f754daf Mon Sep 17 00:00:00 2001 +From: Lukas Wunner +Date: Sun, 11 Sep 2022 10:22:01 +0200 +Subject: serial: fsl_lpuart: Reset prior to registration +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +From: Lukas Wunner + +commit 60f361722ad2ae5ee667d0b0545d40c42f754daf upstream. + +Since commit bd5305dcabbc ("tty: serial: fsl_lpuart: do software reset +for imx7ulp and imx8qxp"), certain i.MX UARTs are reset after they've +already been registered. Register state may thus be clobbered after +user space has begun to open and access the UART. + +Avoid by performing the reset prior to registration. + +Fixes: bd5305dcabbc ("tty: serial: fsl_lpuart: do software reset for imx7ulp and imx8qxp") +Cc: stable@vger.kernel.org # v5.15+ +Cc: Fugang Duan +Cc: Sherry Sun +Reviewed-by: Ilpo Järvinen +Signed-off-by: Lukas Wunner +Link: https://lore.kernel.org/r/72fb646c1b0b11c989850c55f52f9ff343d1b2fa.1662884345.git.lukas@wunner.de +Signed-off-by: Greg Kroah-Hartman +--- + drivers/tty/serial/fsl_lpuart.c | 9 +++++---- + 1 file changed, 5 insertions(+), 4 deletions(-) + +--- a/drivers/tty/serial/fsl_lpuart.c ++++ b/drivers/tty/serial/fsl_lpuart.c +@@ -2726,14 +2726,15 @@ static int lpuart_probe(struct platform_ + lpuart_reg.cons = LPUART_CONSOLE; + handler = lpuart_int; + } +- ret = uart_add_one_port(&lpuart_reg, &sport->port); +- if (ret) +- goto failed_attach_port; + + ret = lpuart_global_reset(sport); + if (ret) + goto failed_reset; + ++ ret = uart_add_one_port(&lpuart_reg, &sport->port); ++ if (ret) ++ goto failed_attach_port; ++ + ret = uart_get_rs485_mode(&sport->port); + if (ret) + goto failed_get_rs485; +@@ -2756,9 +2757,9 @@ static int lpuart_probe(struct platform_ + + failed_irq_request: + failed_get_rs485: +-failed_reset: + uart_remove_one_port(&lpuart_reg, &sport->port); + failed_attach_port: ++failed_reset: + lpuart_disable_clks(sport); + return ret; + } diff --git a/queue-5.15/serial-tegra-tcu-use-uart_xmit_advance-fixes-icount.tx-accounting.patch b/queue-5.15/serial-tegra-tcu-use-uart_xmit_advance-fixes-icount.tx-accounting.patch new file mode 100644 index 00000000000..877d7e7fe8a --- /dev/null +++ b/queue-5.15/serial-tegra-tcu-use-uart_xmit_advance-fixes-icount.tx-accounting.patch @@ -0,0 +1,36 @@ +From 1d10cd4da593bc0196a239dcc54dac24b6b0a74e Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= +Date: Thu, 1 Sep 2022 17:39:34 +0300 +Subject: serial: tegra-tcu: Use uart_xmit_advance(), fixes icount.tx accounting +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +From: Ilpo Järvinen + +commit 1d10cd4da593bc0196a239dcc54dac24b6b0a74e upstream. + +Tx'ing does not correctly account Tx'ed characters into icount.tx. +Using uart_xmit_advance() fixes the problem. + +Fixes: 2d908b38d409 ("serial: Add Tegra Combined UART driver") +Cc: # serial: Create uart_xmit_advance() +Reviewed-by: Andy Shevchenko +Signed-off-by: Ilpo Järvinen +Link: https://lore.kernel.org/r/20220901143934.8850-4-ilpo.jarvinen@linux.intel.com +Signed-off-by: Greg Kroah-Hartman +--- + drivers/tty/serial/tegra-tcu.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/drivers/tty/serial/tegra-tcu.c ++++ b/drivers/tty/serial/tegra-tcu.c +@@ -101,7 +101,7 @@ static void tegra_tcu_uart_start_tx(stru + break; + + tegra_tcu_write(tcu, &xmit->buf[xmit->tail], count); +- xmit->tail = (xmit->tail + count) & (UART_XMIT_SIZE - 1); ++ uart_xmit_advance(port, count); + } + + uart_write_wakeup(port); diff --git a/queue-5.15/serial-tegra-use-uart_xmit_advance-fixes-icount.tx-accounting.patch b/queue-5.15/serial-tegra-use-uart_xmit_advance-fixes-icount.tx-accounting.patch new file mode 100644 index 00000000000..5df060eddd4 --- /dev/null +++ b/queue-5.15/serial-tegra-use-uart_xmit_advance-fixes-icount.tx-accounting.patch @@ -0,0 +1,53 @@ +From 754f68044c7dd6c52534ba3e0f664830285c4b15 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= +Date: Thu, 1 Sep 2022 17:39:33 +0300 +Subject: serial: tegra: Use uart_xmit_advance(), fixes icount.tx accounting +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +From: Ilpo Järvinen + +commit 754f68044c7dd6c52534ba3e0f664830285c4b15 upstream. + +DMA complete & stop paths did not correctly account Tx'ed characters +into icount.tx. Using uart_xmit_advance() fixes the problem. + +Fixes: e9ea096dd225 ("serial: tegra: add serial driver") +Cc: # serial: Create uart_xmit_advance() +Reviewed-by: Andy Shevchenko +Signed-off-by: Ilpo Järvinen +Link: https://lore.kernel.org/r/20220901143934.8850-3-ilpo.jarvinen@linux.intel.com +Signed-off-by: Greg Kroah-Hartman +--- + drivers/tty/serial/serial-tegra.c | 5 ++--- + 1 file changed, 2 insertions(+), 3 deletions(-) + +--- a/drivers/tty/serial/serial-tegra.c ++++ b/drivers/tty/serial/serial-tegra.c +@@ -525,7 +525,7 @@ static void tegra_uart_tx_dma_complete(v + count = tup->tx_bytes_requested - state.residue; + async_tx_ack(tup->tx_dma_desc); + spin_lock_irqsave(&tup->uport.lock, flags); +- xmit->tail = (xmit->tail + count) & (UART_XMIT_SIZE - 1); ++ uart_xmit_advance(&tup->uport, count); + tup->tx_in_progress = 0; + if (uart_circ_chars_pending(xmit) < WAKEUP_CHARS) + uart_write_wakeup(&tup->uport); +@@ -613,7 +613,6 @@ static unsigned int tegra_uart_tx_empty( + static void tegra_uart_stop_tx(struct uart_port *u) + { + struct tegra_uart_port *tup = to_tegra_uport(u); +- struct circ_buf *xmit = &tup->uport.state->xmit; + struct dma_tx_state state; + unsigned int count; + +@@ -624,7 +623,7 @@ static void tegra_uart_stop_tx(struct ua + dmaengine_tx_status(tup->tx_dma_chan, tup->tx_cookie, &state); + count = tup->tx_bytes_requested - state.residue; + async_tx_ack(tup->tx_dma_desc); +- xmit->tail = (xmit->tail + count) & (UART_XMIT_SIZE - 1); ++ uart_xmit_advance(&tup->uport, count); + tup->tx_in_progress = 0; + } + diff --git a/queue-5.15/series b/queue-5.15/series index a4f41d281e1..0ad6c328c4a 100644 --- a/queue-5.15/series +++ b/queue-5.15/series @@ -115,3 +115,8 @@ net-sched-fix-possible-refcount-leak-in-tc_new_tfilt.patch bnxt-prevent-skb-uaf-after-handing-over-to-ptp-worke.patch selftests-forwarding-add-shebang-for-sch_red.sh.patch kvm-x86-mmu-fold-rmap_recycle-into-rmap_add.patch +serial-fsl_lpuart-reset-prior-to-registration.patch +serial-create-uart_xmit_advance.patch +serial-tegra-use-uart_xmit_advance-fixes-icount.tx-accounting.patch +serial-tegra-tcu-use-uart_xmit_advance-fixes-icount.tx-accounting.patch +s390-dasd-fix-oops-in-dasd_alias_get_start_dev-due-to-missing-pavgroup.patch -- 2.47.3