From: gerben@altlinux.org
To: qemu-devel@nongnu.org, richard.henderson@linaro.org,
alex.bennee@linaro.org
Cc: sdl.qemu@linuxtesting.org
Subject: [PATCH] util/qht: fix possible NULL pointer dereference in qht_bucket_remove_entry()
Date: Thu, 14 Aug 2025 14:37:40 +0300 [thread overview]
Message-ID: <20250814113807.16146-1-gerben@altlinux.org> (raw)
From: Denis Rastyogin <gerben@altlinux.org>
If b->pointers[i] is NULL on the first iteration and
prev has not yet been assigned (i.e., is still NULL),
calling qht_entry_move(orig, pos, prev, QHT_BUCKET_ENTRIES - 1)
can lead to a NULL pointer dereference.
The qht_debug_assert(prev) check does not prevent this issue
because QHT_DEBUG is currently disabled (the #define is commented out).
Found by Linux Verification Center (linuxtesting.org) with SVACE.
Reported-by: Alexey Appolonov <alexey@altlinux.org>
Signed-off-by: Denis Rastyogin <gerben@altlinux.org>
---
util/qht.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/util/qht.c b/util/qht.c
index 92c6b78759..cb7e367ebb 100644
--- a/util/qht.c
+++ b/util/qht.c
@@ -768,6 +768,9 @@ static inline void qht_bucket_remove_entry(struct qht_bucket *orig, int pos)
return qht_entry_move(orig, pos, b, i - 1);
}
qht_debug_assert(prev);
+ if (!prev) {
+ continue;
+ }
return qht_entry_move(orig, pos, prev, QHT_BUCKET_ENTRIES - 1);
}
prev = b;
--
2.42.2
next reply other threads:[~2025-08-14 11:39 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-14 11:37 gerben [this message]
2025-08-15 8:51 ` [PATCH] util/qht: fix possible NULL pointer dereference in qht_bucket_remove_entry() Alex Bennée
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=20250814113807.16146-1-gerben@altlinux.org \
--to=gerben@altlinux.org \
--cc=alex.bennee@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=richard.henderson@linaro.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.