From: sashiko-bot@kernel.org
To: "Dmitry Torokhov" <dmitry.torokhov@gmail.com>
Cc: dmitry.torokhov@gmail.com, linux-input@vger.kernel.org
Subject: Re: [PATCH 10/10] Input: synaptics-rmi4 - use __le16 for FIFO offset in F54
Date: Fri, 26 Jun 2026 05:33:58 +0000 [thread overview]
Message-ID: <20260626053359.39BF91F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260626051802.4033172-10-dmitry.torokhov@gmail.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] The struct f54_data is devm-allocated but embeds a struct video_device and sets its release callback to video_device_release_empty. This causes a Use-After-Free (UAF) upon driver unbind if userspace keeps the V4L2 file descriptor open.
--
commit e9522f5af1c14ea69a1ea7da84dfd2f3170f97d8
Author: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Input: synaptics-rmi4 - use __le16 for FIFO offset in F54
Instead of manually splitting the 16-bit offset into a 2-byte array,
use __le16 and cpu_to_le16() to serialize the FIFO offset in
rmi_f54_work(). This is cleaner and more portable.
> diff --git a/drivers/input/rmi4/rmi_f54.c b/drivers/input/rmi4/rmi_f54.c
> index 5d045ece3c2f2..3eeb189be18b3 100644
> --- a/drivers/input/rmi4/rmi_f54.c
> +++ b/drivers/input/rmi4/rmi_f54.c
[ ... ]
> @@ -597,12 +597,11 @@ static void rmi_f54_work(struct work_struct *work)
>
> for (size_t i = 0; i < report_size; i += F54_REPORT_DATA_SIZE) {
> size_t size = min_t(size_t, F54_REPORT_DATA_SIZE, report_size - i);
> + __le16 fifo = cpu_to_le16(i);
>
> - fifo[0] = i & 0xff;
> - fifo[1] = i >> 8;
> error = rmi_write_block(fn->rmi_dev,
> fn->fd.data_base_addr + F54_FIFO_OFFSET,
> - fifo, sizeof(fifo));
> + &fifo, sizeof(fifo));
[Severity: High]
This is a pre-existing issue, but I noticed a potential use-after-free
lifecycle bug related to how struct f54_data is managed.
The struct f54_data is devm-allocated in rmi_f54_probe():
f54 = devm_kzalloc(&fn->dev, sizeof(struct f54_data), GFP_KERNEL);
However, it embeds a struct video_device and sets its release callback to
video_device_release_empty. If userspace keeps the V4L2 file descriptor open
during driver unbind, devres will immediately free f54_data when
rmi_f54_remove() completes:
static void rmi_f54_remove(struct rmi_function *fn)
{
struct f54_data *f54 = dev_get_drvdata(&fn->dev);
video_unregister_device(&f54->vdev);
v4l2_device_unregister(&f54->v4l2);
cancel_delayed_work_sync(&f54->work);
destroy_workqueue(f54->workqueue);
}
Since rmi_f54_remove() doesn't wait for the video device to be fully
released (or synchronize with in-flight V4L2 ioctls holding f54->lock),
an active ioctl could sleep and wake up after the struct is freed.
For example, if VIDIOC_QBUF blocks in rmi_f54_buffer_queue():
if (!wait_for_completion_timeout(&f54->cmd_done,
msecs_to_jiffies(1000))) {
Could this wake up after the driver is unbound and access the freed
f54->data_mutex or f54->sequence?
Does this violate the V4L2 lifecycle contract, which requires that memory
backing a video_device must not be freed until the core invokes the .release
callback?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260626051802.4033172-1-dmitry.torokhov@gmail.com?part=10
next prev parent reply other threads:[~2026-06-26 5:33 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-26 5:17 [PATCH 01/10] Input: synaptics-rmi4 - fix F55 transmitter electrode count typo Dmitry Torokhov
2026-06-26 5:17 ` [PATCH 02/10] Input: synaptics-rmi4 - zero report size on F54 work error Dmitry Torokhov
2026-06-26 5:32 ` sashiko-bot
2026-06-26 5:17 ` [PATCH 03/10] Input: synaptics-rmi4 - bound the F54 report size to the allocated buffer Dmitry Torokhov
2026-06-26 5:31 ` sashiko-bot
2026-06-26 5:17 ` [PATCH 04/10] Input: synaptics-rmi4 - cancel delayed work on F54 remove Dmitry Torokhov
2026-06-26 5:28 ` sashiko-bot
2026-06-26 5:17 ` [PATCH 05/10] Input: synaptics-rmi4 - block s_input when F54 queue is busy Dmitry Torokhov
2026-06-26 5:27 ` sashiko-bot
2026-06-26 5:17 ` [PATCH 06/10] Input: synaptics-rmi4 - propagate F54 worker errors to V4L2 queue Dmitry Torokhov
2026-06-26 7:30 ` sashiko-bot
2026-06-26 5:17 ` [PATCH 07/10] Input: synaptics-rmi4 - check V4L2 buffer size in F54 queue Dmitry Torokhov
2026-06-26 5:31 ` sashiko-bot
2026-06-26 5:17 ` [PATCH 08/10] Input: synaptics-rmi4 - F54 style and typo fixes Dmitry Torokhov
2026-06-26 5:29 ` sashiko-bot
2026-06-26 5:17 ` [PATCH 09/10] Input: synaptics-rmi4 - change report_size to size_t in F54 Dmitry Torokhov
2026-06-26 5:29 ` sashiko-bot
2026-06-26 5:17 ` [PATCH 10/10] Input: synaptics-rmi4 - use __le16 for FIFO offset " Dmitry Torokhov
2026-06-26 5:33 ` sashiko-bot [this message]
2026-06-26 5:31 ` [PATCH 01/10] Input: synaptics-rmi4 - fix F55 transmitter electrode count typo 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=20260626053359.39BF91F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=dmitry.torokhov@gmail.com \
--cc=linux-input@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