From: Richard Henderson <richard.henderson@linaro.org>
To: qemu-devel@nongnu.org
Cc: Helge Deller <deller@gmx.de>
Subject: [PULL 5/6] util/interval-tree: Check root for null in interval_tree_iter_first
Date: Wed, 9 Aug 2023 10:50:05 -0700 [thread overview]
Message-ID: <20230809175006.242479-6-richard.henderson@linaro.org> (raw)
In-Reply-To: <20230809175006.242479-1-richard.henderson@linaro.org>
From: Helge Deller <deller@gmx.de>
Fix a crash in qemu-user when running
cat /proc/self/maps
in a chroot, where /proc isn't mounted.
The problem was introduced by commit 3ce3dd8ca965 ("util/selfmap:
Rewrite using qemu/interval-tree.h") where in open_self_maps_1() the
function read_self_maps() is called and which returns NULL if it can't
read the hosts /proc/self/maps file. Afterwards that NULL is fed into
interval_tree_iter_first() which doesn't check if the root node is NULL.
Fix it by adding a check if root is NULL and return NULL in that case.
Signed-off-by: Helge Deller <deller@gmx.de>
Fixes: 3ce3dd8ca965 ("util/selfmap: Rewrite using qemu/interval-tree.h")
Message-Id: <ZNOsq6Z7t/eyIG/9@p100>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
util/interval-tree.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/util/interval-tree.c b/util/interval-tree.c
index f2866aa7d3..53465182e6 100644
--- a/util/interval-tree.c
+++ b/util/interval-tree.c
@@ -797,7 +797,7 @@ IntervalTreeNode *interval_tree_iter_first(IntervalTreeRoot *root,
{
IntervalTreeNode *node, *leftmost;
- if (!root->rb_root.rb_node) {
+ if (!root || !root->rb_root.rb_node) {
return NULL;
}
--
2.34.1
next prev parent reply other threads:[~2023-08-09 17:51 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-09 17:50 [PULL 0/6] linux-user late fixes Richard Henderson
2023-08-09 17:50 ` [PULL 1/6] qemu/osdep: Remove fallback for MAP_FIXED_NOREPLACE Richard Henderson
2023-08-09 17:50 ` [PULL 2/6] linux-user: Split out do_mmap Richard Henderson
2023-08-09 17:50 ` [PULL 3/6] linux-user: Use ARRAY_SIZE with bitmask_transtbl Richard Henderson
2023-08-09 17:50 ` [PULL 4/6] tests/tcg: Disable filename test for info proc mappings Richard Henderson
2023-08-09 17:50 ` Richard Henderson [this message]
2023-08-09 17:50 ` [PULL 6/6] linux-user: Fix openat() emulation to correctly detect accesses to /proc Richard Henderson
2023-08-09 22:04 ` [PULL 0/6] linux-user late fixes 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=20230809175006.242479-6-richard.henderson@linaro.org \
--to=richard.henderson@linaro.org \
--cc=deller@gmx.de \
--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).