From: Pavel Begunkov <[email protected]>
To: [email protected]
Cc: [email protected], Anuj Gupta <[email protected]>,
Kanchan Joshi <[email protected]>
Subject: [PATCH 3/4] io_uring/rw: use READ_ONCE with rw attributes
Date: Mon, 30 Dec 2024 13:30:23 +0000 [thread overview]
Message-ID: <fbe4711906a9680da6be390548f916d7e2da15c3.1735301337.git.asml.silence@gmail.com> (raw)
In-Reply-To: <[email protected]>
In preparation to pre-mapped attributes read struct io_uring_attr_pi
with READ_ONCE and use an intermediate pointer.
Signed-off-by: Pavel Begunkov <[email protected]>
---
io_uring/rw.c | 22 ++++++++++++++--------
1 file changed, 14 insertions(+), 8 deletions(-)
diff --git a/io_uring/rw.c b/io_uring/rw.c
index 75f70935ccf4..dc1acaf95db1 100644
--- a/io_uring/rw.c
+++ b/io_uring/rw.c
@@ -264,23 +264,29 @@ static inline void io_meta_restore(struct io_async_rw *io, struct kiocb *kiocb)
static int io_prep_rw_pi(struct io_kiocb *req, struct io_rw *rw, int ddir,
u64 attr_ptr, u64 attr_type_mask)
{
- struct io_uring_attr_pi pi_attr;
+ struct io_uring_attr_pi __pi_attr;
+ struct io_uring_attr_pi *pi_attr;
struct io_async_rw *io;
+ void __user *pi_addr;
+ size_t pi_len;
int ret;
- if (copy_from_user(&pi_attr, u64_to_user_ptr(attr_ptr),
+ if (copy_from_user(&__pi_attr, u64_to_user_ptr(attr_ptr),
sizeof(pi_attr)))
return -EFAULT;
+ pi_attr = &__pi_attr;
- if (pi_attr.rsvd)
+ if (pi_attr->rsvd)
return -EINVAL;
io = req->async_data;
- io->meta.flags = pi_attr.flags;
- io->meta.app_tag = pi_attr.app_tag;
- io->meta.seed = pi_attr.seed;
- ret = import_ubuf(ddir, u64_to_user_ptr(pi_attr.addr),
- pi_attr.len, &io->meta.iter);
+ io->meta.flags = READ_ONCE(pi_attr->flags);
+ io->meta.app_tag = READ_ONCE(pi_attr->app_tag);
+ io->meta.seed = READ_ONCE(pi_attr->seed);
+
+ pi_addr = u64_to_user_ptr(READ_ONCE(pi_attr->addr));
+ pi_len = READ_ONCE(pi_attr->len);
+ ret = import_ubuf(ddir, pi_addr, pi_len, &io->meta.iter);
if (unlikely(ret < 0))
return ret;
req->flags |= REQ_F_HAS_METADATA;
--
2.47.1
next prev parent reply other threads:[~2024-12-30 13:29 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-12-30 13:30 [RFC 0/4] pre-mapped rw attributes Pavel Begunkov
2024-12-30 13:30 ` [PATCH 1/4] io_uring: add structure for registered arguments Pavel Begunkov
2024-12-30 13:30 ` [PATCH 2/4] io_uring: add registered request arguments Pavel Begunkov
2024-12-30 13:30 ` Pavel Begunkov [this message]
2024-12-30 13:30 ` [PATCH 4/4] io_uring/rw: pre-mapped rw attributes Pavel Begunkov
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=fbe4711906a9680da6be390548f916d7e2da15c3.1735301337.git.asml.silence@gmail.com \
[email protected] \
[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