Skip to content

Commit 025c55a

Browse files
Diogo Jahchan KoikeKent Overstreet
authored andcommitted
bcachefs: return err ptr instead of null in read sb clean
syzbot reported a null-ptr-deref in bch2_fs_start. [0] When a sb is marked clear but doesn't have a clean section bch2_read_superblock_clean returns NULL which PTR_ERR_OR_ZERO lets through, eventually leading to a null ptr dereference down the line. Adjust read sb clean to return an ERR_PTR indicating the invalid clean section. [0] https://syzkaller.appspot.com/bug?extid=1cecc37d87c4286e5543 Reported-by: [email protected] Closes: https://syzkaller.appspot.com/bug?extid=1cecc37d87c4286e5543 Signed-off-by: Diogo Jahchan Koike <[email protected]> Signed-off-by: Kent Overstreet <[email protected]>
1 parent abb43dd commit 025c55a

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

fs/bcachefs/sb-clean.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ struct bch_sb_field_clean *bch2_read_superblock_clean(struct bch_fs *c)
155155
SET_BCH_SB_CLEAN(c->disk_sb.sb, false);
156156
c->sb.clean = false;
157157
mutex_unlock(&c->sb_lock);
158-
return NULL;
158+
return ERR_PTR(-BCH_ERR_invalid_sb_clean);
159159
}
160160

161161
clean = kmemdup(sb_clean, vstruct_bytes(&sb_clean->field),

0 commit comments

Comments
 (0)