io_uring: fix drain stalls by invalid SQE
authorPavel Begunkov <asml.silence@gmail.com>
Wed, 9 Aug 2023 12:21:41 +0000 (13:21 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 13 Sep 2023 07:42:43 +0000 (09:42 +0200)
commit0c323430e470c922af54cebf1134d7b62144ecfa
tree333b23f3cfe6cfbfe72fa1528c826334b9cb147a
parent9183c4fe9141e6575c801aad2d9fa23b4855d763
io_uring: fix drain stalls by invalid SQE

[ Upstream commit cfdbaa3a291d6fd2cb4a1a70d74e63b4abc2f5ec ]

cq_extra is protected by ->completion_lock, which io_get_sqe() misses.
The bug is harmless as it doesn't happen in real life, requires invalid
SQ index array and racing with submission, and only messes up the
userspace, i.e. stall requests execution but will be cleaned up on
ring destruction.

Fixes: 15641e427070f ("io_uring: don't cache number of dropped SQEs")
Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
Link: https://lore.kernel.org/r/66096d54651b1a60534bb2023f2947f09f50ef73.1691538547.git.asml.silence@gmail.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Sasha Levin <sashal@kernel.org>
io_uring/io_uring.c