]> git.dujemihanovic.xyz Git - linux.git/commit
bcachefs: return err ptr instead of null in read sb clean
authorDiogo Jahchan Koike <djahchankoike@gmail.com>
Tue, 10 Sep 2024 21:18:34 +0000 (18:18 -0300)
committerKent Overstreet <kent.overstreet@linux.dev>
Sat, 21 Sep 2024 15:39:49 +0000 (11:39 -0400)
commit025c55a4c7f11ea38521c6e797f3192ad8768c93
treeb9debe4e9e97622cedf7a699ae08dd98b48f0dca
parentabb43dd677f3c5508dc369a61f82f89a8b16b811
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: syzbot+1cecc37d87c4286e5543@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=1cecc37d87c4286e5543
Signed-off-by: Diogo Jahchan Koike <djahchankoike@gmail.com>
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
fs/bcachefs/sb-clean.c