]> git.baikalelectronics.ru Git - 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)
committerJens Axboe <axboe@kernel.dk>
Tue, 4 Feb 2020 00:27:38 +0000 (17:27 -0700)
commit0bdaaf8c291d8c458dc4206fd2dbc21f0b5c5874
treeff80c1fcdd40441ae015b35d67897c1f63129a9c
parent93f6d624ea19d33be3773655a91cf630cc3a9cb2
eventfd: track eventfd_signal() recursion depth

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>
fs/eventfd.c
include/linux/eventfd.h