[PATCH OLK-6.6 0/3] CVE-2026-74653
PATCH 1: Add serial8250_handle_irq_locked for PATCH 3 PATCH 2: The bugfix for PATCH 1 PATCH 3: CVE-2026-74653 Ilpo Järvinen (1): serial: 8250: Add serial8250_handle_irq_locked() Jacques Nilo (1): serial: 8250: dispatch SysRq character in serial8250_handle_irq() Ryan Wilbur (1): serial: 8250_of: clear stuck empty-FIFO RX-timeout on LPC32xx drivers/tty/serial/8250/8250_of.c | 44 +++++++++++++++++++++++++++++ drivers/tty/serial/8250/8250_port.c | 28 +++++++++++++----- include/linux/serial_8250.h | 1 + 3 files changed, 66 insertions(+), 7 deletions(-) -- 2.18.0.huawei.25
反馈: 您发送到kernel@openeuler.org的补丁/补丁集,已成功转换为PR! PR链接地址: https://atomgit.com/openeuler/kernel/merge_requests/27068 邮件列表地址:https://mailweb.openeuler.org/archives/list/kernel@openeuler.org/message/UYA... FeedBack: The patch(es) which you have sent to kernel@openeuler.org mailing list has been converted to a pull request successfully! Pull request link: https://atomgit.com/openeuler/kernel/merge_requests/27068 Mailing list address: https://mailweb.openeuler.org/archives/list/kernel@openeuler.org/message/UYA...
From: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com> mainline inclusion from mainline-v7.0-rc5 commit 8324a54f604da18f21070702a8ad82ab2062787b category: feature bugzilla: https://atomgit.com/src-openeuler/kernel/issues/18269 CVE: CVE-2026-74653 Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?i... -------------------------------- 8250_port exports serial8250_handle_irq() to HW specific 8250 drivers. It takes port's lock within but a HW specific 8250 driver may want to take port's lock itself, do something, and then call the generic handler in 8250_port but to do that, the caller has to release port's lock for no good reason. Introduce serial8250_handle_irq_locked() which a HW specific driver can call while already holding port's lock. As this is new export, put it straight into a namespace (where all 8250 exports should eventually be moved). Tested-by: Bandal, Shankar <shankar.bandal@intel.com> Tested-by: Murthy, Shanth <shanth.murthy@intel.com> Cc: stable <stable@kernel.org> Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com> Link: https://patch.msgid.link/20260203171049.4353-4-ilpo.jarvinen@linux.intel.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Conflicts: drivers/tty/serial/8250/8250_port.c include/linux/serial_8250.h [There is no guard(xxx) in 6.6. Restore it to the method of locking and unlocking. Others are context conflicts.] Signed-off-by: Cai Xinchen <caixinchen1@huawei.com> --- drivers/tty/serial/8250/8250_port.c | 27 +++++++++++++++++++-------- include/linux/serial_8250.h | 1 + 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/drivers/tty/serial/8250/8250_port.c b/drivers/tty/serial/8250/8250_port.c index c246503c9f80..04b1e3157dca 100644 --- a/drivers/tty/serial/8250/8250_port.c +++ b/drivers/tty/serial/8250/8250_port.c @@ -18,6 +18,7 @@ #include <linux/irq.h> #include <linux/console.h> #include <linux/gpio/consumer.h> +#include <linux/lockdep.h> #include <linux/sysrq.h> #include <linux/delay.h> #include <linux/platform_device.h> @@ -1899,20 +1900,16 @@ static bool handle_rx_dma(struct uart_8250_port *up, unsigned int iir) } /* - * This handles the interrupt from one port. + * Context: port's lock must be held by the caller. */ -int serial8250_handle_irq(struct uart_port *port, unsigned int iir) +void serial8250_handle_irq_locked(struct uart_port *port, unsigned int iir) { struct uart_8250_port *up = up_to_u8250p(port); struct tty_port *tport = &port->state->port; bool skip_rx = false; - unsigned long flags; u16 status; - if (iir & UART_IIR_NO_INT) - return 0; - - spin_lock_irqsave(&port->lock, flags); + lockdep_assert_held_once(&port->lock); status = serial_lsr_in(up); @@ -1945,8 +1942,22 @@ int serial8250_handle_irq(struct uart_port *port, unsigned int iir) else if (!up->dma->tx_running) __stop_tx(up); } +} +EXPORT_SYMBOL_NS_GPL(serial8250_handle_irq_locked, SERIAL_8250); + +/* + * This handles the interrupt from one port. + */ +int serial8250_handle_irq(struct uart_port *port, unsigned int iir) +{ + unsigned long flags; + + if (iir & UART_IIR_NO_INT) + return 0; - uart_unlock_and_check_sysrq_irqrestore(port, flags); + uart_port_lock_irqsave(port, &flags); + serial8250_handle_irq_locked(port, iir); + uart_port_unlock_irqrestore(port, flags); return 1; } diff --git a/include/linux/serial_8250.h b/include/linux/serial_8250.h index be65de65fe61..7e66e6237935 100644 --- a/include/linux/serial_8250.h +++ b/include/linux/serial_8250.h @@ -195,6 +195,7 @@ void serial8250_do_set_mctrl(struct uart_port *port, unsigned int mctrl); void serial8250_do_set_divisor(struct uart_port *port, unsigned int baud, unsigned int quot, unsigned int quot_frac); int fsl8250_handle_irq(struct uart_port *port); +void serial8250_handle_irq_locked(struct uart_port *port, unsigned int iir); int serial8250_handle_irq(struct uart_port *port, unsigned int iir); u16 serial8250_rx_chars(struct uart_8250_port *up, u16 lsr); void serial8250_read_char(struct uart_8250_port *up, u16 lsr); -- 2.18.0.huawei.25
From: Jacques Nilo <jnilo@free.fr> mainline inclusion from mainline-v7.1-rc6 commit 71f42b2149a1307a97165b409493665579462ea0 category: bugfix bugzilla: https://atomgit.com/src-openeuler/kernel/issues/18269 CVE: CVE-2026-74653 Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?i... -------------------------------- serial8250_handle_irq() captures a SysRq character into port->sysrq_ch inside serial8250_handle_irq_locked() via uart_prepare_sysrq_char() (reached from serial8250_read_char()). Dispatch of that captured character to handle_sysrq() is expected to happen at port-unlock time, through uart_unlock_and_check_sysrq[_irqrestore](). After commit 8324a54f604d ("serial: 8250: Add serial8250_handle_irq_locked()") the function was reduced to a wrapper that takes the port lock via guard(uart_port_lock_irqsave) whose destructor is plain uart_port_unlock_irqrestore(). The sysrq-aware unlock helper is no longer called, so port->sysrq_ch is captured but never dispatched: BREAK + SysRq key is consumed silently. This was the very condition Johan Hovold's 853a9ae29e978 ("serial: 8250: fix handle_irq locking", 2021) introduced uart_unlock_and_check_sysrq_irqrestore() to address. Switch to the new guard(uart_port_lock_check_sysrq_irqsave), whose destructor is the sysrq-aware unlock helper, restoring the pre-split behaviour. Update the Context: comment on serial8250_handle_irq_locked() so future HW-specific 8250 wrappers know to use the same guard or the explicit sysrq-aware unlock. Verified on RTL8196E with CONFIG_MAGIC_SYSRQ_SERIAL=y: BREAK + 'h' on the console UART produces the SysRq help dump in dmesg and the brk counter in /proc/tty/driver/serial increments correctly. Fixes: 8324a54f604d ("serial: 8250: Add serial8250_handle_irq_locked()") Cc: stable@vger.kernel.org Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com> Signed-off-by: Jacques Nilo <jnilo@free.fr> Link: https://patch.msgid.link/52692ae6c3501f7940347cef364ad7fcacaab7e5.1778675349... Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Conflicts: drivers/tty/serial/8250/8250_port.c [There is no guard in 6.6. Restore it to the mothod of locking and unlocking.] Signed-off-by: Cai Xinchen <caixinchen1@huawei.com> --- drivers/tty/serial/8250/8250_port.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/tty/serial/8250/8250_port.c b/drivers/tty/serial/8250/8250_port.c index 04b1e3157dca..2af03919e3ea 100644 --- a/drivers/tty/serial/8250/8250_port.c +++ b/drivers/tty/serial/8250/8250_port.c @@ -1900,7 +1900,10 @@ static bool handle_rx_dma(struct uart_8250_port *up, unsigned int iir) } /* - * Context: port's lock must be held by the caller. + * Context: port's lock must be held by the caller. The caller must + * release it via guard(uart_port_lock_check_sysrq_irqsave) or + * uart_unlock_and_check_sysrq_irqrestore(), which captures SysRq + * character on unlock. */ void serial8250_handle_irq_locked(struct uart_port *port, unsigned int iir) { @@ -1957,7 +1960,7 @@ int serial8250_handle_irq(struct uart_port *port, unsigned int iir) uart_port_lock_irqsave(port, &flags); serial8250_handle_irq_locked(port, iir); - uart_port_unlock_irqrestore(port, flags); + uart_unlock_and_check_sysrq_irqrestore(port, flags); return 1; } -- 2.18.0.huawei.25
From: Ryan Wilbur <rwilbur633@gmail.com> mainline inclusion from mainline-v7.2-rc7 commit 1423415471274abda87024967d7fe2206ceee0ea category: bugfix bugzilla: https://atomgit.com/src-openeuler/kernel/issues/18269 CVE: CVE-2026-74653 Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?i... -------------------------------- The NXP LPC32xx UART (PORT_LPC3220) can latch an RX character-timeout interrupt while the RX FIFO is empty: IIR reports UART_IIR_RX_TIMEOUT (0x0c) but LSR.DR is clear. A character timeout is only cleared by reading RHR, but serial8250_rx_chars() reads RHR only when LSR.DR is set, so nothing ever clears the condition. The interrupt is level-triggered and re-fires immediately, so on a single-core ARM926 the resulting interrupt storm livelocks the CPU. It is reproducible when userspace repeatedly opens the front-panel port (ttyS1): serial8250_do_set_termios() re-enables interrupts on unlock and the handler then spins forever with iir=0xcc lsr=0x60 ier=0x05, tripping the soft-lockup detector in serial8250_handle_irq_locked(). LPC32xx has no dedicated 8250 glue driver, it's driven by the generic 8250_of. Add a hardware specific handle_irq for PORT_LPC3220, wired up in of_platform_serial_setup() the same way fsl8250_handle_irq is installed. The handler follows dw8250_handle_irq(): on an RX timeout with an empty FIFO (LSR.DR and LSR.BI clear) it does one throwaway RHR read to clear the condition, then calls serial8250_handle_irq_locked(). No real received data is ever discarded, and it is a no-op on healthy UARTs which never report a timeout with DR clear. This is the same class of bug already worked around in other 8250 drivers; see commit 424d79183af0 ("serial: 8250_dw: Avoid "too much work" from bogus rx timeout interrupt") which reports the identical iir=0xcc/lsr=0x60. See also UART_RX_TIMEOUT_QUIRK in 8250_omap, and the note in 8250_bcm7271. Cc: stable <stable@kernel.org> Assisted-by: Claude:Opus4.8 Signed-off-by: Ryan Wilbur <rwilbur633@gmail.com> Link: https://patch.msgid.link/20260730193920.28954-1-rwilbur633@gmail.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Conflicts: drivers/tty/serial/8250/8250_of.c [There is no guard(xxx) in 6.6. Restore it to the method of locking and unlocking. The commit cdd30ebb1b9f ("module: Convert symbol namespace to string literal") is not merged, thus MODULE_IMPORT_NS should not add "". Others are only context conflicts.] Signed-off-by: Cai Xinchen <caixinchen1@huawei.com> --- drivers/tty/serial/8250/8250_of.c | 44 +++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/drivers/tty/serial/8250/8250_of.c b/drivers/tty/serial/8250/8250_of.c index 51329625c48a..aec3cb0a3fb5 100644 --- a/drivers/tty/serial/8250/8250_of.c +++ b/drivers/tty/serial/8250/8250_of.c @@ -25,6 +25,46 @@ struct of_serial_info { int line; }; +static int lpc32xx_handle_irq(struct uart_port *port) +{ + struct uart_8250_port *up = up_to_u8250p(port); + unsigned int iir; + u16 status; + unsigned long flags; + + serial8250_rpm_get(up); + + iir = serial_port_in(port, UART_IIR); + if (iir & UART_IIR_NO_INT) { + serial8250_rpm_put(up); + return 0; + } + + uart_port_lock_irqsave(port, &flags); + + /* + * The LPC32xx UART can assert an RX character-timeout interrupt while + * the RX FIFO is empty: IIR reports UART_IIR_RX_TIMEOUT but LSR.DR is + * clear. The timeout is only cleared by reading RHR, but the core RX + * path skips that read when the FIFO is empty, so the level-triggered + * IRQ re-fires forever and livelocks this single-core SoC. Do one + * throwaway RHR read to clear it; a healthy UART never reports a + * timeout with DR/BI clear, so no received data is ever discarded. + */ + if ((iir & 0x3f) == UART_IIR_RX_TIMEOUT) { + status = serial_lsr_in(up); + if (!(status & (UART_LSR_DR | UART_LSR_BI))) + serial_port_in(port, UART_RX); + } + + serial8250_handle_irq_locked(port, iir); + + uart_unlock_and_check_sysrq_irqrestore(port, flags); + serial8250_rpm_put(up); + + return 1; +} + /* * Fill a struct uart_port for a given device node */ @@ -175,6 +215,9 @@ static int of_platform_serial_setup(struct platform_device *ofdev, if (ret) goto err_unprepare; break; + case PORT_LPC3220: + port->handle_irq = lpc32xx_handle_irq; + break; } if (IS_REACHABLE(CONFIG_SERIAL_8250_FSL) && @@ -354,6 +397,7 @@ static struct platform_driver of_platform_serial_driver = { module_platform_driver(of_platform_serial_driver); +MODULE_IMPORT_NS(SERIAL_8250); MODULE_AUTHOR("Arnd Bergmann <arnd@arndb.de>"); MODULE_LICENSE("GPL"); MODULE_DESCRIPTION("Serial Port driver for Open Firmware platform devices"); -- 2.18.0.huawei.25
participants (2)
-
Cai Xinchen -
patchwork bot