All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Myeonghun Pak" <mhun512@gmail.com>
Cc: linux-serial@vger.kernel.org
Subject: Re: [PATCH] serial: 8250_aspeed_vuart: shut down the unthrottle timer on removal
Date: Thu, 12 Nov 2026 07:15:15 +0000	[thread overview]
Message-ID: <sashiko-outbox-210574@kernel.org> (raw)
In-Reply-To: <20261112070357.38870-1-mhun512@gmail.com>

Thank you for your contribution! Sashiko AI review found no new issues
in this patch, but noticed 1 related pre-existing issue it does not
introduce:
- [Critical] serial: 8250: use-after-free and port leaks on probe error
  paths [1]
--

commit afd3348a7cc94ca4f33ad325f21afb53b427217e
Author: Myeonghun Pak <mhun512@gmail.com>

serial: 8250_aspeed_vuart: shut down the unthrottle timer on removal

This commit replaces timer_delete_sync() with timer_shutdown_sync() in
aspeed_vuart_remove() to prevent unthrottle_timer from being re-armed by
an interrupt before the port is unregistered.

> diff --git a/drivers/tty/serial/8250/8250_aspeed_vuart.c b/drivers/tty/serial/8250/8250_aspeed_vuart.c
> index 452bef82bec2a..0776675b83823 100644
> --- a/drivers/tty/serial/8250/8250_aspeed_vuart.c
> +++ b/drivers/tty/serial/8250/8250_aspeed_vuart.c
> @@ -552,7 +552,7 @@ static void aspeed_vuart_remove(struct platform_device *pdev)
>  {
>  	struct aspeed_vuart *vuart = platform_get_drvdata(pdev);
>  
> -	timer_delete_sync(&vuart->unthrottle_timer);
> +	timer_shutdown_sync(&vuart->unthrottle_timer);
>  	aspeed_vuart_set_enabled(vuart, false);
>  	serial8250_unregister_port(vuart->port);
>  	sysfs_remove_group(&vuart->dev->kobj, &aspeed_vuart_attr_group);

[Severity: Critical]
This problem wasn't introduced by this patch, but does the error path in
aspeed_vuart_probe() leave the port registered [1] and cause a
use-after-free of vuart?

drivers/tty/serial/8250/8250_aspeed_vuart.c:aspeed_vuart_probe() {
	...
	struct uart_8250_port *uport = serial8250_register_8250_port(&port);
	if (IS_ERR(uport)) {
		rc = PTR_ERR(uport);
		goto err_sysfs_remove;
	}
	...
	rc = aspeed_vuart_set_lpc_address(vuart, prop);
	if (rc < 0) {
		dev_err_probe(dev, rc, "invalid value in aspeed,lpc-io-reg property\n");
		goto err_sysfs_remove;
	}
	...
err_sysfs_remove:
	sysfs_remove_group(&vuart->dev->kobj, &aspeed_vuart_attr_group);
	return rc;
}

When aspeed_vuart_set_lpc_address() or a later step fails after
serial8250_register_8250_port(), err_sysfs_remove returns without calling
serial8250_unregister_port().  The driver core then frees the
devm-allocated vuart while the 8250 core still holds port.private_data
pointing to it, so a later interrupt or TTY access dereferences freed
memory.

[1] https://sashiko.dev/#/bug/linux-99bf5468-4b0d-497a-8419-674f926b3cdb

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261112070357.38870-1-mhun512@gmail.com?part=1

      reply	other threads:[~2026-11-12  7:15 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-12  7:03 [PATCH] serial: 8250_aspeed_vuart: shut down the unthrottle timer on removal Myeonghun Pak
2026-11-12  7:15 ` sashiko-bot [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=sashiko-outbox-210574@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=linux-serial@vger.kernel.org \
    --cc=mhun512@gmail.com \
    --cc=sashiko-reviews@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.