Re: INFO: task hung in exit_mm

From: Peter Zijlstra
Date: Tue Jul 02 2019 - 05:36:30 EST


On Tue, Jul 02, 2019 at 11:06:08AM +0200, Peter Zijlstra wrote:
> On Mon, Jul 01, 2019 at 05:14:12PM -0700, Andrew Morton wrote:
> > On Mon, 01 Jul 2019 01:27:04 -0700 syzbot <syzbot+8cc1843d4eec9c0dfb35@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote:
> >
> > > Hello,
> > >
> > > syzbot found the following crash on:
> >
> > At a guess I'd say that perf_mmap() hit a deadlock on event->mmap_mutex
> > while holding down_write(mmap_sem) (via vm_mmap_pgoff). The
> > down_read(mmap_sem) in do_exit() happened to stumble across this and
> > that's what got reported.
>
> lockdep never reported that and I don't see event->mmap_mutex being held
> anywhere.
>
> AFAICT CPU0 is running 8355 and only 'has' mmap_sem -- it's blocked
> waiting to acquire.
>
> CPU1 is running 8354 and has mmap_sem and is waiting to acquire
> event->mmap_mutex.
>
> But nobody is actually owning it
>
> We take mmap_mutex in:
>
> perf_mmap() - called with mmap_sem held
> perf_mmap_close() - called with mmap_sem held
>
> _free_event() - no faults/mmap while holding it
> perf_poll() - idem
> perf_event_set_output() - idem
>
> I don't see any of those functions in the below stacktrace, and having
> just looked them over, I don't see how they would end up trying to
> acquire mmap_sem and AB-BA.
>
> Now, clearly there's something screwy, but I'm not seeing a deadlock.
> Let me go play with that reproducer.
>
> > > HEAD commit: 249155c2 Merge branch 'parisc-5.2-4' of git://git.kernel.o..
> > > git tree: upstream
> > > console output: https://syzkaller.appspot.com/x/log.txt?x=1306be61a00000
> > > kernel config: https://syzkaller.appspot.com/x/.config?x=9a31528e58cc12e2
> > > dashboard link: https://syzkaller.appspot.com/bug?extid=8cc1843d4eec9c0dfb35
> > > compiler: clang version 9.0.0 (/home/glider/llvm/clang

Also note that I very much do not trust that compiler to build a working
kernel. There's still known code-gen bugs with it.