Skip to content

Commit ff0b7ed

Browse files
author
Kent Overstreet
committed
bcachefs: Fix check_inode_hash_info_matches_root()
Can't use memcmp() when the struct contains padding. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
1 parent a4e11ce commit ff0b7ed

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

fs/bcachefs/str_hash.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,10 +167,19 @@ found:;
167167
goto err;
168168

169169
struct bch_hash_info hash2 = bch2_hash_info_init(c, &inode);
170-
if (memcmp(hash_info, &hash2, sizeof(hash2))) {
170+
if (hash_info->type != hash2.type ||
171+
memcmp(&hash_info->siphash_key, &hash2.siphash_key, sizeof(hash2.siphash_key))) {
171172
ret = repair_inode_hash_info(trans, &inode);
172173
if (!ret) {
173-
bch_err(c, "inode hash info mismatch with root, but mismatch not found");
174+
bch_err(c, "inode hash info mismatch with root, but mismatch not found\n"
175+
"%u %llx %llx\n"
176+
"%u %llx %llx",
177+
hash_info->type,
178+
hash_info->siphash_key.k0,
179+
hash_info->siphash_key.k1,
180+
hash2.type,
181+
hash2.siphash_key.k0,
182+
hash2.siphash_key.k1);
174183
ret = -BCH_ERR_fsck_repair_unimplemented;
175184
}
176185
}

0 commit comments

Comments
 (0)