Re: [syzbot] [dri?] BUG: sleeping function called from invalid context in _vm_unmap_aliases

Tetsuo Handa
2023-03-22T04:26:59Z

Commit c53e98934f93 ("mm: vmalloc: use rwsem, mutex for vmap_area_lock and vmap_block->lock")
is broken. We can't take mutex (a sleeping lock) inside RCU read section (an atomic context).

@@ -2183,7 +2184,7 @@ static void _vm_unmap_aliases(unsigned long start, unsigned long end, int flush)

rcu_read_lock();
list_for_each_entry_rcu(vb, &vbq->free, free_list) {
- spin_lock(&vb->lock);
+ mutex_lock(&vb->lock);
if (vb->dirty && vb->dirty != VMAP_BBMAP_BITS) {
unsigned long va_start = vb->va->va_start;
unsigned long s, e;
@@ -2196,7 +2197,7 @@ static void _vm_unmap_aliases(unsigned long start, unsigned long end, int flush)

flush = 1;
}
- spin_unlock(&vb->lock);
+ mutex_unlock(&vb->lock);
}
rcu_read_unlock();
}

#syz set subsystems: mm

On 2023/03/22 2:04, syzbot wrote:
> Hello,
>
> syzbot found the following issue on:
>
> HEAD commit: f3594f0204b7 Add linux-next specific files for 20230321
> git tree: linux-next
> console output: https://syzkaller.appspot.com/x/log.txt?x=161552eec80000
> kernel config: https://syzkaller.appspot.com/x/.config?x=f22105589e896af1
> dashboard link: https://syzkaller.appspot.com/bug?extid=a9a2bb6afe9eb31efc56
> compiler: gcc (Debian 10.2.1-6) 10.2.1 20210110, GNU ld (GNU Binutils for Debian) 2.35.2
>
> Unfortunately, I don't have any reproducer for this issue yet.
>
> Downloadable assets:
> disk image: https://storage.googleapis.com/syzbot-assets/0b755145006a/disk-f3594f02.raw.xz
> vmlinux: https://storage.googleapis.com/syzbot-assets/fca26e328a81/vmlinux-f3594f02.xz
> kernel image: https://storage.googleapis.com/syzbot-assets/39744d7d289f/bzImage-f3594f02.xz
>
> IMPORTANT: if you fix the issue, please add the following tag to the commit:
> Reported-by: syzbot+a9a2bb6afe9eb31efc56@syzkaller.appspotmail.com
>