From: gerben@altlinux.org
To: qemu-devel@nongnu.org, laurent@vivier.eu
Cc: sdl.qemu@linuxtesting.org
Subject: [PATCH] linux-user: check for NULL before using interval_tree_iter_first result
Date: Tue, 22 Jul 2025 13:15:05 +0300 [thread overview]
Message-ID: <20250722101544.16366-1-gerben@altlinux.org> (raw)
From: Denis Rastyogin <gerben@altlinux.org>
interval_tree_iter_first() may return NULL if the interval tree is empty or invalid.
Add a check for NULL before dereferencing the pointer to avoid potential crashes
due to null pointer dereference in open_self_maps_2().
Found by Linux Verification Center (linuxtesting.org) with SVACE.
Signed-off-by: Denis Rastyogin <gerben@altlinux.org>
---
linux-user/syscall.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 91360a072c..d5d5912c96 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -8172,6 +8172,9 @@ static int open_self_maps_2(void *opaque, vaddr guest_start,
while (1) {
IntervalTreeNode *n =
interval_tree_iter_first(d->host_maps, host_start, host_start);
+ if (n == NULL) {
+ return -1;
+ }
MapInfo *mi = container_of(n, MapInfo, itree);
uintptr_t this_hlast = MIN(host_last, n->last);
target_ulong this_gend = h2g(this_hlast) + 1;
--
2.42.2
next reply other threads:[~2025-07-22 10:16 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-22 10:15 gerben [this message]
2025-07-22 14:43 ` [PATCH] linux-user: check for NULL before using interval_tree_iter_first result Richard Henderson
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=20250722101544.16366-1-gerben@altlinux.org \
--to=gerben@altlinux.org \
--cc=laurent@vivier.eu \
--cc=qemu-devel@nongnu.org \
--cc=sdl.qemu@linuxtesting.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.