[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <871pkndqed.fsf@tarshish>
Date: Mon, 22 Dec 2025 07:41:46 +0200
From: Baruch Siach <baruch@...s.co.il>
To: Junrui Luo <moonafterrain@...look.com>
Cc: Greg Kroah-Hartman <gregkh@...uxfoundation.org>, Jiri Slaby
<jirislaby@...nel.org>, linux-kernel@...r.kernel.org,
linux-serial@...r.kernel.org, linux-arm-kernel@...ts.infradead.org,
Yuhao Jiang <danisjiang@...il.com>
Subject: Re: [PATCH] serial: digicolor: fix use-after-free on driver unbind
Hi Junrui,
On Mon, Dec 22 2025, Junrui Luo wrote:
> The digicolor_uart_console_write() function accesses the global
> digicolor_ports[] array to retrieve the uart port pointer, which
> can lead to a use-after-free if the console write occurs after
> the port has been removed via unbind.
>
> digicolor_uart_remove() leaves a dangling pointer in the array.
>
> Fix by clearing the array entry in digicolor_uart_remove() and
> adding a NULL check in digicolor_uart_console_write().
Thanks for the patch.
Is this .write/.remove callbacks race actually possible? Can you refer
me to similar fixes in other drivers?
> Reported-by: Yuhao Jiang <danisjiang@...il.com>
Where can I find this report?
Thanks,
baruch
> Reported-by: Junrui Luo <moonafterrain@...look.com>
> Fixes: 5930cb3511df ("serial: driver for Conexant Digicolor USART")
> Signed-off-by: Junrui Luo <moonafterrain@...look.com>
> ---
> drivers/tty/serial/digicolor-usart.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/drivers/tty/serial/digicolor-usart.c b/drivers/tty/serial/digicolor-usart.c
> index d2482df5cb9b..5861be2072c4 100644
> --- a/drivers/tty/serial/digicolor-usart.c
> +++ b/drivers/tty/serial/digicolor-usart.c
> @@ -397,6 +397,9 @@ static void digicolor_uart_console_write(struct console *co, const char *c,
> unsigned long flags;
> int locked = 1;
>
> + if (!port)
> + return;
> +
> if (oops_in_progress)
> locked = uart_port_trylock_irqsave(port, &flags);
> else
> @@ -508,6 +511,7 @@ static void digicolor_uart_remove(struct platform_device *pdev)
> struct uart_port *port = platform_get_drvdata(pdev);
>
> uart_remove_one_port(&digicolor_uart, port);
> + digicolor_ports[port->line] = NULL;
> }
>
> static const struct of_device_id digicolor_uart_dt_ids[] = {
>
> ---
> base-commit: ea1013c1539270e372fc99854bc6e4d94eaeff66
> change-id: 20251222-fixes-74e6b26513d1
>
> Best regards,
--
~. .~ Tk Open Systems
=}------------------------------------------------ooO--U--Ooo------------{=
- baruch@...s.co.il - tel: +972.52.368.4656, http://www.tkos.co.il -
Powered by blists - more mailing lists