Commit 0bc215484d for qemu.org
commit 0bc215484d66822ba0a9967f7719eaf59b662f42
Author: Julio Faracco <jcfaracco@gmail.com>
Date: Mon Nov 23 23:37:08 2026 -0300
block/dmg-lzfse: reject truncated LZFSE decodes
dmg_uncompress_lzfse_do() treated any non-zero lzfse_decode_buffer()
return as success. A crafted DMG can declare a larger chunk output
size than its LZFSE stream decodes to, so the uninitialized tail of
uncompressed_chunk is handed to the guest as sector data -- a heap
disclosure.
Fix this by requiring out_size == avail_out: if lzfse_decode_buffer()
returns less than avail_out the decode was truncated and the chunk is
rejected with an error. When the return value equals avail_out the
stream may also have been oversized (destination too small), but that
ambiguity is harmless -- the guest never sees stale data either way.
zlib and bzip2 chunk paths already enforce exact output size; LZFSE
did not.
Fixes: CVE-2026-116483
Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/4662
Reported-by: oxsignal <awo@kakao.com>
Signed-off-by: Julio Faracco <jcfaracco@gmail.com>
Message-ID: <20261123-dmg-short-decode-v2-v2-1-e1dee5893891@gmail.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
diff --git a/block/dmg-lzfse.c b/block/dmg-lzfse.c
index 4ea0b9b20d..61b6d567c1 100644
--- a/block/dmg-lzfse.c
+++ b/block/dmg-lzfse.c
@@ -37,12 +37,17 @@ static int dmg_uncompress_lzfse_do(char *next_in, unsigned int avail_in,
(uint8_t *) next_in, avail_in,
NULL);
- /* We need to decode the single chunk only. */
- /* So, out_size == avail_out is not an error here. */
- if (out_size > 0) {
- return out_size;
+ /*
+ * lzfse_decode_buffer() returns the number of bytes written to the
+ * destination buffer, or the destination capacity if the buffer is
+ * too small. Reject any decode that did not fill the full chunk:
+ * a truncated decode would expose the uninitialized tail of the
+ * uncompressed_chunk buffer to the guest.
+ */
+ if (out_size < avail_out) {
+ return -1;
}
- return -1;
+ return out_size;
}
__attribute__((constructor))