From: heropd <munkhuu0825@gmail.com>
To: qemu-devel@nongnu.org
Cc: Munkhbaatar Enkhbaatar <munkhuu0825@gmail.com>
Subject: [PATCH V2] htif: reject invalid signature ranges (end <= begin)
Date: Tue, 9 Dec 2025 16:53:49 +0800 [thread overview]
Message-ID: <20251209085349.61510-1-munkhuu0825@gmail.com> (raw)
From: Munkhbaatar Enkhbaatar <munkhuu0825@gmail.com>
Prevents huge allocations and crashes caused by malformed HTIF signature
addresses.
Fixes: link to issue #3205
Signed-off-by: Munkhbaatar Enkhbaatar <munkhuu0825@gmail.com>
---
hw/char/riscv_htif.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/hw/char/riscv_htif.c b/hw/char/riscv_htif.c
index a78ea9b01c..aa205c84c0 100644
--- a/hw/char/riscv_htif.c
+++ b/hw/char/riscv_htif.c
@@ -170,6 +170,11 @@ static void htif_handle_tohost_write(HTIFState *s, uint64_t val_written)
* begin/end_signature symbols exist.
*/
if (sig_file && begin_sig_addr && end_sig_addr) {
+ if (end_sig_addr <= begin_sig_addr) {
+ error_report("Invalid HTIF signature range: begin=0x%llx end=0x%llx",
+ begin_sig_addr, end_sig_addr);
+ return;
+ }
uint64_t sig_len = end_sig_addr - begin_sig_addr;
char *sig_data = g_malloc(sig_len);
dma_memory_read(&address_space_memory, begin_sig_addr,
--
2.50.1 (Apple Git-155)
reply other threads:[~2025-12-09 8:54 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=20251209085349.61510-1-munkhuu0825@gmail.com \
--to=munkhuu0825@gmail.com \
--cc=qemu-devel@nongnu.org \
/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;
as well as URLs for NNTP newsgroup(s).