[PATCH] firmware: arm_scmi: imx: Check syslog reply length against word count

Zijie Zhao via B4 Relay devnull+zzjas98.gmail.com at kernel.org
Thu Dec 3 15:29:25 PST 2026


From: Zijie Zhao <zzjas98 at gmail.com>

iter_misc_syslog_update_state() takes the number of returned words from
the SYSLOG_GET reply and the iterator then copies that many words from
the RX buffer without checking the reply length. A reply announcing more
words than it carries copies stale data, or memory past the RX buffer,
into the syslog dumped to debugfs. Reject such replies.

Found by a static analysis tool.

Fixes: 4fa62e80c7db ("firmware: arm_scmi: imx: Support getting syslog of MISC protocol")
Signed-off-by: Zijie Zhao <zzjas98 at gmail.com>
---
The patch is against mainline. In linux-next the file has moved to
drivers/firmware/arm/scmi/vendors/imx/ by 49c49ca0c4d0 ("firmware: arm:
Group interface drivers under arm/"); the changed function is identical there.

The fix and the changelog were drafted with AI assistance (Claude Code,
with a second review by OpenAI Codex), then reviewed by the submitter.

Testing:
- Compile-tested on x86_64 (allmodconfig, W=1):
  drivers/firmware/arm_scmi/vendors/imx/imx-sm-misc.o; no new warnings.
- checkpatch.pl --strict: no errors or warnings.
---
 drivers/firmware/arm_scmi/vendors/imx/imx-sm-misc.c | 4 ++++
 1 file changed, 4 insertions(+)

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 ed7499d72f19..ad338fc23f72 100644
--- a/drivers/firmware/arm_scmi/vendors/imx/imx-sm-misc.c
+++ b/drivers/firmware/arm_scmi/vendors/imx/imx-sm-misc.c
@@ -446,6 +446,10 @@ static int iter_misc_syslog_update_state(struct scmi_iterator_state *st,
 
 	st->num_returned = RETURNED(r->numlogflags);
 	st->num_remaining = REMAINING(r->numlogflags);
+
+	if (st->rx_len < sizeof(*r) + sizeof(r->syslog[0]) * st->num_returned)
+		return -EINVAL;
+
 	*p->size = st->desc_index + st->num_returned;
 
 	return 0;

---
base-commit: 007722b8211f7b34fdf21b1e6a9c32497633ea29
change-id: 20261203-kbug-l1808-9567ba03e265

Best regards,
--  
Zijie Zhao <zzjas98 at gmail.com>





More information about the linux-arm-kernel mailing list