io_uring: fix put_kbuf without proper locking
authorPavel Begunkov <asml.silence@gmail.com>
Fri, 25 Mar 2022 13:00:43 +0000 (13:00 +0000)
committerJens Axboe <axboe@kernel.dk>
Fri, 25 Mar 2022 13:43:53 +0000 (07:43 -0600)
commit8197b053a83335dd1b7eb7581a933924e25c1025
tree3844abb6d83a181ff588b15861ad7589a0da2702
parentab0ac0959b028779ea43002db81daa12203cb57d
io_uring: fix put_kbuf without proper locking

io_put_kbuf_comp() should only be called while holding
->completion_lock, however there is no such assumption in io_clean_op()
and thus it can corrupt ->io_buffer_comp. Take the lock there, and
workaround the only user of io_clean_op() calling it with locks. Not
the prettiest solution, but it's easier to refactor it for-next.

Fixes: cc3cec8367cba ("io_uring: speedup provided buffer handling")
Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
Link: https://lore.kernel.org/r/743e2130b73ec6d48c4c5dd15db896c433431e6d.1648212967.git.asml.silence@gmail.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
fs/io_uring.c