firmware: arm_scmi: imx: Check syslog reply length against word count
Subsystems (3)
PATCH 1/1 firmware: arm_scmi: imx: Check syslog reply length against word count
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.
---
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(+)
drivers/firmware/arm_scmi/vendors/imx/imx-sm-misc.c +4 -0
@@ -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,
Signature · 1 line
Zijie Zhao <[email protected]>
Quoted 33 lines · On Thu, 03 Dec 2026 17:29:25 -0600 Zijie Zhao via B4 Relay…
From: Zijie Zhao <[email protected]>
iter_misc_syslog_update_state()takes the number of returned words from theSYSLOG_GETreply 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 <[email protected]>---
The patch is against mainline. In linux-next the file has moved todrivers/firmware/arm/scmi/vendors/imx/by49c49ca0c4d0("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 onx86_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(+)drivers/firmware/arm_scmi/vendors/imx/imx-sm-misc.c +0
-0
drivers/firmware/arm_scmi/vendors/imx/imx-sm-misc.c static int iter_misc_syslog_update_state(struct scmi_iterator_state *st, · line 453
Quoted 8 lines
drivers/firmware/arm_scmi/vendors/imx/imx-sm-misc.c +4
-0@@ -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;
Fine as defensive programming logic.