Re: [syzbot] [mm?] [udf?] KASAN: null-ptr-deref Read in filemap_fault

From: Jan Kara
Date: Wed May 03 2023 - 08:23:44 EST


On Wed 03-05-23 02:23:19, syzbot wrote:
> syzbot has bisected this issue to:
>
> commit 66dabbb65d673aef40dd17bf62c042be8f6d4a4b
> Author: Christoph Hellwig <hch@xxxxxx>
> Date: Tue Mar 7 14:34:10 2023 +0000
>
> mm: return an ERR_PTR from __filemap_get_folio
>
> bisection log: https://syzkaller.appspot.com/x/bisect.txt?x=15220608280000
> start commit: 865fdb08197e Merge tag 'input-for-v6.4-rc0' of git://git.k..
> git tree: upstream
> final oops: https://syzkaller.appspot.com/x/report.txt?x=17220608280000
> console output: https://syzkaller.appspot.com/x/log.txt?x=13220608280000
> kernel config: https://syzkaller.appspot.com/x/.config?x=d1c8518c09009bad
> dashboard link: https://syzkaller.appspot.com/bug?extid=48011b86c8ea329af1b9
> syz repro: https://syzkaller.appspot.com/x/repro.syz?x=137594c4280000
> C reproducer: https://syzkaller.appspot.com/x/repro.c?x=10cfd602280000
>
> Reported-by: syzbot+48011b86c8ea329af1b9@xxxxxxxxxxxxxxxxxxxxxxxxx
> Fixes: 66dabbb65d67 ("mm: return an ERR_PTR from __filemap_get_folio")
>
> For information about bisection process see: https://goo.gl/tpsmEJ#bisection

Actually looking into commit 66dabbb65d67 it seems it has two problems -
one in filemap_fault() where in:

if (IS_ERR(folio)) {
if (fpin)
goto out_retry;

we need to clear folio so that we don't try to folio_put() the error
pointer. And another in afs_dir_get_folio() where the changes effectively
make that function return ERR_PTR instead of NULL as well which will then
confuse afs_edit_dir_add() and other callers (which were not updated).

Honza
--
Jan Kara <jack@xxxxxxxx>
SUSE Labs, CR