lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID:
 <SYBPR01MB7881835C63D3E6F5F4BA81FFAFB2A@SYBPR01MB7881.ausprd01.prod.outlook.com>
Date: Thu, 25 Dec 2025 04:23:01 +0000
From: Junrui Luo <moonafterrain@...look.com>
To: Greg Kroah-Hartman <gregkh@...uxfoundation.org>, Baruch Siach
	<baruch@...s.co.il>
CC: Jiri Slaby <jirislaby@...nel.org>, "linux-kernel@...r.kernel.org"
	<linux-kernel@...r.kernel.org>, "linux-serial@...r.kernel.org"
	<linux-serial@...r.kernel.org>, "linux-arm-kernel@...ts.infradead.org"
	<linux-arm-kernel@...ts.infradead.org>, Yuhao Jiang <danisjiang@...il.com>
Subject: Re: [PATCH] serial: digicolor: fix use-after-free on driver unbind

On Mon, Dec 22, 2025 at 07:22:14AM +0100, Greg Kroah-Hartman wrote:
> On Mon, Dec 22, 2025 at 12:55:02PM +0800, 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().
> > 
> > Reported-by: Yuhao Jiang <danisjiang@...il.com>
> > 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;
> > +
> 
> What prevents port from changing right after you tested this?

Thanks for the review. You're right that there's a potentially race window
between the NULL check and port usage. I found that several drivers handle
this the same way:

- meson_uart: has NULL check in console_write, clears array in remove
- sprd_serial: Fixed similar issue in commit 99038fe75afa

This check does not fully eliminate the race window, and adding stronger
synchronization in the console_write() path may have non-trivial cost. I
am willing to adopt an alternative if one is preferred.

> 
> And who is calling unbind on a port?  Why?  That's a debuggging thing
> that a developer could do, it should not be part of any normal system
> operation.

Although this may most commonly occur in development or testing
environments, it is still a legitimate bug that should be fixed.

In addition, unbind may also occur in:

- Some embedded systems using runtime device tree overlays
- Certain virtualization scenarios with device passthrough

Though these are uncommon.

thanks,
Junrui Luo

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ