From: Nicholas Krause Subject: [PATCH] fs:Fix Possible deadlock on spinlock "ctx_lock" when user aborts process using async-IO with ctrl-C Date: Thu, 25 Aug 2016 22:42:27 -0400 Message-ID: <1472179347-13960-1-git-send-email-xerofoify@gmail.com> Cc: bcrl@kvack.org, linux-fsdevel@vger.kernel.org, linux-aio@kvack.org, linux-kernel@vger.kernel.org To: viro@zeniv.linux.org.uk Return-path: Sender: owner-linux-aio@kvack.org List-Id: linux-fsdevel.vger.kernel.org This fixes a possible deadlock on spinlock ctx_lock used the percpu ref structure before calling kiocb_cancel, this is due to the issue of us reattempting to lock on calling aio_complete from within kiob_cancel as the kiocb_cancel_fn function pointer which in term causes a deadlock. This is easily fixed by unlocking the ctx_lock with spin_lock_irq and locking afterward the call to kiocb_cancel in order to avoid this deadlock when the user aborts a process using async-IO with ctrl-C. Signed-off-by: Nicholas Krause --- fs/aio.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/fs/aio.c b/fs/aio.c index fb8e45b..3107b92 100644 --- a/fs/aio.c +++ b/fs/aio.c @@ -615,7 +615,9 @@ static void free_ioctx_users(struct percpu_ref *ref) struct aio_kiocb, ki_list); list_del_init(&req->ki_list); + spin_unlock_irq(&ctx->ctx_lock); kiocb_cancel(req); + spin_lock_irq(&ctx->ctx_lock); } spin_unlock_irq(&ctx->ctx_lock); -- 2.7.4 -- To unsubscribe, send a message with 'unsubscribe linux-aio' in the body to majordomo@kvack.org. For more info on Linux AIO, see: http://www.kvack.org/aio/ Don't email: aart@kvack.org