From 51554778ff99cbf52ef2bd17d327e0c1962cbcbe Mon Sep 17 00:00:00 2001 From: Al Viro Date: Sat, 22 Aug 2020 18:25:52 -0400 Subject: [PATCH] BACKPORT: do_epoll_ctl(): clean the failure exits up a bit commit 52c479697c9b73f628140dcdfcd39ea302d05482 upstream. Signed-off-by: Al Viro Signed-off-by: Marc Zyngier Signed-off-by: Greg Kroah-Hartman Signed-off-by: Lee Jones Issue: SEC-2677 [backport to FP2: Missing change "epoll: do not take global 'epmutex' for simple topologies", so we don't have the full_check condition yet.] Change-Id: I97468c95d3c22cc5f538dfcf78907aefa35a6503 (cherry picked from commit 1d90193cda629e352eecfe0d1a2cec388c73ab68) --- fs/eventpoll.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/fs/eventpoll.c b/fs/eventpoll.c index 78d6709e39c..f2f360e96ab 100644 --- a/fs/eventpoll.c +++ b/fs/eventpoll.c @@ -1772,7 +1772,6 @@ SYSCALL_DEFINE4(epoll_ctl, int, epfd, int, op, int, fd, if (is_file_epoll(tf.file)) { error = -ELOOP; if (ep_loop_check(ep, tf.file) != 0) { - clear_tfile_check_list(); goto error_tgt_fput; } } else { @@ -1798,7 +1797,6 @@ SYSCALL_DEFINE4(epoll_ctl, int, epfd, int, op, int, fd, error = ep_insert(ep, &epds, tf.file, fd); } else error = -EEXIST; - clear_tfile_check_list(); break; case EPOLL_CTL_DEL: if (epi) @@ -1817,8 +1815,10 @@ SYSCALL_DEFINE4(epoll_ctl, int, epfd, int, op, int, fd, mutex_unlock(&ep->mtx); error_tgt_fput: - if (did_lock_epmutex) + if (did_lock_epmutex) { + clear_tfile_check_list(); mutex_unlock(&epmutex); + } fdput(tf); error_fput: