Re: INFO: task hung in lo_ioctl

From: Tetsuo Handa
Date: Fri Apr 06 2018 - 09:56:23 EST


Peter Zijlstra wrote:
> On Fri, Apr 06, 2018 at 09:04:18PM +0900, Tetsuo Handa wrote:
> > + /* Temporary hack for handling lock imbalance. */
> > + if (__mutex_owner(&lo->lo_ctl_mutex) == current)
> > + mutex_unlock(&lo->lo_ctl_mutex);
>
> ARGGH.. you didn't read the comment we put on that?
>

Commit 5b52330bbfe63b33 ("audit: fix auditd/kernel connection state tracking")
is using __mutex_owner(). ;-)

Of course, regarding loop module, we will be able to add a flag variable
associated with lo->lo_ctl_mutex. But that will be done after we solved
the deadlock problem. I think whether we need to drop lo->lo_ctl_mutex is
not clear. Maybe

- err = mutex_lock_killable_nested(&lo->lo_ctl_mutex, 1);
+ err = mutex_lock_killable(&lo->lo_ctl_mutex);

on top of this patch and listen to the lockdep?

Commit f028f3b2f987ebc6 ("loop: fix circular locking in loop_clr_fd()") says

A simple way to silence lockdep could be to mark the lo_ctl_mutex
in ioctl to be a sub class, but this might mask some other real bugs.

and we are currently hitting a deadlock problem.