From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
To: Bryam Vargas <hexlabsecurity@proton.me>,
Hans Verkuil <hverkuil@kernel.org>
Cc: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org,
stable@vger.kernel.org, sashiko-bot@kernel.org
Subject: [PATCH 02/10] Input: synaptics-rmi4 - zero report size on F54 work error
Date: Thu, 25 Jun 2026 22:17:51 -0700 [thread overview]
Message-ID: <20260626051802.4033172-2-dmitry.torokhov@gmail.com> (raw)
In-Reply-To: <20260626051802.4033172-1-dmitry.torokhov@gmail.com>
In rmi_f54_work(), if an error occurs during report request or command
verification, the code jumped directly to the 'error' label, bypassing
the 'abort' label where f54->report_size was normally zeroed out.
This left f54->report_size containing its previous successful payload
size. If a user then altered the V4L2 format to a smaller size, and a
subsequent run failed, rmi_f54_buffer_queue() would copy the stale,
larger payload size into the shrunken V4L2 buffer, causing a heap
buffer overflow.
Fix this by merging the 'abort' and 'error' labels into a single 'out'
exit path, and ensuring that f54->report_size is always set to 0 on
failure by checking for error and zeroing the local report_size first.
Fixes: 3a762dbd5347 ("[media] Input: synaptics-rmi4 - add support for F54 diagnostics")
Cc: stable@vger.kernel.org
Reported-by: sashiko-bot@kernel.org
Assisted-by: Antigravity:gemini-3.5-flash
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
---
drivers/input/rmi4/rmi_f54.c | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/drivers/input/rmi4/rmi_f54.c b/drivers/input/rmi4/rmi_f54.c
index 61909e1a39e2..8eac320c43e3 100644
--- a/drivers/input/rmi4/rmi_f54.c
+++ b/drivers/input/rmi4/rmi_f54.c
@@ -545,7 +545,7 @@ static void rmi_f54_work(struct work_struct *work)
dev_err(&fn->dev, "Bad report size, report type=%d\n",
f54->report_type);
error = -EINVAL;
- goto error; /* retry won't help */
+ goto out; /* retry won't help */
}
/*
@@ -556,7 +556,7 @@ static void rmi_f54_work(struct work_struct *work)
&command);
if (error) {
dev_err(&fn->dev, "Failed to read back command\n");
- goto error;
+ goto out;
}
if (command & F54_GET_REPORT) {
if (time_after(jiffies, f54->timeout)) {
@@ -564,7 +564,7 @@ static void rmi_f54_work(struct work_struct *work)
error = -ETIMEDOUT;
}
report_size = 0;
- goto error;
+ goto out;
}
rmi_dbg(RMI_DEBUG_FN, &fn->dev, "Get report command completed, reading data\n");
@@ -579,7 +579,7 @@ static void rmi_f54_work(struct work_struct *work)
fifo, sizeof(fifo));
if (error) {
dev_err(&fn->dev, "Failed to set fifo start offset\n");
- goto abort;
+ goto out;
}
error = rmi_read_block(fn->rmi_dev, fn->fd.data_base_addr +
@@ -588,16 +588,16 @@ static void rmi_f54_work(struct work_struct *work)
if (error) {
dev_err(&fn->dev, "%s: read [%d bytes] returned %d\n",
__func__, size, error);
- goto abort;
+ goto out;
}
}
-abort:
- f54->report_size = error ? 0 : report_size;
-error:
+out:
if (error)
report_size = 0;
+ f54->report_size = report_size;
+
if (report_size == 0 && !error) {
queue_delayed_work(f54->workqueue, &f54->work,
msecs_to_jiffies(1));
--
2.55.0.rc0.799.gd6f94ed593-goog
next prev parent reply other threads:[~2026-06-26 5:18 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 ` Dmitry Torokhov [this message]
2026-06-26 5:32 ` [PATCH 02/10] Input: synaptics-rmi4 - zero report size on F54 work error 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
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=20260626051802.4033172-2-dmitry.torokhov@gmail.com \
--to=dmitry.torokhov@gmail.com \
--cc=hexlabsecurity@proton.me \
--cc=hverkuil@kernel.org \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=sashiko-bot@kernel.org \
--cc=stable@vger.kernel.org \
/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.