All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Grégoire Layet" <gregoire.layet@9elements.com>
Cc: lee@kernel.org, devicetree@vger.kernel.org, robh@kernel.org,
	mfd@lists.linux.dev, conor+dt@kernel.org
Subject: Re: [PATCH v5 2/6] serial: 8250_aspeed_vuart: add aspeed,ast2600-vuart compatible string
Date: Wed, 05 Aug 2026 12:31:04 +0000	[thread overview]
Message-ID: <20260805123105.42E0E1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <56aa0a5e26ea76e4f9a27ed059d2b05bec9cffa5.1785932211.git.gregoire.layet@9elements.com>

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

Pre-existing issues:
- [High] Probe error paths leak the registered 8250 port and timer, leading to a use-after-free when devres cleans up.
- [High] Early sysfs exposure in probe allows userspace to trigger a NULL pointer dereference before drvdata is set.
- [High] Late sysfs removal during device remove allows userspace to access unmapped IO memory.
--

--- Patch [2]: [PATCH v5 2/6] serial: 8250_aspeed_vuart: add aspeed,ast2600-vuart compatible string ---
commit 513026908b64cd69b7d61f618f21a1466256a146
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 adding this compatible string
exposes the AST2600 device to a pre-existing resource leak in the driver's
probe error path:

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;
}

The err_sysfs_remove error path fails to call serial8250_unregister_port()
and timer_delete_sync() before returning an error, leaking resources that hold
a dangling pointer to the devres-freed vuart structure.

Could this lead to a use-after-free when devres cleans up?

[Severity: High]
This is also a pre-existing issue, but there is a race condition with early
sysfs exposure during probe:

drivers/tty/serial/8250/8250_aspeed_vuart.c:aspeed_vuart_probe() {
    ...
	rc = sysfs_create_group(&vuart->dev->kobj, &aspeed_vuart_attr_group);
    ...
	platform_set_drvdata(pdev, vuart);
    ...
}

The sysfs group is created and exposed to userspace early in the probe
function, creating a race window before platform_set_drvdata() is called at
the end.

If userspace reads a sysfs attribute (like sirq) during this window, the
handler will call dev_get_drvdata() and receive NULL. Can this allow
userspace to trigger a NULL pointer dereference before drvdata is set?

[Severity: High]
This is a pre-existing issue as well, but there appears to be a use-after-unmap
vulnerability in the remove function:

drivers/tty/serial/8250/8250_aspeed_vuart.c:aspeed_vuart_remove() {
    ...
	serial8250_unregister_port(vuart->line);
	sysfs_remove_group(&vuart->dev->kobj, &aspeed_vuart_attr_group);
}

The underlying 8250 port is unregistered and unmapped before the sysfs
interface is removed.

If userspace accesses a sysfs attribute concurrently in the window before the
sysfs group is removed, can this result in an access violation on the now
unmapped vuart->port->port.membase?

>  	{ },
>  };
>  MODULE_DEVICE_TABLE(of, aspeed_vuart_table);

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

  reply	other threads:[~2026-08-05 12:31 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-05 12:19 [PATCH v5 0/6] soc: aspeed: Add BMC and host driver for PCIe BMC device Grégoire Layet
2026-08-05 12:19 ` [PATCH v5 1/6] dt-bindings: serial: 8250: aspeed: add ast2600 and aspeed,vuart-over-pci Grégoire Layet
2026-08-05 12:25   ` sashiko-bot
2026-08-07  7:23   ` Krzysztof Kozlowski
2026-08-05 12:19 ` [PATCH v5 2/6] serial: 8250_aspeed_vuart: add aspeed,ast2600-vuart compatible string Grégoire Layet
2026-08-05 12:31   ` sashiko-bot [this message]
2026-08-07  8:37   ` Tan Siewert
2026-08-05 12:19 ` [PATCH v5 3/6] serial: 8250_aspeed_vuart: add VUART over PCI Grégoire Layet
2026-08-05 12:33   ` sashiko-bot
2026-08-07  8:37   ` Tan Siewert
2026-08-05 12:19 ` [PATCH v5 4/6] soc: mfd: add ASPEED AST2600 PCIe BMC device driver Grégoire Layet
2026-08-05 12:30   ` sashiko-bot
2026-08-07  8:37   ` Tan Siewert
2026-08-10 10:36     ` Grégoire Layet
2026-08-05 12:19 ` [PATCH v5 5/6] ARM: dts: aspeed: g6: Change vuart compatible string for ast2600 Grégoire Layet
2026-08-05 12:27   ` sashiko-bot
2026-08-07  8:37   ` Tan Siewert
2026-08-05 12:19 ` [PATCH v5 6/6] ARM: dts: aspeed: g6: add aspeed,vuart-over-pci prop to vuart3 and 4 Grégoire Layet
2026-08-05 12:30   ` sashiko-bot
2026-08-07  8:37   ` Tan Siewert

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=20260805123105.42E0E1F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=gregoire.layet@9elements.com \
    --cc=lee@kernel.org \
    --cc=mfd@lists.linux.dev \
    --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 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.