io_uring: prevent potential eventfd recursion on poll
authorJens Axboe <axboe@kernel.dk>
Sun, 2 Feb 2020 04:30:11 +0000 (21:30 -0700)
committerJens Axboe <axboe@kernel.dk>
Tue, 4 Feb 2020 00:27:47 +0000 (17:27 -0700)
commitf0b493e6b9a8959356983f57112229e69c2f7b8c
treee1b2bdd95a1b37cb4563a798a18ace70a2a1cd80
parentb5e683d5cab8cd433b06ae178621f083cabd4f63
io_uring: prevent potential eventfd recursion on poll

If we have nested or circular eventfd wakeups, then we can deadlock if
we run them inline from our poll waitqueue wakeup handler. It's also
possible to have very long chains of notifications, to the extent where
we could risk blowing the stack.

Check the eventfd recursion count before calling eventfd_signal(). If
it's non-zero, then punt the signaling to async context. This is always
safe, as it takes us out-of-line in terms of stack and locking context.

Cc: stable@vger.kernel.org # 5.1+
Signed-off-by: Jens Axboe <axboe@kernel.dk>
fs/io_uring.c