]> git.baikalelectronics.ru Git - kernel.git/commit
io_uring: initialize io_buffer_list head when shared ring is unregistered
authorJens Axboe <axboe@kernel.dk>
Wed, 18 May 2022 20:36:18 +0000 (14:36 -0600)
committerJens Axboe <axboe@kernel.dk>
Wed, 18 May 2022 22:21:11 +0000 (16:21 -0600)
commit4139c20931f3bcfca4f3cbe59f9ce8390987f337
tree8d8d1169009625c9b34280fe2a74dcfe67fce4a6
parenta2d4a77fc4d85e9b9c365d0b41e4ce6992683979
io_uring: initialize io_buffer_list head when shared ring is unregistered

We use ->buf_pages != 0 to tell if this is a shared buffer ring or a
classic provided buffer group. If we unregister the shared ring and
then attempt to use it, buf_pages is zero yet the classic list head
isn't properly initialized. This causes io_buffer_select() to think
that we have classic buffers available, but then we crash when we try
and get one from the list.

Just initialize the list if we unregister a shared buffer ring, leaving
it in a sane state for either re-registration or for attempting to use
it. And do the same for the initial setup from the classic path.

Fixes: e790404d1245 ("io_uring: add support for ring mapped supplied buffers")
Signed-off-by: Jens Axboe <axboe@kernel.dk>
fs/io_uring.c