Skip to content

Commit 2fe79ce

Browse files
author
Kent Overstreet
committed
bcachefs: Fix a UAF after write_super()
write_super() may reallocate the superblock buffer - but bch_sb_field_ext was referencing it; don't use it after the write_super call. Reported-by: syzbot+8992fc10a192067b8d8a@syzkaller.appspotmail.com Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
1 parent e6b3a65 commit 2fe79ce

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

fs/bcachefs/recovery.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -664,10 +664,10 @@ int bch2_fs_recovery(struct bch_fs *c)
664664
if (check_version_upgrade(c))
665665
write_sb = true;
666666

667+
c->recovery_passes_explicit |= bch2_recovery_passes_from_stable(le64_to_cpu(ext->recovery_passes_required[0]));
668+
667669
if (write_sb)
668670
bch2_write_super(c);
669-
670-
c->recovery_passes_explicit |= bch2_recovery_passes_from_stable(le64_to_cpu(ext->recovery_passes_required[0]));
671671
mutex_unlock(&c->sb_lock);
672672

673673
if (c->opts.fsck && IS_ENABLED(CONFIG_BCACHEFS_DEBUG))

0 commit comments

Comments
 (0)