From: Zijie Zhao via B4 Relay <devnull+zzjas98.gmail.com@kernel.org>
To: Peng Fan <peng.fan@nxp.com>, Sudeep Holla <sudeep.holla@kernel.org>
Cc: Cristian Marussi <cristian.marussi@arm.com>,
Frank Li <Frank.Li@nxp.com>,
Sascha Hauer <s.hauer@pengutronix.de>,
Pengutronix Kernel Team <kernel@pengutronix.de>,
Fabio Estevam <festevam@gmail.com>,
Shawn Guo <shawnguo@kernel.org>,
arm-scmi@vger.kernel.org, imx@lists.linux.dev,
linux-arm-kernel@lists.infradead.org,
Zijie Zhao <zzjas98@gmail.com>
Subject: [PATCH] firmware: arm_scmi: imx: Check syslog reply length against word count
Date: Thu, 03 Dec 2026 17:29:25 -0600 [thread overview]
Message-ID: <20261203-kbug-l1808-v1-1-bc6587da52ca@gmail.com> (raw)
From: Zijie Zhao <zzjas98@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@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@gmail.com>
reply other threads:[~2026-12-03 23:29 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20261203-kbug-l1808-v1-1-bc6587da52ca@gmail.com \
--to=devnull+zzjas98.gmail.com@kernel.org \
--cc=Frank.Li@nxp.com \
--cc=arm-scmi@vger.kernel.org \
--cc=cristian.marussi@arm.com \
--cc=festevam@gmail.com \
--cc=imx@lists.linux.dev \
--cc=kernel@pengutronix.de \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=peng.fan@nxp.com \
--cc=s.hauer@pengutronix.de \
--cc=shawnguo@kernel.org \
--cc=sudeep.holla@kernel.org \
--cc=zzjas98@gmail.com \
/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