public inbox for [email protected]
 help / color / mirror / Atom feed
From: Pavel Begunkov <[email protected]>
To: Jens Axboe <[email protected]>, [email protected]
Subject: [PATCH 3/4] io_uring: fix ovelapped memcpy in io_req_map_rw()
Date: Sun,  6 Sep 2020 00:45:47 +0300	[thread overview]
Message-ID: <2acfe0165377015983a0f285bf6242f8fa4232d6.1599341028.git.asml.silence@gmail.com> (raw)
In-Reply-To: <[email protected]>

When io_req_map_rw() is called from io_rw_prep_async(), it memcpy()
iorw->iter into itself. Even though it doesn't lead to an error, such a
memcpy()'s aliasing rules violation is considered to be a bad practise.

Inline io_req_map_rw() into io_rw_prep_async(). We don't really need any
remapping there, so it's much simpler than the generic implementation.

Signed-off-by: Pavel Begunkov <[email protected]>
---
 fs/io_uring.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/fs/io_uring.c b/fs/io_uring.c
index 03808e865dde..fc2aaaaca908 100644
--- a/fs/io_uring.c
+++ b/fs/io_uring.c
@@ -2986,7 +2986,10 @@ static inline int io_rw_prep_async(struct io_kiocb *req, int rw,
 	if (unlikely(ret < 0))
 		return ret;
 
-	io_req_map_rw(req, iov, iorw->fast_iov, &iorw->iter);
+	iorw->bytes_done = 0;
+	iorw->free_iovec = iov;
+	if (iov)
+		req->flags |= REQ_F_NEED_CLEANUP;
 	return 0;
 }
 
-- 
2.24.0


  parent reply	other threads:[~2020-09-05 21:48 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-05 21:45 [PATCH 0/4] iov remapping hardening Pavel Begunkov
2020-09-05 21:45 ` [PATCH 1/4] io_uring: simplify io_rw_prep_async() Pavel Begunkov
2020-09-05 21:45 ` [PATCH 2/4] io_uring: refactor io_req_map_rw() Pavel Begunkov
2020-09-05 21:45 ` Pavel Begunkov [this message]
2020-09-05 21:45 ` [PATCH 4/4] io_uring: kill extra user_bufs check Pavel Begunkov
2020-09-05 21:58 ` [PATCH 0/4] iov remapping hardening Jens Axboe
2020-09-05 22:15   ` Pavel Begunkov
2020-09-05 22:34     ` Jens Axboe
2020-09-05 22:51       ` 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=2acfe0165377015983a0f285bf6242f8fa4232d6.1599341028.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