From: sashiko-bot@kernel.org
To: "Guangshuo Li" <liguangshuo@mail.sdu.edu.cn>
Cc: linux-serial@vger.kernel.org
Subject: Re: [PATCH] serial: 8250_aspeed_vuart: Fix potential stale port on probe failure
Date: Mon, 16 Nov 2026 14:39:15 +0000 [thread overview]
Message-ID: <sashiko-outbox-217183@kernel.org> (raw)
In-Reply-To: <20261116-c29ba55625-serial-aspeed@mail.sdu.edu.cn>
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_aspeed_vuart: use-after-free in
aspeed_vuart_remove() [1]
--
commit 4eac67f7d5031d7988614ed386938a68b8050e5b
Author: Guangshuo Li <liguangshuo@mail.sdu.edu.cn>
serial: 8250_aspeed_vuart: Fix potential stale port on probe failure
This commit disables the VUART, shuts down its unthrottle timer, and
unregisters the 8250 port when LPC configuration fails during probe.
> diff --git a/drivers/tty/serial/8250/8250_aspeed_vuart.c b/drivers/tty/serial/8250/8250_aspeed_vuart.c
> index c8dc87f6886c1..2cd1c9146ec89 100644
> --- a/drivers/tty/serial/8250/8250_aspeed_vuart.c
> +++ b/drivers/tty/serial/8250/8250_aspeed_vuart.c
[ ... ]
> @@ -543,6 +543,10 @@ static int aspeed_vuart_probe(struct platform_device *pdev)
>
> return 0;
>
> +err_unregister_port:
> + aspeed_vuart_set_enabled(vuart, false);
> + timer_shutdown_sync(&vuart->unthrottle_timer);
> + serial8250_unregister_port(vuart->port);
[Severity: Critical]
This problem wasn't introduced by this patch, but can [1]
aspeed_vuart_remove() cause a use-after-free on vuart when
unthrottle_timer is re-armed during removal?
drivers/tty/serial/8250/8250_aspeed_vuart.c:aspeed_vuart_remove() {
struct aspeed_vuart *vuart = platform_get_drvdata(pdev);
timer_delete_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);
}
Because aspeed_vuart_remove() calls timer_delete_sync() instead of
timer_shutdown_sync() before serial8250_unregister_port(), a UART
interrupt arriving while the TTY flip buffers are full can re-arm
vuart->unthrottle_timer before the port is unregistered:
CPU0 CPU1
aspeed_vuart_remove()
timer_delete_sync(&vuart->unthrottle_timer)
aspeed_vuart_handle_irq()
if (!space)
mod_timer(&vuart->unthrottle_timer, ...)
serial8250_unregister_port(...)
// vuart freed by devres on return
aspeed_vuart_unthrottle_exp()
<-- use-after-free
Unregistering the port before stopping the timer, or using
timer_shutdown_sync() as this patch does on the probe error path, would
prevent the timer from being re-armed.
[1] https://sashiko.dev/#/bug/linux-2b3eb48a-af6f-4ebd-a642-413d2498b067
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261116-c29ba55625-serial-aspeed@mail.sdu.edu.cn?part=1
prev parent reply other threads:[~2026-11-16 14:39 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-16 14:24 [PATCH] serial: 8250_aspeed_vuart: Fix potential stale port on probe failure Guangshuo Li
2026-11-16 14:39 ` 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-217183@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=liguangshuo@mail.sdu.edu.cn \
--cc=linux-serial@vger.kernel.org \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox