Re: [ep_insert()] 9ee1cc5666: WARNING:possible_recursive_locking_detected

Al Viro
2020-10-04T14:27:53Z

On Sun, Oct 04, 2020 at 03:17:45PM +0100, Al Viro wrote:
> On Sun, Oct 04, 2020 at 08:56:19PM +0800, kernel test robot wrote:
> > Greeting,
> >
> > FYI, we noticed the following commit (built with gcc-9):
> >
> > commit: 9ee1cc56661640a2ace2f7d0b52dec56b3573c53 ("[RFC PATCH 20/27] ep_insert(): we only need tep->mtx around the insertion itself")
> > url: https://github.com/0day-ci/linux/commits/Al-Viro/epoll-switch-epitem-pwqlist-to-single-linked-list/20201004-113938
> > base: https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git 22fbc037cd32e4e6771d2271b565806cfb8c134c
>
> False positive, actually - that should've been mutex_lock_nested()
> with 1 for depth; will update.

Folded and pushed; the incremental is
diff --git a/fs/eventpoll.c b/fs/eventpoll.c
index d3fdabf6fd34..aa8b8490cc96 100644
--- a/fs/eventpoll.c
+++ b/fs/eventpoll.c
@@ -1455,7 +1455,7 @@ static int ep_insert(struct eventpoll *ep, const struct epoll_event *event,
epi->next = EP_UNACTIVE_PTR;

if (tep)
- mutex_lock(&tep->mtx);
+ mutex_lock_nested(&tep->mtx, 1);
/* Add the current item to the list of active epoll hook for this file */
if (unlikely(attach_epitem(tfile, epi) < 0)) {
kmem_cache_free(epi_cache, epi);