]> git.baikalelectronics.ru Git - kernel.git/commit
io_uring/net: cache provided buffer group value for multishot receives
authorJens Axboe <axboe@kernel.dk>
Sun, 22 Jan 2023 17:02:55 +0000 (10:02 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 1 Feb 2023 07:34:38 +0000 (08:34 +0100)
commit0aee01d14b65daf06a921d150ab9792e6beeac16
tree6124293c1df134a854c316fbb28d33d8a03ae18d
parent27593bf79844f4d2de0034fa07121f3bc9aab1f5
io_uring/net: cache provided buffer group value for multishot receives

commit 2779635a7dc88d74db0583d964cf00105374846a upstream.

If we're using ring provided buffers with multishot receive, and we end
up doing an io-wq based issue at some points that also needs to select
a buffer, we'll lose the initially assigned buffer group as
io_ring_buffer_select() correctly clears the buffer group list as the
issue isn't serialized by the ctx uring_lock. This is fine for normal
receives as the request puts the buffer and finishes, but for multishot,
we will re-arm and do further receives. On the next trigger for this
multishot receive, the receive will try and pick from a buffer group
whose value is the same as the buffer ID of the las receive. That is
obviously incorrect, and will result in a premature -ENOUFS error for
the receive even if we had available buffers in the correct group.

Cache the buffer group value at prep time, so we can restore it for
future receives. This only needs doing for the above mentioned case, but
just do it by default to keep it easier to read.

Cc: stable@vger.kernel.org
Fixes: d1967183598e ("io_uring: multishot recv")
Fixes: 8d4d73328bf3 ("io_uring: support multishot in recvmsg")
Cc: Dylan Yudaken <dylany@meta.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
io_uring/net.c