Re: KASAN: null-ptr-deref Read in filp_close

From: Christian Brauner
Date: Thu Dec 17 2020 - 11:45:34 EST


On Thu, Dec 17, 2020 at 07:54:09AM -0800, syzbot wrote:
> Hello,
>
> syzbot found the following issue on:
>
> HEAD commit: 5e60366d Merge tag 'fallthrough-fixes-clang-5.11-rc1' of g..
> git tree: upstream
> console output: https://syzkaller.appspot.com/x/log.txt?x=15f15413500000
> kernel config: https://syzkaller.appspot.com/x/.config?x=db720fe37a6a41d8
> dashboard link: https://syzkaller.appspot.com/bug?extid=96cfd2b22b3213646a93
> compiler: gcc (GCC) 10.1.0-syz 20200507
> syz repro: https://syzkaller.appspot.com/x/repro.syz?x=10e1a00b500000
> C reproducer: https://syzkaller.appspot.com/x/repro.c?x=1128e41f500000
>
> The issue was bisected to:
>
> commit 582f1fb6b721facf04848d2ca57f34468da1813e
> Author: Giuseppe Scrivano <gscrivan@xxxxxxxxxx>
> Date: Wed Nov 18 10:47:45 2020 +0000
>
> fs, close_range: add flag CLOSE_RANGE_CLOEXEC
>
> bisection log: https://syzkaller.appspot.com/x/bisect.txt?x=16e85613500000
> final oops: https://syzkaller.appspot.com/x/report.txt?x=15e85613500000
> console output: https://syzkaller.appspot.com/x/log.txt?x=11e85613500000
>
> IMPORTANT: if you fix the issue, please add the following tag to the commit:
> Reported-by: syzbot+96cfd2b22b3213646a93@xxxxxxxxxxxxxxxxxxxxxxxxx
> Fixes: 582f1fb6b721 ("fs, close_range: add flag CLOSE_RANGE_CLOEXEC")

Ok, I think the bug is simply that max_fd is not correctly updated when
CLOSE_RANGE_UNSHARE is combined with CLOSE_RANGE_CLOEXEC.
I'll write a patch for syszbot to chew on.

Christian