Skip to content

Commit 8e910ca

Browse files
author
Kent Overstreet
committed
bcachefs: Fix UAF in bch2_reconstruct_alloc()
write_super() -> sb_counters_from_cpu() may reallocate the superblock Reported-by: [email protected] Signed-off-by: Kent Overstreet <[email protected]>
1 parent a25a83d commit 8e910ca

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

fs/bcachefs/recovery.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,11 +94,10 @@ static void bch2_reconstruct_alloc(struct bch_fs *c)
9494
__set_bit_le64(BCH_FSCK_ERR_accounting_mismatch, ext->errors_silent);
9595
c->sb.compat &= ~(1ULL << BCH_COMPAT_alloc_info);
9696

97-
bch2_write_super(c);
98-
mutex_unlock(&c->sb_lock);
99-
10097
c->opts.recovery_passes |= bch2_recovery_passes_from_stable(le64_to_cpu(ext->recovery_passes_required[0]));
10198

99+
bch2_write_super(c);
100+
mutex_unlock(&c->sb_lock);
102101

103102
bch2_shoot_down_journal_keys(c, BTREE_ID_alloc,
104103
0, BTREE_MAX_DEPTH, POS_MIN, SPOS_MAX);

0 commit comments

Comments
 (0)