Closed nasastry closed 6 years ago
These image files created by tests/image_fuzzer
code from qemu source tree
.
------- Comment From muriloo@br.ibm.com 2017-12-27 07:51:15 EDT------- I can't reproduce this bug with HostOS QEMU 2.11.0 (commit e7153e020f) from branch hostos-release. The qemu-io program terminates gracefully:
$ ./qemu-io test.img -c "write 1352192 1707520"
can't open device test.img: Image does not contain a reference count table
Apparently, this was fixed by:
commit 951053a9ec1c47edf4b2549ef58d82aee8a42a7f
Author: Alberto Garcia <berto@igalia.com>
Date: Fri Nov 3 16:18:53 2017 +0200
qcow2: Don't open images with header.refcount_table_clusters == 0
This commit checks whether .refcount_table_clusters of the image is equal to 0, terminating the program. So the program terminates before qcow2_cache_entry_mark_dirty() is called and tries to assert(c->entries[i].offset != 0), which caused the segfault reported here:
Thread 1 "qemu-io" hit Breakpoint 1, qcow2_cache_entry_mark_dirty (bs=0x10680ee0, c=0x10662350, table=0x7ffff5f70000) at /home/muriloo/hostos/qemu/block/qcow2-cache.c:410
410 int i = qcow2_cache_get_table_idx(bs, c, table);
(gdb) n
411 assert(c->entries[i].offset != 0);
(gdb) p i
$1 = 0
(gdb) p c->entries[i].offset != 0
$2 = 0
(gdb) n
qemu-io: /home/muriloo/hostos/qemu/block/qcow2-cache.c:411: qcow2_cache_entry_mark_dirty: Assertion `c->entries[i].offset != 0' failed.
Thread 1 "qemu-io" received signal SIGABRT, Aborted.
0x00007ffff79b91d8 in raise () from /lib64/libc.so.6
The commit 951053a9ec is present in both hostos-devel and -release branches.
Cheers Murilo
------- Comment From muriloo@br.ibm.com 2017-12-27 14:13:03 EDT------- The actual commit that fixes this issue is:
https://git.qemu.org/?p=qemu.git;a=commitdiff;h=6bf45d59f98c898b7d79
commit 6bf45d59f98c898b7d7997a333765c8ee41236ea Author: Alberto Garcia <berto@igalia.com> Date: Fri Nov 3 16:18:50 2017 +0200
qcow2: Prevent allocating refcount blocks at offset 0
------- Comment From nasastry@in.ibm.com 2018-01-01 01:02:56 EDT------- Tested with qemu-img-2.11.0-1.rel.gite7153e0.el7.centos.ppc64le
can't open device /tmp/test.img: Image does not contain a reference count table
qemu-io version 2.11.0 Copyright (c) 2003-2017 Fabrice Bellard and the QEMU Project developers
Reported segfault not seen. This bugzilla can be closed.