From: sashiko-bot@kernel.org
To: "Adrian Ambrozewicz" <aambrozewicz@nvidia.com>
Cc: linux-usb@vger.kernel.org
Subject: Re: [PATCH 11/11] ipmi: Add NVIDIA LSTP IPMI BMC driver
Date: Mon, 12 Oct 2026 17:51:54 +0000 [thread overview]
Message-ID: <sashiko-outbox-168499@kernel.org> (raw)
In-Reply-To: <20261012-lstp-usb-adapter-v1-11-aambrozewicz@nvidia.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] devres: device mismatch in devm_add_action_or_reset causes UAF and resource leak
--
commit 9f3744092e4398b83c4dd08ac11a951e27142671
Author: Adrian Ambrozewicz <aambrozewicz@nvidia.com>
ipmi: Add NVIDIA LSTP IPMI BMC driver
This commit adds a BMC-side driver for the IPMI channels of NVIDIA LSTP USB
adapters. The adapter carries IPMI messages between the host and the BMC,
exposing each channel as an ipmi-lstp<n> character device.
> diff --git a/drivers/char/ipmi/ipmi-lstp.c b/drivers/char/ipmi/ipmi-lstp.c
> index 0000000000000..787d633d4ada7
> --- /dev/null
> +++ b/drivers/char/ipmi/ipmi-lstp.c
[ ... ]
> +static int lstp_ipmi_start(struct lstp_channel *ch, struct lstp_ipmi_ctx *ctx)
> +{
> + int ret = misc_register(&ctx->miscdev);
> +
> + if (ret) {
> + dev_err(ch->dev, "%s: ch_%d: Could not register miscdevice (%pe)\n", __func__,
> + ch->ch_id, ERR_PTR(ret));
> + return ret;
> + }
> +
> + ret = devm_add_action_or_reset(ch->dev, lstp_ipmi_stop_and_deregister, ctx);
[Severity: High]
Are these devres actions being attached to the correct device?
In an auxiliary driver, devres actions should typically be attached to the
device being probed (&auxdev->dev), not its parent. Here, the driver
incorrectly attaches its teardown action (lstp_ipmi_stop_and_deregister)
to the parent USB device (ch->dev).
If the auxiliary driver is unbound (for example, via rmmod), the driver core
cleans up actions attached to &auxdev->dev. Because this action is queued on
ch->dev, it will not execute and the miscdevice will remain registered.
When the module is unloaded, the dangling actions remain on the parent's
devres list. If userspace opens the lingering device node, or if the USB
device is later disconnected, the kernel will jump to unmapped module memory
and crash.
> + if (ret)
> + return ret;
> +
> + dev_info(ch->dev, "%s: ch_%d: Started as %s\n", __func__, ch->ch_id, ch->display_name);
> + return 0;
> +}
> +
> +static int lstp_ipmi_probe(struct auxiliary_device *auxdev, const struct auxiliary_device_id *id)
> +{
> + struct lstp_channel *ch = lstp_channel_from_auxdev(auxdev);
> + const struct lstp_channel_init_info *info = dev_get_platdata(&auxdev->dev);
> +
> + if (!info)
> + return -ENODEV;
> +
> + int ret = lstp_ipmi_init(ch, info);
> +
> + if (ret)
> + return ret;
> +
> + /* Booked first, so it unwinds after the node's deregister action. */
> + ret = devm_add_action_or_reset(ch->dev, lstp_ipmi_ctx_put, ch->priv);
[Severity: High]
Similar to the issue above, does this context put action also attach to the
wrong device?
By registering against ch->dev instead of &auxdev->dev, the context memory
will leak upon unbind because the driver core will not execute this cleanup
action.
Additionally, if misc_register() fails during probe, the devres unwind
targets &auxdev->dev, leaving the lstp_ipmi_ctx_put action queued on
ch->dev and leaking the context.
> + if (ret)
> + return ret;
> +
> + return lstp_ipmi_start(ch, ch->priv);
> +}
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261012-lstp-usb-adapter-v1-0-aambrozewicz@nvidia.com?part=11
next prev parent reply other threads:[~2026-10-12 17:51 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-12 17:35 [PATCH 00/11] Add NVIDIA LSTP USB adapter drivers Adrian Ambrozewicz
2026-10-12 17:35 ` [PATCH 01/11] dt-bindings: gpio: Add NVIDIA LSTP GPIO Adrian Ambrozewicz
2026-10-12 17:43 ` sashiko-bot
2026-10-13 6:09 ` Krzysztof Kozlowski
2026-10-12 17:36 ` [PATCH 02/11] dt-bindings: i2c: Add NVIDIA LSTP I2C Adrian Ambrozewicz
2026-10-12 17:41 ` sashiko-bot
2026-10-13 6:11 ` Krzysztof Kozlowski
2026-10-12 17:36 ` [PATCH 03/11] dt-bindings: spi: Add NVIDIA LSTP SPI Adrian Ambrozewicz
2026-10-12 17:46 ` sashiko-bot
2026-10-13 6:11 ` Krzysztof Kozlowski
2026-10-12 17:36 ` [PATCH 04/11] dt-bindings: usb: Add NVIDIA LSTP USB adapter Adrian Ambrozewicz
2026-10-12 17:47 ` sashiko-bot
2026-10-13 6:13 ` Krzysztof Kozlowski
2026-10-13 6:17 ` Krzysztof Kozlowski
2026-10-12 17:36 ` [PATCH 05/11] usb: misc: Add NVIDIA LSTP USB adapter driver Adrian Ambrozewicz
2026-10-12 17:51 ` sashiko-bot
2026-10-12 17:36 ` [PATCH 06/11] gpio: Add NVIDIA LSTP GPIO driver Adrian Ambrozewicz
2026-10-12 17:53 ` sashiko-bot
2026-10-12 17:36 ` [PATCH 07/11] leds: Add NVIDIA LSTP LED driver Adrian Ambrozewicz
2026-10-12 17:46 ` sashiko-bot
2026-10-12 17:36 ` [PATCH 08/11] i2c: Add NVIDIA LSTP I2C driver Adrian Ambrozewicz
2026-10-12 17:49 ` sashiko-bot
2026-10-12 17:36 ` [PATCH 09/11] spi: Add NVIDIA LSTP SPI driver Adrian Ambrozewicz
2026-10-12 17:45 ` sashiko-bot
2026-10-12 17:36 ` [PATCH 10/11] tty: Add NVIDIA LSTP UART driver Adrian Ambrozewicz
2026-10-12 17:50 ` sashiko-bot
2026-10-13 5:49 ` Jiri Slaby
2026-10-12 17:36 ` [PATCH 11/11] ipmi: Add NVIDIA LSTP IPMI BMC driver Adrian Ambrozewicz
2026-10-12 17:51 ` sashiko-bot [this message]
2026-10-12 21:10 ` Corey Minyard
2026-10-13 11:37 ` [PATCH 00/11] Add NVIDIA LSTP USB adapter drivers Greg Kroah-Hartman
2026-10-13 11:39 ` Greg Kroah-Hartman
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-168499@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=aambrozewicz@nvidia.com \
--cc=linux-usb@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;
as well as URLs for NNTP newsgroup(s).