From: Jens Axboe <axboe@kernel.dk>
To: linux-kernel@vger.kernel.org, netdev@vger.kernel.org
Cc: soheil@google.com, willemdebruijn.kernel@gmail.com,
stefanha@redhat.com, Jens Axboe <axboe@kernel.dk>
Subject: [PATCH 5/7] eventpoll: move file checking earlier for epoll_ctl()
Date: Thu, 1 Dec 2022 11:11:54 -0700 [thread overview]
Message-ID: <20221201181156.848373-6-axboe@kernel.dk> (raw)
In-Reply-To: <20221201181156.848373-1-axboe@kernel.dk>
This just cleans up the checking a bit, in preparation for a change
that will need access to 'ep' earlier.
Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
fs/eventpoll.c | 26 ++++++++++++++++----------
1 file changed, 16 insertions(+), 10 deletions(-)
diff --git a/fs/eventpoll.c b/fs/eventpoll.c
index 0994f2eb6adc..962d897bbfc6 100644
--- a/fs/eventpoll.c
+++ b/fs/eventpoll.c
@@ -2111,6 +2111,20 @@ int do_epoll_ctl(int epfd, int op, int fd, struct epoll_event *epds,
if (!f.file)
goto error_return;
+ /*
+ * We have to check that the file structure underneath the file
+ * descriptor the user passed to us _is_ an eventpoll file.
+ */
+ error = -EINVAL;
+ if (!is_file_epoll(f.file))
+ goto error_fput;
+
+ /*
+ * At this point it is safe to assume that the "private_data" contains
+ * our own data structure.
+ */
+ ep = f.file->private_data;
+
/* Get the "struct file *" for the target file */
tf = fdget(fd);
if (!tf.file)
@@ -2126,12 +2140,10 @@ int do_epoll_ctl(int epfd, int op, int fd, struct epoll_event *epds,
ep_take_care_of_epollwakeup(epds);
/*
- * We have to check that the file structure underneath the file descriptor
- * the user passed to us _is_ an eventpoll file. And also we do not permit
- * adding an epoll file descriptor inside itself.
+ * We do not permit adding an epoll file descriptor inside itself.
*/
error = -EINVAL;
- if (f.file == tf.file || !is_file_epoll(f.file))
+ if (f.file == tf.file)
goto error_tgt_fput;
/*
@@ -2147,12 +2159,6 @@ int do_epoll_ctl(int epfd, int op, int fd, struct epoll_event *epds,
goto error_tgt_fput;
}
- /*
- * At this point it is safe to assume that the "private_data" contains
- * our own data structure.
- */
- ep = f.file->private_data;
-
/*
* When we insert an epoll file descriptor inside another epoll file
* descriptor, there is the chance of creating closed loops, which are
--
2.35.1
next prev parent reply other threads:[~2022-12-01 18:12 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-12-01 18:11 [PATCHSET v4 0/7] Add support for epoll min_wait Jens Axboe
2022-12-01 18:11 ` [PATCH 1/7] eventpoll: cleanup branches around sleeping for events Jens Axboe
2022-12-01 18:11 ` [PATCH 2/7] eventpoll: don't pass in 'timed_out' to ep_busy_loop() Jens Axboe
2022-12-01 18:11 ` [PATCH 3/7] eventpoll: split out wait handling Jens Axboe
2022-12-01 18:11 ` [PATCH 4/7] eventpoll: move expires to epoll_wq Jens Axboe
2022-12-01 18:11 ` Jens Axboe [this message]
2022-12-01 18:11 ` [PATCH 6/7] eventpoll: add support for min-wait Jens Axboe
2022-12-01 18:11 ` [PATCH 7/7] eventpoll: add method for configuring minimum wait on epoll context 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=20221201181156.848373-6-axboe@kernel.dk \
--to=axboe@kernel.dk \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=soheil@google.com \
--cc=stefanha@redhat.com \
--cc=willemdebruijn.kernel@gmail.com \
/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
all inboxes | Powered by JetHome®