From: sashiko-bot@kernel.org
To: "Kishore Batta" <kishore.batta@oss.qualcomm.com>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH v6 4/7] bus: mhi: Add QDU100 Sahara variant and firmware fallback
Date: Wed, 01 Jul 2026 10:53:14 +0000 [thread overview]
Message-ID: <20260701105315.46E501F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260701-sahara_protocol_new_v2-v6-4-3a78362c4741@oss.qualcomm.com>
Thank you for your contribution! Sashiko AI review found 5 potential issue(s) to consider:
New issues:
- [Medium] The firmware fallback mechanism inadvertently changes the behavior for existing AIC100 and AIC200 devices, bypassing their explicit allowlist and contradicting the commit message.
- [Low] The `dev_err` statement in the fallback error path uses a signed format specifier `%d` to print an unsigned 32-bit integer.
Pre-existing issues:
- [High] A malicious or malfunctioning device can trigger a NULL pointer dereference or Use-After-Free by requesting an image transfer with `image_id` equal to `SAHARA_IMAGE_ID_NONE` (0xFFFFFFFF).
- [High] Missing cancellation of `read_data_work` during driver removal leads to a Use-After-Free of `context` and `context->firmware`.
- [High] Lockless concurrency between `fw_work` and `read_data_work` allows a device-triggered Use-After-Free during firmware streaming.
--
commit e80f9e2e7047bfa82528957f04343840159ae175
Author: Kishore Batta <kishore.batta@oss.qualcomm.com>
bus: mhi: Add QDU100 Sahara variant and firmware fallback
Extend the probe time variant selection to match the SAHARA MHI channel for
QDU100 devices. Add a firmware lookup fallback to provision images dynamically
if they aren't explicitly listed in the image table.
> diff --git a/drivers/bus/mhi/host/clients/sahara/sahara.c b/drivers/bus/mhi/host/clients/sahara/sahara.c
> index e339c67e236af..9adbd84859073 100644
> --- a/drivers/bus/mhi/host/clients/sahara/sahara.c
> +++ b/drivers/bus/mhi/host/clients/sahara/sahara.c
> @@ -189,6 +189,7 @@ static bool is_streaming(struct sahara_context *context)
>
> static int sahara_find_image(struct sahara_context *context, u32 image_id)
> {
> + char *fw_path;
> int ret;
>
> if (image_id == context->active_image_id)
> return 0;
[Severity: High]
This is a pre-existing issue, but can a malicious or malfunctioning device
trigger a NULL pointer dereference or use-after-free here?
If a device requests an image transfer with image_id equal to
SAHARA_IMAGE_ID_NONE (0xFFFFFFFF), context->active_image_id is initialized and
reset to this value. sahara_find_image() would return success (0) without
acquiring firmware.
Later, sahara_read_data() unconditionally dereferences context->firmware->size,
which would be NULL or a dangling pointer.
[ ... ]
> @@ -201,8 +202,28 @@ static int sahara_find_image(struct sahara_context *context, u32 image_id)
> }
>
> if (image_id >= context->table_size || !context->image_table[image_id]) {
> - dev_err(&context->mhi_dev->dev, "request for unknown image: %d\n", image_id);
> - return -EINVAL;
> + if (!context->fw_folder) {
> + dev_err(&context->mhi_dev->dev,
> + "Request for unknown image: %u (no fw folder)\n", image_id);
> + return -EINVAL;
> + }
[Severity: Medium]
The commit message states this change does not affect behavior for existing
AIC100 and AIC200 devices. However, legacy AIC devices populate fw_folder at
probe time.
Since this check relies on !context->fw_folder instead of matching against the
SAHARA channel, will legacy AIC devices fall through to the VFS lookup via
firmware_request_nowarn() instead of immediately returning -EINVAL?
> +
> + fw_path = kasprintf(GFP_KERNEL, "qcom/%s/%u",
> + context->fw_folder, image_id);
> + if (!fw_path)
> + return -ENOMEM;
> +
> + ret = firmware_request_nowarn(&context->firmware,
> + fw_path,
> + &context->mhi_dev->dev);
> + kfree(fw_path);
> + if (ret) {
> + dev_err(&context->mhi_dev->dev,
> + "request for unknown image: %d\n", image_id);
[Severity: Low]
Is %d the correct format specifier here? image_id is a u32, so if the
requested ID is greater than INT_MAX, it will be printed as a negative number.
> + return -EINVAL;
> + }
> + context->active_image_id = image_id;
> + return 0;
> }
[Severity: High]
This is a pre-existing issue, but does device teardown systematically omit
canceling read_data_work?
When the driver is unbound, sahara_mhi_remove() calls cancel_work_sync() for
fw_work and dump_work, but fails to cancel read_data_work. If read_data_work
is pending or executing, it can run after remove() returns, leading to a
use-after-free of the devres-managed context.
[Severity: High]
This is a pre-existing issue, but is there lockless concurrency between
fw_work and read_data_work that allows a device-triggered use-after-free?
During firmware streaming, sahara_read_data() schedules read_data_work. If a
device sends a SAHARA_END_OF_IMAGE_CMD immediately after a read request, the
command is processed by fw_work which calls sahara_release_image() to free
context->firmware.
Because these are independent work items without synchronization, could an
untrusted MHI device deliberately race the EOI command against the executing
streaming task?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260701-sahara_protocol_new_v2-v6-0-3a78362c4741@oss.qualcomm.com?part=4
next prev parent reply other threads:[~2026-07-01 10:53 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-01 10:37 [PATCH v6 0/7] Qualcomm Sahara protocol enhancements Kishore Batta
2026-07-01 10:37 ` [PATCH v6 1/7] Add documentation for Sahara protocol Kishore Batta
2026-07-01 10:42 ` sashiko-bot
2026-07-08 4:46 ` Randy Dunlap
2026-07-13 7:20 ` Kishore Batta
2026-07-01 10:37 ` [PATCH v6 2/7] bus: mhi: Move Sahara protocol driver under MHI host client drivers Kishore Batta
2026-07-01 10:50 ` sashiko-bot
2026-07-01 10:37 ` [PATCH v6 3/7] bus: mhi: Centralize Sahara firmware image table selection at probe time Kishore Batta
2026-07-01 10:47 ` sashiko-bot
2026-07-01 10:37 ` [PATCH v6 4/7] bus: mhi: Add QDU100 Sahara variant and firmware fallback Kishore Batta
2026-07-01 10:53 ` sashiko-bot [this message]
2026-07-09 6:19 ` Manivannan Sadhasivam
2026-07-13 7:25 ` Kishore Batta
2026-07-13 17:11 ` Manivannan Sadhasivam
2026-07-13 14:16 ` Kishore Batta
2026-07-13 16:19 ` Manivannan Sadhasivam
2026-07-01 10:37 ` [PATCH v6 5/7] bus: mhi: Load DDR training data using device serial number Kishore Batta
2026-07-01 10:57 ` sashiko-bot
2026-07-09 6:21 ` Manivannan Sadhasivam
2026-07-13 7:27 ` Kishore Batta
2026-07-01 10:37 ` [PATCH v6 6/7] bus: mhi: Capture DDR training data via command mode Kishore Batta
2026-07-01 10:51 ` sashiko-bot
2026-07-01 10:37 ` [PATCH v6 7/7] bus: mhi: Expose DDR training data via controller sysfs Kishore Batta
2026-07-01 10:52 ` sashiko-bot
2026-07-09 6:57 ` Manivannan Sadhasivam
2026-07-13 7:30 ` Kishore Batta
2026-07-13 17:08 ` Manivannan Sadhasivam
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=20260701105315.46E501F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=kishore.batta@oss.qualcomm.com \
--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.