Devicetree
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Grégoire Layet" <gregoire.layet@9elements.com>
Cc: robh@kernel.org, devicetree@vger.kernel.org, conor+dt@kernel.org
Subject: Re: [PATCH v4 3/7] serial: 8250_aspeed_vuart: add aspeed,ast2600-vuart compatible string
Date: Wed, 08 Jul 2026 15:49:46 +0000	[thread overview]
Message-ID: <20260708154947.33C5E1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <3598f3d668717082adbffa5179b4afbe39b2a946.1783524645.git.gregoire.layet@9elements.com>

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:

Pre-existing issues:
- [High] Error paths in `aspeed_vuart_probe()` after serial port registration fail to unregister the port, leading to a Use-After-Free vulnerability.
- [High] Incorrect teardown ordering in `aspeed_vuart_remove()` allows the unthrottle timer to be re-armed after it is deleted, leading to a Use-After-Free vulnerability.
--

--- Patch [3]: [PATCH v4 3/7] serial: 8250_aspeed_vuart: add aspeed,ast2600-vuart compatible string ---
commit be545f82b6eac2794c78d897d8e0ac9945c563d1
Author: Grégoire Layet <gregoire.layet@9elements.com>

serial: 8250_aspeed_vuart: add aspeed,ast2600-vuart compatible string
    
Make the driver compatible with the ast2600-vuart.
Enable specific configuration for the AST2600.

> diff --git a/drivers/tty/serial/8250/8250_aspeed_vuart.c b/drivers/tty/serial/8250/8250_aspeed_vuart.c
> index 26fc0464f1cc2..6afa2f4057e1b 100644
> --- a/drivers/tty/serial/8250/8250_aspeed_vuart.c
> +++ b/drivers/tty/serial/8250/8250_aspeed_vuart.c
> @@ -560,6 +560,7 @@ static void aspeed_vuart_remove(struct platform_device *pdev)
>  static const struct of_device_id aspeed_vuart_table[] = {
>  	{ .compatible = "aspeed,ast2400-vuart" },
>  	{ .compatible = "aspeed,ast2500-vuart" },
> +	{ .compatible = "aspeed,ast2600-vuart" },
>  	{ },
>  };

[Severity: High]
This isn't a bug introduced by this patch, but the error paths in
aspeed_vuart_probe() after serial port registration fail to unregister
the port.

If an initialization step fails after serial8250_register_8250_port() (e.g.
if aspeed_vuart_set_lpc_address() returns -EINVAL), the code jumps here:

drivers/tty/serial/8250/8250_aspeed_vuart.c:aspeed_vuart_probe() {
    ...
err_sysfs_remove:
	sysfs_remove_group(&vuart->dev->kobj, &aspeed_vuart_attr_group);
	return rc;
}

This error path omits serial8250_unregister_port(vuart->line) and
timer_delete_sync(&vuart->unthrottle_timer), leaking the registered port.

Since the vuart struct is then freed by devres, if a user opens the leaked
serial port, aspeed_vuart_startup() will dereference the freed vuart struct.

Should the error path unregister the port and delete the timer?


[Severity: High]
This isn't a bug introduced by this patch, but there is an incorrect teardown
ordering in aspeed_vuart_remove() that allows the unthrottle timer to be
re-armed after it is deleted.

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->line);
	sysfs_remove_group(&vuart->dev->kobj, &aspeed_vuart_attr_group);
}

Because timer_delete_sync() is invoked before serial8250_unregister_port(),
the UART and its IRQ are still fully active. An incoming interrupt can trigger
aspeed_vuart_handle_irq(), and if the tty buffer is full, re-arm the timer
via mod_timer(). 

When the driver removal completes, the vuart struct is freed by devres. When
the re-armed timer fires, aspeed_vuart_unthrottle_exp() will dereference the
freed vuart struct.

Could the timer be deleted after unregistering the serial port to prevent
it from being re-armed?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/cover.1783524645.git.gregoire.layet@9elements.com?part=3

  reply	other threads:[~2026-07-08 15:49 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-08 15:35 [PATCH v4 0/7] soc: aspeed: Add BMC and host driver for PCIe BMC device Grégoire Layet
2026-07-08 15:35 ` [PATCH v4 1/7] dt-bindings: serial: 8250: aspeed: add compatible string for ast2600 Grégoire Layet
2026-07-08 16:38   ` Andrew Lunn
2026-07-09  8:50   ` Krzysztof Kozlowski
2026-07-09 14:21     ` Grégoire Layet
2026-07-08 15:35 ` [PATCH v4 2/7] dt-bindings: serial: 8250: aspeed: add aspeed,vuart-over-pci bool prop Grégoire Layet
2026-07-08 15:45   ` sashiko-bot
2026-07-09  8:54   ` Krzysztof Kozlowski
2026-07-08 15:35 ` [PATCH v4 3/7] serial: 8250_aspeed_vuart: add aspeed,ast2600-vuart compatible string Grégoire Layet
2026-07-08 15:49   ` sashiko-bot [this message]
2026-07-08 15:35 ` [PATCH v4 4/7] serial: 8250_aspeed_vuart: add VUART over PCI Grégoire Layet
2026-07-08 15:47   ` sashiko-bot
2026-07-08 16:46   ` Andrew Lunn
2026-07-09  5:18     ` Jiri Slaby
2026-07-09  5:17   ` Jiri Slaby
2026-07-08 15:35 ` [PATCH v4 5/7] soc: aspeed: add host-side PCIe BMC device driver Grégoire Layet
2026-07-08 15:48   ` sashiko-bot
2026-07-09  5:27   ` Jiri Slaby
2026-07-08 15:35 ` [PATCH v4 6/7] ARM: dts: aspeed: g6: Change vuart compatible string for ast2600 Grégoire Layet
2026-07-08 15:35 ` [PATCH v4 7/7] ARM: dts: aspeed: g6: add aspeed,vuart-over-pci prop to vuart3 and 4 Grégoire Layet
2026-07-08 15:49   ` sashiko-bot

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=20260708154947.33C5E1F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=gregoire.layet@9elements.com \
    --cc=robh@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