]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
io_uring/eventfd: ensure io_eventfd_signal() defers another RCU period
authorJens Axboe <axboe@kernel.dk>
Wed, 8 Jan 2025 17:28:05 +0000 (10:28 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 17 Jan 2025 12:40:58 +0000 (13:40 +0100)
Commit c9a40292a44e78f71258b8522655bffaf5753bdb upstream.

io_eventfd_do_signal() is invoked from an RCU callback, but when
dropping the reference to the io_ev_fd, it calls io_eventfd_free()
directly if the refcount drops to zero. This isn't correct, as any
potential freeing of the io_ev_fd should be deferred another RCU grace
period.

Just call io_eventfd_put() rather than open-code the dec-and-test and
free, which will correctly defer it another RCU grace period.

Fixes: 21a091b970cd ("io_uring: signal registered eventfd to process deferred task work")
Reported-by: Jann Horn <jannh@google.com>
Cc: stable@vger.kernel.org
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
io_uring/eventfd.c

index e37fddd5d9ce8e7279a4d30def8001e87b65a192..ffc4bd17d0786c317e4b3ca45b95c314761b6e64 100644 (file)
@@ -38,7 +38,7 @@ static void io_eventfd_do_signal(struct rcu_head *rcu)
        eventfd_signal_mask(ev_fd->cq_ev_fd, EPOLL_URING_WAKE);
 
        if (refcount_dec_and_test(&ev_fd->refs))
-               io_eventfd_free(rcu);
+               call_rcu(&ev_fd->rcu, io_eventfd_free);
 }
 
 void io_eventfd_signal(struct io_ring_ctx *ctx)