]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/commitdiff
5.6-stable patches
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 4 May 2020 16:42:10 +0000 (18:42 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 4 May 2020 16:42:10 +0000 (18:42 +0200)
added patches:
io_uring-statx-must-grab-the-file-table-for-valid-fd.patch

queue-5.6/io_uring-statx-must-grab-the-file-table-for-valid-fd.patch [new file with mode: 0644]
queue-5.6/series

diff --git a/queue-5.6/io_uring-statx-must-grab-the-file-table-for-valid-fd.patch b/queue-5.6/io_uring-statx-must-grab-the-file-table-for-valid-fd.patch
new file mode 100644 (file)
index 0000000..8396534
--- /dev/null
@@ -0,0 +1,80 @@
+From 5b0bbee4732cbd58aa98213d4c11a366356bba3d Mon Sep 17 00:00:00 2001
+From: Jens Axboe <axboe@kernel.dk>
+Date: Mon, 27 Apr 2020 10:41:22 -0600
+Subject: io_uring: statx must grab the file table for valid fd
+
+From: Jens Axboe <axboe@kernel.dk>
+
+commit 5b0bbee4732cbd58aa98213d4c11a366356bba3d upstream.
+
+Clay reports that OP_STATX fails for a test case with a valid fd
+and empty path:
+
+ -- Test 0: statx:fd 3: SUCCEED, file mode 100755
+ -- Test 1: statx:path ./uring_statx: SUCCEED, file mode 100755
+ -- Test 2: io_uring_statx:fd 3: FAIL, errno 9: Bad file descriptor
+ -- Test 3: io_uring_statx:path ./uring_statx: SUCCEED, file mode 100755
+
+This is due to statx not grabbing the process file table, hence we can't
+lookup the fd in async context. If the fd is valid, ensure that we grab
+the file table so we can grab the file from async context.
+
+Cc: stable@vger.kernel.org # v5.6
+Reported-by: Clay Harris <bugs@claycon.org>
+Signed-off-by: Jens Axboe <axboe@kernel.dk>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ fs/io_uring.c |   12 ++++++++++--
+ 1 file changed, 10 insertions(+), 2 deletions(-)
+
+--- a/fs/io_uring.c
++++ b/fs/io_uring.c
+@@ -479,6 +479,7 @@ enum {
+       REQ_F_COMP_LOCKED_BIT,
+       REQ_F_NEED_CLEANUP_BIT,
+       REQ_F_OVERFLOW_BIT,
++      REQ_F_NO_FILE_TABLE_BIT,
+ };
+ enum {
+@@ -521,6 +522,8 @@ enum {
+       REQ_F_NEED_CLEANUP      = BIT(REQ_F_NEED_CLEANUP_BIT),
+       /* in overflow list */
+       REQ_F_OVERFLOW          = BIT(REQ_F_OVERFLOW_BIT),
++      /* doesn't need file table for this request */
++      REQ_F_NO_FILE_TABLE     = BIT(REQ_F_NO_FILE_TABLE_BIT),
+ };
+ /*
+@@ -711,6 +714,7 @@ static const struct io_op_def io_op_defs
+               .needs_file             = 1,
+               .fd_non_neg             = 1,
+               .needs_fs               = 1,
++              .file_table             = 1,
+       },
+       [IORING_OP_READ] = {
+               .needs_mm               = 1,
+@@ -2843,8 +2847,12 @@ static int io_statx(struct io_kiocb *req
+       struct kstat stat;
+       int ret;
+-      if (force_nonblock)
++      if (force_nonblock) {
++              /* only need file table for an actual valid fd */
++              if (ctx->dfd == -1 || ctx->dfd == AT_FDCWD)
++                      req->flags |= REQ_F_NO_FILE_TABLE;
+               return -EAGAIN;
++      }
+       if (vfs_stat_set_lookup_flags(&lookup_flags, ctx->how.flags))
+               return -EINVAL;
+@@ -4632,7 +4640,7 @@ static int io_grab_files(struct io_kiocb
+       int ret = -EBADF;
+       struct io_ring_ctx *ctx = req->ctx;
+-      if (req->work.files)
++      if (req->work.files || (req->flags & REQ_F_NO_FILE_TABLE))
+               return 0;
+       if (!ctx->ring_file)
+               return -EBADF;
index bdc1ae45eddae46cd3ef615634ce54b7e0d282f4..0710f45eda1bcf02be56aa959a34cd344b36c0c8 100644 (file)
@@ -70,3 +70,4 @@ dmaengine-dmatest-fix-iteration-non-stop-logic.patch
 drm-i915-use-proper-fault-mask-in-interrupt-postinstall-too.patch
 dmaengine-dmatest-fix-process-hang-when-reading-wait-parameter.patch
 arm64-vdso-add-fasynchronous-unwind-tables-to-cflags.patch
+io_uring-statx-must-grab-the-file-table-for-valid-fd.patch