From: Greg Kroah-Hartman Date: Tue, 14 Apr 2020 17:43:06 +0000 (+0200) Subject: 5.5-stable patches X-Git-Tag: v4.19.116~58 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=a365c68e22591eae412d9e53e3a368f0027bdb03;p=thirdparty%2Fkernel%2Fstable-queue.git 5.5-stable patches added patches: io_uring-honor-original-task-rlimit_fsize.patch --- diff --git a/queue-5.5/io_uring-honor-original-task-rlimit_fsize.patch b/queue-5.5/io_uring-honor-original-task-rlimit_fsize.patch new file mode 100644 index 00000000000..aac601c062b --- /dev/null +++ b/queue-5.5/io_uring-honor-original-task-rlimit_fsize.patch @@ -0,0 +1,63 @@ +From 4ed734b0d0913e566a9d871e15d24eb240f269f7 Mon Sep 17 00:00:00 2001 +From: Jens Axboe +Date: Fri, 20 Mar 2020 11:23:41 -0600 +Subject: io_uring: honor original task RLIMIT_FSIZE + +From: Jens Axboe + +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 +Signed-off-by: Greg Kroah-Hartman + + +--- + fs/io_uring.c | 10 ++++++++++ + 1 file changed, 10 insertions(+) + +--- a/fs/io_uring.c ++++ b/fs/io_uring.c +@@ -432,6 +432,7 @@ struct io_kiocb { + #define REQ_F_INFLIGHT 16384 /* on inflight list */ + #define REQ_F_COMP_LOCKED 32768 /* completion under lock */ + #define REQ_F_HARDLINK 65536 /* doesn't sever on completion < 0 */ ++ unsigned long fsize; + u64 user_data; + u32 result; + u32 sequence; +@@ -1899,6 +1900,8 @@ static int io_write_prep(struct io_kiocb + if (unlikely(!(req->file->f_mode & FMODE_WRITE))) + return -EBADF; + ++ req->fsize = rlimit(RLIMIT_FSIZE); ++ + if (!req->io) + return 0; + +@@ -1970,10 +1973,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. diff --git a/queue-5.5/series b/queue-5.5/series index e546311cbbd..ddaac75ac85 100644 --- a/queue-5.5/series +++ b/queue-5.5/series @@ -170,3 +170,4 @@ remoteproc-qcom_q6v5_mss-reload-the-mba-region-on-coredump.patch remoteproc-fix-null-pointer-dereference-in-rproc_virtio_notify.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