]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/commitdiff
5.6-stable patches
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 14 Apr 2020 17:43:22 +0000 (19:43 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 14 Apr 2020 17:43:22 +0000 (19:43 +0200)
added patches:
io_uring-honor-original-task-rlimit_fsize.patch

queue-5.6/io_uring-honor-original-task-rlimit_fsize.patch [new file with mode: 0644]
queue-5.6/series

diff --git a/queue-5.6/io_uring-honor-original-task-rlimit_fsize.patch b/queue-5.6/io_uring-honor-original-task-rlimit_fsize.patch
new file mode 100644 (file)
index 0000000..0cbbbe8
--- /dev/null
@@ -0,0 +1,82 @@
+From 4ed734b0d0913e566a9d871e15d24eb240f269f7 Mon Sep 17 00:00:00 2001
+From: Jens Axboe <axboe@kernel.dk>
+Date: Fri, 20 Mar 2020 11:23:41 -0600
+Subject: io_uring: honor original task RLIMIT_FSIZE
+
+From: Jens Axboe <axboe@kernel.dk>
+
+commit 4ed734b0d0913e566a9d871e15d24eb240f269f7 upstream.
+
+With the previous fixes for number of files open checking, I added some
+debug code to see if we had other spots where we're checking rlimit()
+against the async io-wq workers. The only one I found was file size
+checking, which we should also honor.
+
+During write and fallocate prep, store the max file size and override
+that for the current ask if we're in io-wq worker context.
+
+Cc: stable@vger.kernel.org # 5.1+
+Signed-off-by: Jens Axboe <axboe@kernel.dk>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+
+---
+ fs/io_uring.c |   13 +++++++++++++
+ 1 file changed, 13 insertions(+)
+
+--- a/fs/io_uring.c
++++ b/fs/io_uring.c
+@@ -565,6 +565,7 @@ struct io_kiocb {
+       struct list_head        link_list;
+       unsigned int            flags;
+       refcount_t              refs;
++      unsigned long           fsize;
+       u64                     user_data;
+       u32                     result;
+       u32                     sequence;
+@@ -2294,6 +2295,8 @@ static int io_write_prep(struct io_kiocb
+       if (unlikely(!(req->file->f_mode & FMODE_WRITE)))
+               return -EBADF;
++      req->fsize = rlimit(RLIMIT_FSIZE);
++
+       /* either don't need iovec imported or already have it */
+       if (!req->io || req->flags & REQ_F_NEED_CLEANUP)
+               return 0;
+@@ -2366,10 +2369,17 @@ static int io_write(struct io_kiocb *req
+               }
+               kiocb->ki_flags |= IOCB_WRITE;
++              if (!force_nonblock)
++                      current->signal->rlim[RLIMIT_FSIZE].rlim_cur = req->fsize;
++
+               if (req->file->f_op->write_iter)
+                       ret2 = call_write_iter(req->file, kiocb, &iter);
+               else
+                       ret2 = loop_rw_iter(WRITE, req->file, kiocb, &iter);
++
++              if (!force_nonblock)
++                      current->signal->rlim[RLIMIT_FSIZE].rlim_cur = RLIM_INFINITY;
++
+               /*
+                * Raw bdev writes will -EOPNOTSUPP for IOCB_NOWAIT. Just
+                * retry them without IOCB_NOWAIT.
+@@ -2512,8 +2522,10 @@ static void io_fallocate_finish(struct i
+       if (io_req_cancelled(req))
+               return;
++      current->signal->rlim[RLIMIT_FSIZE].rlim_cur = req->fsize;
+       ret = vfs_fallocate(req->file, req->sync.mode, req->sync.off,
+                               req->sync.len);
++      current->signal->rlim[RLIMIT_FSIZE].rlim_cur = RLIM_INFINITY;
+       if (ret < 0)
+               req_set_fail_links(req);
+       io_cqring_add_event(req, ret);
+@@ -2531,6 +2543,7 @@ static int io_fallocate_prep(struct io_k
+       req->sync.off = READ_ONCE(sqe->off);
+       req->sync.len = READ_ONCE(sqe->addr);
+       req->sync.mode = READ_ONCE(sqe->len);
++      req->fsize = rlimit(RLIMIT_FSIZE);
+       return 0;
+ }
index 46143a50856772f763b78e4bebb2652445819fe7..b029da37419a58cabc81c510793158af7cee1699 100644 (file)
@@ -163,3 +163,4 @@ time-namespace-fix-time_for_children-symlink.patch
 time-namespace-add-max_time_namespaces-ucount.patch
 crypto-rng-fix-a-refcounting-bug-in-crypto_rng_reset.patch
 crypto-mxs-dcp-fix-scatterlist-linearization-for-hash.patch
+io_uring-honor-original-task-rlimit_fsize.patch