Skip to content

Commit 40d40c6

Browse files
Diogo Jahchan KoikeKent Overstreet
authored andcommitted
bcachefs: assign return error when iterating through layout
syzbot reported a null ptr deref in __copy_user [0] In __bch2_read_super, when a corrupt backup superblock matches the default opts offset, no error is assigned to ret and the freed superblock gets through, possibly being assigned as the best sb in bch2_fs_open and being later dereferenced, causing a fault. Assign EINVALID to ret when iterating through layout. [0]: https://syzkaller.appspot.com/bug?extid=18a5c5e8a9c856944876 Reported-by: [email protected] Closes: https://syzkaller.appspot.com/bug?extid=18a5c5e8a9c856944876 Signed-off-by: Diogo Jahchan Koike <[email protected]> Signed-off-by: Kent Overstreet <[email protected]>
1 parent c604044 commit 40d40c6

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

fs/bcachefs/super-io.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -799,8 +799,10 @@ static int __bch2_read_super(const char *path, struct bch_opts *opts,
799799
i < layout.sb_offset + layout.nr_superblocks; i++) {
800800
offset = le64_to_cpu(*i);
801801

802-
if (offset == opt_get(*opts, sb))
802+
if (offset == opt_get(*opts, sb)) {
803+
ret = -BCH_ERR_invalid;
803804
continue;
805+
}
804806

805807
ret = read_one_super(sb, offset, &err);
806808
if (!ret)

0 commit comments

Comments
 (0)