Skip to content

Commit

Permalink
qcow2-refcount: check_refblocks(): add separate message for reserved
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
Vladimir Sementsov-Ogievskiy authored and XanClic committed Sep 15, 2021
1 parent 98bc07d commit 8fba395
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
10 changes: 9 additions & 1 deletion block/qcow2-refcount.c
Original file line number Diff line number Diff line change
Expand Up @@ -2089,9 +2089,17 @@ static int check_refblocks(BlockDriverState *bs, BdrvCheckResult *res,

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

if (s->refcount_table[i] & REFT_RESERVED_MASK) {
fprintf(stderr, "ERROR refcount table entry %" PRId64 " has "
"reserved bits set\n", i);
res->corruptions++;
*rebuild = true;
continue;
}

/* Refcount blocks are cluster aligned */
if (offset_into_cluster(s, offset)) {
fprintf(stderr, "ERROR refcount block %" PRId64 " is not "
Expand Down
1 change: 1 addition & 0 deletions block/qcow2.h
Original file line number Diff line number Diff line change
Expand Up @@ -591,6 +591,7 @@ typedef enum QCow2MetadataOverlap {
#define L2E_STD_RESERVED_MASK 0x3f000000000001feULL

#define REFT_OFFSET_MASK 0xfffffffffffffe00ULL
#define REFT_RESERVED_MASK 0x1ffULL

#define INV_OFFSET (-1ULL)

Expand Down

0 comments on commit 8fba395

Please sign in to comment.