Linux Serial subsystem development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "ChunAn Wu" <an.wu@canonical.com>
Cc: linux-serial@vger.kernel.org
Subject: Re: [PATCH v4 2/3] platform/x86: dell-uart-backlight: Bind through normal serdev matching
Date: Sat, 24 Oct 2026 04:02:11 +0000	[thread overview]
Message-ID: <sashiko-outbox-183537@kernel.org> (raw)
In-Reply-To: <20261024035011.2712103-1-an.wu@canonical.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] platform/x86: dell-uart-backlight: type confusion in serdev_device_match()
--

commit 845cea88ea8fd97f6d009ac4a558f36871acb863
Author: ChunAn Wu <an.wu@canonical.com>

platform/x86: dell-uart-backlight: Bind through normal serdev matching

This commit switches the dell-uart-backlight driver from manually binding
its serdev client via device_driver_attach() to passing a modalias to
serdev_device_add() and matching via a serdev_device_id table.

> diff --git a/drivers/platform/x86/dell/dell-uart-backlight.c b/drivers/platform/x86/dell/dell-uart-backlight.c
> index f323a667dc2d2..9b8ef91bb0a20 100644
> --- a/drivers/platform/x86/dell/dell-uart-backlight.c
> +++ b/drivers/platform/x86/dell/dell-uart-backlight.c
> @@ -325,11 +325,17 @@ static int dell_uart_bl_serdev_probe(struct serdev_device *serdev)
>  	return PTR_ERR_OR_ZERO(dell_bl->bl);
>  }
>  
> +static const struct serdev_device_id dell_uart_bl_serdev_id[] = {
> +	{ KBUILD_MODNAME },
> +	{ }
> +};
> +
>  static struct serdev_device_driver dell_uart_bl_serdev_driver = {
>  	.probe = dell_uart_bl_serdev_probe,
>  	.driver = {
>  		.name = KBUILD_MODNAME,
>  	},
> +	.id_table = dell_uart_bl_serdev_id,
>  };

[Severity: High]
Does adding id_table to dell_uart_bl_serdev_driver trigger a type confusion
and out-of-bounds read in serdev_device_match() when
dell_uart_bl_pdev_probe() calls serdev_device_driver_register()?

Both struct serdev_controller and struct serdev_device are registered on
serdev_bus_type:

drivers/tty/serdev/core.c:serdev_controller_alloc() {
	...
	device_initialize(&ctrl->dev);
	ctrl->dev.type = &serdev_ctrl_type;
	ctrl->dev.bus = &serdev_bus_type;
	ctrl->dev.parent = parent;
	ctrl->host = host;
	device_set_node(&ctrl->dev, dev_fwnode(host));
	...
}

Earlier in the series, commit 1b3d9973e0d0 ("serdev: handle devices without
an ACPI or device tree node") removed the is_serdev_device(dev) check from
serdev_device_match(), leaving an unconditional cast via to_serdev_device():

drivers/tty/serdev/core.c:serdev_device_match() {
	const struct serdev_device *serdev = to_serdev_device(dev);
	const struct serdev_device_driver *sdrv = to_serdev_device_driver(drv);

	if (acpi_driver_match_device(dev, drv))
		return 1;

	if (of_driver_match_device(dev, drv))
		return 1;

	return !!serdev_match_id(sdrv->id_table, serdev->modalias);
}

When dell_uart_bl_pdev_probe() calls:

  serdev_device_driver_register(&dell_uart_bl_serdev_driver)
    -> driver_register()
      -> bus_add_driver()
        -> driver_attach()
          -> serdev_device_match()

the driver core iterates over every device on serdev_bus_type, including
the struct serdev_controller instance ("serial0").

Because dell_uart_bl_serdev_driver has no ACPI or OF match table and sets a
non-NULL id_table, serdev_device_match() reaches
serdev_match_id(sdrv->id_table, serdev->modalias) with serdev pointing to a
struct serdev_controller.

In struct serdev_device, modalias is at offset sizeof(struct device) + 4
and is 40 bytes long. In struct serdev_controller, that offset overlaps
struct device *host, unsigned int nr, struct serdev_device *serdev,
const struct serdev_controller_ops *ops, and extends 12 bytes past the end
of struct serdev_controller, passing those bytes into strcmp(modalias,
id->name) in serdev_match_id().

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261024022930.2704030-1-an.wu@canonical.com?part=2

  reply	other threads:[~2026-10-24  4:02 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-24  2:29 [PATCH v4 0/3] serdev: handle devices without an ACPI or device tree node ChunAn Wu
2026-10-24  2:29 ` [PATCH v4 1/3] " ChunAn Wu
2026-10-24  4:09   ` sashiko-bot
2026-10-24  2:29 ` [PATCH v4] platform/x86: dell-uart-backlight: Bind through normal serdev matching ChunAn Wu
2026-10-24  2:35   ` sashiko-bot
2026-10-24 11:59   ` kernel test robot
2026-10-24 12:03     ` Markus Probst
2026-10-24 17:42   ` kernel test robot
2026-10-24  2:29 ` [PATCH v4 3/3] platform/x86: lenovo-yoga-tab2-pro-1380-fastcharger: " ChunAn Wu
2026-10-24  4:07   ` sashiko-bot
2026-10-24  3:50 ` [PATCH v4 2/3] platform/x86: dell-uart-backlight: " ChunAn Wu
2026-10-24  4:02   ` sashiko-bot [this message]
2026-10-24  8:40 ` [PATCH v4 0/3] serdev: handle devices without an ACPI or device tree node An Wu
2026-10-24 11:48   ` Markus Probst

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-183537@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=an.wu@canonical.com \
    --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