From: Pengpeng Hou <pengpeng@iscas.ac.cn>
To: maddy@linux.ibm.com
Cc: mpe@ellerman.id.au, npiggin@gmail.com, chleroy@kernel.org,
srikar@linux.ibm.com, sshegde@linux.ibm.com,
linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org,
pengpeng@iscas.ac.cn
Subject: [PATCH] powerpc/rtas_flash: bound validate-flash message strings
Date: Thu, 2 Apr 2026 00:03:16 +0800 [thread overview]
Message-ID: <20260401160316.88567-1-pengpeng@iscas.ac.cn> (raw)
get_validate_flash_msg() appends args_buf->buf to the userspace-visible
status message with a plain %s conversion. The firmware validation path
copies a full 4096-byte buffer through args_buf->buf, so the status
message builder can walk past the end of that fixed buffer looking for a
terminator.
Limit the appended message to the validated buffer size.
Signed-off-by: Pengpeng Hou <pengpeng@iscas.ac.cn>
---
arch/powerpc/kernel/rtas_flash.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/arch/powerpc/kernel/rtas_flash.c b/arch/powerpc/kernel/rtas_flash.c
index 583dc16e9d3c..5b3c6f3a11cd 100644
--- a/arch/powerpc/kernel/rtas_flash.c
+++ b/arch/powerpc/kernel/rtas_flash.c
@@ -455,8 +455,10 @@ static int get_validate_flash_msg(struct rtas_validate_flash_t *args_buf,
n = sprintf(msg, "%d\n", args_buf->update_results);
if ((args_buf->update_results >= VALIDATE_CUR_UNKNOWN) ||
(args_buf->update_results == VALIDATE_TMP_UPDATE))
- n += snprintf(msg + n, msglen - n, "%s\n",
- args_buf->buf);
+ n += snprintf(msg + n, msglen - n, "%.*s\n",
+ (int)strnlen(args_buf->buf,
+ args_buf->buf_size),
+ args_buf->buf);
} else {
n = sprintf(msg, "%d\n", args_buf->status);
}
--
2.50.1 (Apple Git-155)
reply other threads:[~2026-04-01 16:03 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=20260401160316.88567-1-pengpeng@iscas.ac.cn \
--to=pengpeng@iscas.ac.cn \
--cc=chleroy@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=maddy@linux.ibm.com \
--cc=mpe@ellerman.id.au \
--cc=npiggin@gmail.com \
--cc=srikar@linux.ibm.com \
--cc=sshegde@linux.ibm.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