io_uring/rsrc: Simplify buffer cloning by locking both rings
authorJann Horn <jannh@google.com>
Wed, 15 Jan 2025 20:26:03 +0000 (21:26 +0100)
committerJens Axboe <axboe@kernel.dk>
Wed, 15 Jan 2025 22:35:12 +0000 (15:35 -0700)
commit8865af703c087b8bcc2fdd04b6a93d3cc0fb0e9f
tree903ac422107125c058c61ddd4a8b43bbbdc54e80
parent1ac3ba2b3cc41645a30e49f93d3e09bd05e6d2c7
io_uring/rsrc: Simplify buffer cloning by locking both rings

The locking in the buffer cloning code is somewhat complex because it goes
back and forth between locking the source ring and the destination ring.

Make it easier to reason about by locking both rings at the same time.
To avoid ABBA deadlocks, lock the rings in ascending kernel address order,
just like in lock_two_nondirectories().

Signed-off-by: Jann Horn <jannh@google.com>
Link: https://lore.kernel.org/r/20250115-uring-clone-refactor-v2-1-7289ba50776d@google.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
io_uring/rsrc.c