From: Dylan Yudaken Date: Thu, 30 Jun 2022 13:20:06 +0000 (-0700) Subject: io_uring: fix provided buffer import X-Git-Tag: baikal/mips/sdk6.1~5391^2 X-Git-Url: https://git.baikalelectronics.ru/sdk/?a=commitdiff_plain;h=9c59c09ca7e547827e5906785cdb83e32c623a98;p=kernel.git io_uring: fix provided buffer import io_import_iovec uses the s pointer, but this was changed immediately after the iovec was re-imported and so it was imported into the wrong place. Change the ordering. Fixes: f2fc9832203d ("io_uring: ensure reads re-import for selected buffers") Signed-off-by: Dylan Yudaken Link: https://lore.kernel.org/r/20220630132006.2825668-1-dylany@fb.com [axboe: ensure we don't half-import as well] Signed-off-by: Jens Axboe --- diff --git a/fs/io_uring.c b/fs/io_uring.c index aeb042ba5cc53..0d491ad15b66a 100644 --- a/fs/io_uring.c +++ b/fs/io_uring.c @@ -4318,18 +4318,19 @@ static int io_read(struct io_kiocb *req, unsigned int issue_flags) if (unlikely(ret < 0)) return ret; } else { + rw = req->async_data; + s = &rw->s; + /* * Safe and required to re-import if we're using provided * buffers, as we dropped the selected one before retry. */ - if (req->flags & REQ_F_BUFFER_SELECT) { + if (io_do_buffer_select(req)) { ret = io_import_iovec(READ, req, &iovec, s, issue_flags); if (unlikely(ret < 0)) return ret; } - rw = req->async_data; - s = &rw->s; /* * We come here from an earlier attempt, restore our state to * match in case it doesn't. It's cheap enough that we don't