public inbox for [email protected]
 help / color / mirror / Atom feed
From: Pavel Begunkov <[email protected]>
To: Jens Axboe <[email protected]>, [email protected]
Subject: [PATCH 4/4] io_uring: kill extra user_bufs check
Date: Sun,  6 Sep 2020 00:45:48 +0300	[thread overview]
Message-ID: <bf649f4931ad406bfa4b4f1730d7de120fbd0a06.1599341028.git.asml.silence@gmail.com> (raw)
In-Reply-To: <[email protected]>

Testing ctx->user_bufs for NULL in io_import_fixed() is not neccessary,
because in that case ctx->nr_user_bufs would be zero, and the following
check would fail.

Signed-off-by: Pavel Begunkov <[email protected]>
---
 fs/io_uring.c | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/fs/io_uring.c b/fs/io_uring.c
index fc2aaaaca908..2e3adf9d17dd 100644
--- a/fs/io_uring.c
+++ b/fs/io_uring.c
@@ -2587,18 +2587,12 @@ static ssize_t io_import_fixed(struct io_kiocb *req, int rw,
 	struct io_ring_ctx *ctx = req->ctx;
 	size_t len = req->rw.len;
 	struct io_mapped_ubuf *imu;
-	u16 index, buf_index;
+	u16 index, buf_index = req->buf_index;
 	size_t offset;
 	u64 buf_addr;
 
-	/* attempt to use fixed buffers without having provided iovecs */
-	if (unlikely(!ctx->user_bufs))
-		return -EFAULT;
-
-	buf_index = req->buf_index;
 	if (unlikely(buf_index >= ctx->nr_user_bufs))
 		return -EFAULT;
-
 	index = array_index_nospec(buf_index, ctx->nr_user_bufs);
 	imu = &ctx->user_bufs[index];
 	buf_addr = req->rw.addr;
-- 
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 ` [PATCH 3/4] io_uring: fix ovelapped memcpy in io_req_map_rw() Pavel Begunkov
2020-09-05 21:45 ` Pavel Begunkov [this message]
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=bf649f4931ad406bfa4b4f1730d7de120fbd0a06.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