Skip to content

Commit 8fba395

Browse files
Vladimir Sementsov-OgievskiyXanClic
authored andcommitted
qcow2-refcount: check_refblocks(): add separate message for reserved
Split checking for reserved bits out of aligned offset check. Signed-off-by: Vladimir Sementsov-Ogievskiy <[email protected]> Reviewed-by: Eric Blake <[email protected]> Tested-by: Kirill Tkhai <[email protected]> Reviewed-by: Hanna Reitz <[email protected]> Message-Id: <[email protected]> Signed-off-by: Hanna Reitz <[email protected]>
1 parent 98bc07d commit 8fba395

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

block/qcow2-refcount.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2089,9 +2089,17 @@ static int check_refblocks(BlockDriverState *bs, BdrvCheckResult *res,
20892089

20902090
for(i = 0; i < s->refcount_table_size; i++) {
20912091
uint64_t offset, cluster;
2092-
offset = s->refcount_table[i];
2092+
offset = s->refcount_table[i] & REFT_OFFSET_MASK;
20932093
cluster = offset >> s->cluster_bits;
20942094

2095+
if (s->refcount_table[i] & REFT_RESERVED_MASK) {
2096+
fprintf(stderr, "ERROR refcount table entry %" PRId64 " has "
2097+
"reserved bits set\n", i);
2098+
res->corruptions++;
2099+
*rebuild = true;
2100+
continue;
2101+
}
2102+
20952103
/* Refcount blocks are cluster aligned */
20962104
if (offset_into_cluster(s, offset)) {
20972105
fprintf(stderr, "ERROR refcount block %" PRId64 " is not "

block/qcow2.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -591,6 +591,7 @@ typedef enum QCow2MetadataOverlap {
591591
#define L2E_STD_RESERVED_MASK 0x3f000000000001feULL
592592

593593
#define REFT_OFFSET_MASK 0xfffffffffffffe00ULL
594+
#define REFT_RESERVED_MASK 0x1ffULL
594595

595596
#define INV_OFFSET (-1ULL)
596597

0 commit comments

Comments
 (0)