Skip to contentSkip to conversation

io_uring: do not double call_rcu with eventfd

PATCH In review Dylan Yudaken 2 participants 2 messages Sep 1, 2022 io_uring

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 io_uring: do not double call_rcu with eventfd

It is not allowed to use call_rcu twice with the same rcu head. This could have happened with multiple signals occurring concurrently.

Instead keep track of ops in a bitset and only queue up the call if it is not already queued up.

The refcounting is still required since as far as I can tell there is otherwise no protection from a call to io_eventfd_ops being started and before it completes another call being started.

Fixes "io_uring: signal registered eventfd to process deferred task work"

---

Note I did not put a hash in the Fixes tag as it has not yet been merged. You could also just merge it into that commit if you like.

Dylan

 include/linux/io_uring_types.h |  1 +
 io_uring/io_uring.c            | 41 +++++++++++++++++++---------------
 2 files changed, 24 insertions(+), 18 deletions(-)
include/linux/io_uring_types.h +1 -0
index 42494176434a..aa4d90a53866 100644
@@ -185,6 +185,7 @@ struct io_ev_fd {
 	unsigned int		eventfd_async: 1;
 	struct rcu_head		rcu;
 	atomic_t		refs;
+	atomic_t		ops;
 };
 
 struct io_alloc_cache {
io_uring/io_uring.c +23 -18

78 lines not on this page · raw message

base-commit: 32bde07ca566822d14f5faadcce86629d89b072b

Signature · 1 line
2.30.2
maintainer
#1 lore raw
Quoted 10 lines · Dylan Yudaken

It is not allowed to use call_rcu twice with the same rcu head. This could have happened with multiple signals occurring concurrently.

Instead keep track of ops in a bitset and only queue up the call if it is not already queued up.

The refcounting is still required since as far as I can tell there is otherwise no protection from a call to io_eventfd_ops being started and before it completes another call being started.

Quoted 6 lines
Fixes "io_uring: signal registered eventfd to process deferred task work"

---

Note I did not put a hash in the Fixes tag as it has not yet been merged. You could also just merge it into that commit if you like.

I folded it into that commit, thanks!

Signature · 1 line
Jens Axboe