From: Pavel Begunkov <[email protected]>
To: [email protected]
Cc: Jens Axboe <[email protected]>, [email protected]
Subject: [PATCH 3/7] io_uring: extend provided buf return to fails
Date: Thu, 17 Mar 2022 02:03:38 +0000 [thread overview]
Message-ID: <a4880106fcf199d5810707fe2d17126fcdf18bc4.1647481208.git.asml.silence@gmail.com> (raw)
In-Reply-To: <[email protected]>
It's never a good idea to put provided buffers without notifying the
userspace, it'll lead to userspace leaks, so add io_put_kbuf() in
io_req_complete_failed(). The fail helper is called by all sorts of
requests, but it's still safe to do as io_put_kbuf() will return 0 in
for all requests that don't support and so don't expect provided buffers.
btw, remove some code duplication from kiocb_done().
Signed-off-by: Pavel Begunkov <[email protected]>
---
fs/io_uring.c | 12 ++++--------
1 file changed, 4 insertions(+), 8 deletions(-)
diff --git a/fs/io_uring.c b/fs/io_uring.c
index b4b12aa7d107..bbbbf889dfd8 100644
--- a/fs/io_uring.c
+++ b/fs/io_uring.c
@@ -2116,7 +2116,7 @@ static inline void io_req_complete(struct io_kiocb *req, s32 res)
static void io_req_complete_failed(struct io_kiocb *req, s32 res)
{
req_set_fail(req);
- io_req_complete_post(req, res, 0);
+ io_req_complete_post(req, res, io_put_kbuf(req, 0));
}
static void io_req_complete_fail_submit(struct io_kiocb *req)
@@ -3225,14 +3225,10 @@ static void kiocb_done(struct io_kiocb *req, ssize_t ret,
if (req->flags & REQ_F_REISSUE) {
req->flags &= ~REQ_F_REISSUE;
- if (io_resubmit_prep(req)) {
+ if (io_resubmit_prep(req))
io_req_task_queue_reissue(req);
- } else {
- req_set_fail(req);
- req->result = ret;
- req->io_task_work.func = io_req_task_complete;
- io_req_task_work_add(req, false);
- }
+ else
+ io_req_task_queue_fail(req, ret);
}
}
--
2.35.1
next prev parent reply other threads:[~2022-03-17 2:05 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-17 2:03 [PATCH for-next 0/7] completion path optimisations Pavel Begunkov
2022-03-17 2:03 ` [PATCH 1/7] io_uring: normilise naming for fill_cqe* Pavel Begunkov
2022-03-17 2:03 ` [PATCH 2/7] io_uring: refactor timeout cancellation cqe posting Pavel Begunkov
2022-03-17 2:03 ` Pavel Begunkov [this message]
2022-03-17 2:14 ` [PATCH 3/7] io_uring: extend provided buf return to fails Jens Axboe
2022-03-17 2:03 ` [PATCH 4/7] io_uring: remove extra barrier for non-sqpoll iopoll Pavel Begunkov
2022-03-17 2:03 ` [PATCH 5/7] io_uring: shuffle io_eventfd_signal() bits around Pavel Begunkov
2022-03-17 2:03 ` [PATCH 6/7] io_uring: thin down io_commit_cqring() Pavel Begunkov
2022-03-17 2:03 ` [PATCH 7/7] io_uring: fold evfd signalling under a slower path Pavel Begunkov
2022-03-17 12:31 ` [PATCH for-next 0/7] completion path optimisations Jens Axboe
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=a4880106fcf199d5810707fe2d17126fcdf18bc4.1647481208.git.asml.silence@gmail.com \
[email protected] \
[email protected] \
[email protected] \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox