From: gerben@altlinux.org
To: qemu-devel@nongnu.org, kwolf@redhat.com, hreitz@redhat.com
Cc: sdl.qemu@linuxtesting.org
Subject: [PATCH] qcow2: fix null pointer dereference in crypto block
Date: Tue, 18 Mar 2025 13:58:58 +0300 [thread overview]
Message-ID: <20250318105924.258014-1-gerben@altlinux.org> (raw)
From: Denis Rastyogin <gerben@altlinux.org>
This error was discovered by fuzzing qemu-img.
The qcow2_refresh_limits() is missing a check
for the s->crypto pointer, which can lead to
a null pointer dereference. This commit adds the necessary check.
Reported-by: Leonid Reviakin <L.reviakin@fobos-nt.ru>
Signed-off-by: Denis Rastyogin <gerben@altlinux.org>
---
block/qcow2.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/block/qcow2.c b/block/qcow2.c
index dd6bcafbd8..55861a285a 100644
--- a/block/qcow2.c
+++ b/block/qcow2.c
@@ -1978,6 +1978,10 @@ static void qcow2_refresh_limits(BlockDriverState *bs, Error **errp)
if (bs->encrypted) {
/* Encryption works on a sector granularity */
+ if (!s->crypto) {
+ error_setg(errp, "Encryption context is missing");
+ return;
+ }
bs->bl.request_alignment = qcrypto_block_get_sector_size(s->crypto);
}
bs->bl.pwrite_zeroes_alignment = s->subcluster_size;
--
2.42.2
next reply other threads:[~2025-03-18 11:00 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-18 10:58 gerben [this message]
2025-03-18 12:00 ` [PATCH] qcow2: fix null pointer dereference in crypto block Kevin Wolf
2025-03-18 13:00 ` gerben
2025-03-18 19:53 ` Kevin Wolf
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=20250318105924.258014-1-gerben@altlinux.org \
--to=gerben@altlinux.org \
--cc=hreitz@redhat.com \
--cc=kwolf@redhat.com \
--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.