From: Pavel Begunkov <[email protected]>
To: Jens Axboe <[email protected]>, [email protected]
Subject: [PATCH 2/9] io_uring: fix uninit old data for poll event upd
Date: Tue, 13 Apr 2021 02:58:39 +0100 [thread overview]
Message-ID: <ab08fd35b7652e977f9a475f01741b04102297f1.1618278933.git.asml.silence@gmail.com> (raw)
In-Reply-To: <[email protected]>
Both IORING_POLL_UPDATE_EVENTS and IORING_POLL_UPDATE_USER_DATA need
old_user_data to find/cancel a poll request, but it's set only for the
first one.
Signed-off-by: Pavel Begunkov <[email protected]>
---
fs/io_uring.c | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
diff --git a/fs/io_uring.c b/fs/io_uring.c
index 44342ff5c4e1..429ee5fd9044 100644
--- a/fs/io_uring.c
+++ b/fs/io_uring.c
@@ -5384,17 +5384,17 @@ static int io_poll_add_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe
if (!(flags & IORING_POLL_ADD_MULTI))
events |= EPOLLONESHOT;
poll->update_events = poll->update_user_data = false;
- if (flags & IORING_POLL_UPDATE_EVENTS) {
- poll->update_events = true;
+
+ if (flags & (IORING_POLL_UPDATE_EVENTS|IORING_POLL_UPDATE_USER_DATA)) {
poll->old_user_data = READ_ONCE(sqe->addr);
+ poll->update_events = flags & IORING_POLL_UPDATE_EVENTS;
+ poll->update_user_data = flags & IORING_POLL_UPDATE_USER_DATA;
+ if (poll->update_user_data)
+ poll->new_user_data = READ_ONCE(sqe->off);
+ } else {
+ if (sqe->off || sqe->addr)
+ return -EINVAL;
}
- if (flags & IORING_POLL_UPDATE_USER_DATA) {
- poll->update_user_data = true;
- poll->new_user_data = READ_ONCE(sqe->off);
- }
- if (!(poll->update_events || poll->update_user_data) &&
- (sqe->off || sqe->addr))
- return -EINVAL;
poll->events = demangle_poll(events) |
(events & (EPOLLEXCLUSIVE|EPOLLONESHOT));
return 0;
--
2.24.0
next prev parent reply other threads:[~2021-04-13 2:03 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-04-13 1:58 [PATCH 5.13 0/9] another 5.13 pack Pavel Begunkov
2021-04-13 1:58 ` [PATCH 1/9] io_uring: fix leaking reg files on exit Pavel Begunkov
2021-04-13 1:58 ` Pavel Begunkov [this message]
2021-04-13 1:58 ` [PATCH 3/9] io_uring: split poll and poll update structures Pavel Begunkov
2021-04-13 17:14 ` Pavel Begunkov
2021-04-13 1:58 ` [PATCH 4/9] io_uring: add timeout completion_lock annotation Pavel Begunkov
2021-04-13 1:58 ` [PATCH 5/9] io_uring: refactor hrtimer_try_to_cancel uses Pavel Begunkov
2021-04-13 1:58 ` [PATCH 6/9] io_uring: clean up io_poll_remove_waitqs() Pavel Begunkov
2021-04-13 1:58 ` [PATCH 7/9] io_uring: don't fail overflow on in_idle Pavel Begunkov
2021-04-13 1:58 ` [PATCH 8/9] io_uring: skip futile iopoll iterations Pavel Begunkov
2021-04-13 1:58 ` [PATCH 9/9] io_uring: inline io_iopoll_getevents() Pavel Begunkov
2021-04-13 15:38 ` [PATCH 5.13 0/9] another 5.13 pack 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=ab08fd35b7652e977f9a475f01741b04102297f1.1618278933.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