From: sashiko-bot@kernel.org
To: "Wei Jie LAW" <98lawweijie@gmail.com>
Cc: dmitry.torokhov@gmail.com, linux-input@vger.kernel.org
Subject: Re: [PATCH v3 2/2] Input: synaptics-rmi4 - reject a PDT that grows between scans
Date: Tue, 25 Aug 2026 06:21:50 +0000 [thread overview]
Message-ID: <20260825062151.1206E1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260825061027.105062-3-98lawweijie@gmail.com>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
Pre-existing issues:
- [High] If rmi_f34_create_sysfs() fails during probe, the error path skips function cleanup, leading to a use-after-free of the driver's private data and leaking registered devices.
- [High] Concurrent sysfs writes to the `update_fw` attribute execute firmware updates without serialization, leading to list corruption, data races, and potential double-frees.
--
--- Patch [2]: [PATCH v3 2/2] Input: synaptics-rmi4 - reject a PDT that grows between scans ---
commit 2fad09409bb9588b1763723ac01bfc86aa11a46f
Author: Wei Jie Law <98lawweijie@gmail.com>
Input: synaptics-rmi4 - reject a PDT that grows between scans
This commit validates the interrupt counts gathered during Page Description
Table (PDT) scans to ensure they haven't grown between consecutive reads from
the device. By checking the counts before allocating the function, it prevents
an out-of-bounds write in the flexible array at the end of struct rmi_function.
> diff --git a/drivers/input/rmi4/rmi_driver.c b/drivers/input/rmi4/rmi_driver.c
> index 5d49a9021c7d0..f66be55677a94 100644
> --- a/drivers/input/rmi4/rmi_driver.c
> +++ b/drivers/input/rmi4/rmi_driver.c
[ ... ]
While reviewing this code, I noticed a couple of pre-existing issues in the
surrounding functions.
In drivers/input/rmi4/rmi_driver.c:rmi_driver_probe():
retval = rmi_init_functions(data);
if (retval)
goto err;
retval = rmi_f34_create_sysfs(rmi_dev);
if (retval)
goto err;
[Severity: High]
This isn't a bug introduced by this patch, but if rmi_f34_create_sysfs() fails
during probe, the error path jumps to 'err', which bypasses
err_destroy_functions.
Does this skip rmi_free_function_list() and leave the registered rmi_function
child devices active? Because rmi_driver_probe() returns an error, the driver
core cleans up the devm-managed struct rmi_driver_data. Any subsequent access
by the still-active child devices could dereference the freed driver data,
leading to a use-after-free.
Should this error path use goto err_destroy_functions instead?
In drivers/input/rmi4/rmi_f34.c:rmi_driver_update_fw_store():
error = rmi_firmware_update(data, fw);
if (error)
return error;
[Severity: High]
This is a pre-existing issue, but does this sysfs attribute lack serialization?
If multiple threads write to the update_fw sysfs file concurrently, they will
execute rmi_firmware_update() simultaneously:
drivers/input/rmi4/rmi_f34.c:rmi_firmware_update() {
...
/* Tear down functions and re-probe */
rmi_free_function_list(rmi_dev);
...
}
Because rmi_free_function_list() modifies the global data->function_list without
any synchronization, won't concurrent execution corrupt the linked list and lead
to double-frees?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260825061027.105062-1-98lawweijie@gmail.com?part=2
next prev parent reply other threads:[~2026-08-25 6:21 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-25 6:10 [PATCH v3 0/2] Input: synaptics-rmi4 - fix two device-controlled out-of-bounds writes Wei Jie LAW
2026-08-25 6:10 ` [PATCH v3 1/2] Input: synaptics-rmi4 - fix irq[] overrun with 7 interrupt sources Wei Jie LAW
2026-08-25 6:24 ` sashiko-bot
2026-08-25 10:45 ` Wei Jie LAW
2026-08-25 6:10 ` [PATCH v3 2/2] Input: synaptics-rmi4 - reject a PDT that grows between scans Wei Jie LAW
2026-08-25 6:21 ` sashiko-bot [this message]
2026-08-25 10:46 ` Wei Jie LAW
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=20260825062151.1206E1F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=98lawweijie@gmail.com \
--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