Messages in this thread | | | Subject | Re: [PATCH] io_uring: fix deferred req iovec leak | From | Jens Axboe <> | Date | Thu, 6 Feb 2020 12:56:57 -0700 |
| |
On 2/6/20 10:16 AM, Pavel Begunkov wrote: > On 06/02/2020 20:04, Pavel Begunkov wrote: >> On 06/02/2020 19:51, Pavel Begunkov wrote: >>> After defer, a request will be prepared, that includes allocating iovec >>> if needed, and then submitted through io_wq_submit_work() but not custom >>> handler (e.g. io_rw_async()/io_sendrecv_async()). However, it'll leak >>> iovec, as it's in io-wq and the code goes as follows: >>> >>> io_read() { >>> if (!io_wq_current_is_worker()) >>> kfree(iovec); >>> } >>> >>> Put all deallocation logic in io_{read,write,send,recv}(), which will >>> leave the memory, if going async with -EAGAIN. >>> >> Interestingly, this will fail badly if it returns -EAGAIN from io-wq context. >> Apparently, I need to do v2. >> > Or not... > Jens, can you please explain what's with the -EAGAIN handling in > io_wq_submit_work()? Checking the code, it seems neither of > read/write/recv/send can return -EAGAIN from async context (i.e. > force_nonblock=false). Are there other ops that can do it?
Nobody should return -EAGAIN with force_nonblock=false, they should end the io_kiocb inline for that.
-- Jens Axboe
| |