From: Denis Rastyogin <ger...@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 <ger...@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