From: Max Kellermann <mk@cm4all.com>
To: axboe@kernel.dk, linux-fsdevel@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, Max Kellermann <mk@cm4all.com>,
stable@vger.kernel.org
Subject: [PATCH] fs/io_uring: fix O_PATH fds in openat, openat2, statx
Date: Thu, 7 May 2020 20:57:25 +0200 [thread overview]
Message-ID: <20200507185725.15840-1-mk@cm4all.com> (raw)
If an operation's flag `needs_file` is set, the function
io_req_set_file() calls io_file_get() to obtain a `struct file*`.
This fails for `O_PATH` file descriptors, because those have no
`struct file*`, causing io_req_set_file() to throw `-EBADF`. This
breaks the operations `openat`, `openat2` and `statx`, where `O_PATH`
file descriptors are commonly used.
The solution is to simply remove `needs_file` (and the accompanying
flag `fd_non_reg`). This flag was never needed because those
operations use numeric file descriptor and don't use the `struct
file*` obtained by io_req_set_file().
Signed-off-by: Max Kellermann <mk@cm4all.com>
Cc: stable@vger.kernel.org
---
fs/io_uring.c | 6 ------
1 file changed, 6 deletions(-)
diff --git a/fs/io_uring.c b/fs/io_uring.c
index a46de2cfc28e..d24f8e33323c 100644
--- a/fs/io_uring.c
+++ b/fs/io_uring.c
@@ -693,8 +693,6 @@ static const struct io_op_def io_op_defs[] = {
.needs_file = 1,
},
[IORING_OP_OPENAT] = {
- .needs_file = 1,
- .fd_non_neg = 1,
.file_table = 1,
.needs_fs = 1,
},
@@ -708,8 +706,6 @@ static const struct io_op_def io_op_defs[] = {
},
[IORING_OP_STATX] = {
.needs_mm = 1,
- .needs_file = 1,
- .fd_non_neg = 1,
.needs_fs = 1,
},
[IORING_OP_READ] = {
@@ -739,8 +735,6 @@ static const struct io_op_def io_op_defs[] = {
.unbound_nonreg_file = 1,
},
[IORING_OP_OPENAT2] = {
- .needs_file = 1,
- .fd_non_neg = 1,
.file_table = 1,
.needs_fs = 1,
},
--
2.20.1
next reply other threads:[~2020-05-07 18:57 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-05-07 18:57 Max Kellermann [this message]
2020-05-07 18:58 ` [PATCH] fs/io_uring: fix O_PATH fds in openat, openat2, statx Jens Axboe
2020-05-07 19:01 ` Max Kellermann
2020-05-07 19:01 ` Al Viro
2020-05-07 19:05 ` Max Kellermann
2020-05-07 19:05 ` Jens Axboe
2020-05-07 19:12 ` Max Kellermann
2020-05-07 19:29 ` Al Viro
2020-05-07 19:37 ` Max Kellermann
2020-05-07 20:53 ` Jens Axboe
2020-05-07 22:06 ` Al Viro
2020-05-07 22:25 ` Jens Axboe
2020-05-07 22:44 ` Al Viro
2020-05-07 23:03 ` Jens Axboe
2020-05-07 23:31 ` Al Viro
2020-05-08 2:28 ` Jens Axboe
2020-05-08 2:53 ` Jens Axboe
[not found] ` <20200508152918.12340-1-hdanton@sina.com>
2020-05-08 15:33 ` 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=20200507185725.15840-1-mk@cm4all.com \
--to=mk@cm4all.com \
--cc=axboe@kernel.dk \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=stable@vger.kernel.org \
/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;
as well as URLs for NNTP newsgroup(s).