]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commit
eventfd: track eventfd_signal() recursion depth
authorJens Axboe <axboe@kernel.dk>
Sun, 2 Feb 2020 15:23:03 +0000 (08:23 -0700)
committerKhalid Elmously <khalid.elmously@canonical.com>
Fri, 13 Mar 2020 04:31:00 +0000 (00:31 -0400)
commitfde5fd9cf2f607b9216e3dcf262a639767b44675
treee8071c4703213255cd5d2b0d9b45cdbb8fb9835b
parentb03a2a0650d569bb16bd858f147e51dc842996bf
eventfd: track eventfd_signal() recursion depth

BugLink: https://bugs.launchpad.net/bugs/1866678
commit b5e683d5cab8cd433b06ae178621f083cabd4f63 upstream.

eventfd use cases from aio and io_uring can deadlock due to circular
or resursive calling, when eventfd_signal() tries to grab the waitqueue
lock. On top of that, it's also possible to construct notification
chains that are deep enough that we could blow the stack.

Add a percpu counter that tracks the percpu recursion depth, warn if we
exceed it. The counter is also exposed so that users of eventfd_signal()
can do the right thing if it's non-zero in the context where it is
called.

Cc: stable@vger.kernel.org # 4.19+
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
fs/eventfd.c
include/linux/eventfd.h