[PATCH 1/3] firmware: arm_scmi: imx: Track copied syslog words

Sudeep Holla sudeep.holla at kernel.org
Wed Oct 28 06:05:00 PDT 2026


The MISC syslog iterator records the number of returned words plus
firmware-reported remaining words in the caller's size output.

The debugfs consumer uses that value to dump its fixed-size buffer. A
malformed or inconsistent response can therefore make it read beyond
the copied data and allocation.

Return the accumulated number of words copied into the caller's buffer
instead. The generic iterator bounds this count to the initial buffer
capacity before processing each response.

Reported-by: Sashiko <sashiko-bot at kernel.org>
Closes: https://sashiko.dev/#/bug/linux-c3c9437c-ba1a-4db6-837f-cb0950d89018
Fixes: 4fa62e80c7db ("firmware: arm_scmi: imx: Support getting syslog of MISC protocol")
Signed-off-by: Sudeep Holla <sudeep.holla at kernel.org>
---
 drivers/firmware/arm_scmi/vendors/imx/imx-sm-misc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/firmware/arm_scmi/vendors/imx/imx-sm-misc.c b/drivers/firmware/arm_scmi/vendors/imx/imx-sm-misc.c
index 637973fb45e6..0c708b2dd496 100644
--- a/drivers/firmware/arm_scmi/vendors/imx/imx-sm-misc.c
+++ b/drivers/firmware/arm_scmi/vendors/imx/imx-sm-misc.c
@@ -438,7 +438,7 @@ static int iter_misc_syslog_update_state(struct scmi_iterator_state *st,
 
 	st->num_returned = RETURNED(r->numlogflags);
 	st->num_remaining = REMAINING(r->numlogflags);
-	*p->size = st->num_returned + st->num_remaining;
+	*p->size = st->desc_index + st->num_returned;
 
 	return 0;
 }
-- 
2.43.0




More information about the linux-arm-kernel mailing list