summaryrefslogtreecommitdiff
path: root/fs
diff options
context:
space:
mode:
authorJens Axboe <axboe@kernel.dk>2020-03-20 20:23:41 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2020-04-17 11:50:16 +0300
commit7661469ef56e15c2c32fa4b7be126a6b91e265a5 (patch)
treee9b7f3d84328547438f0a159b8ae407f2fad3aa9 /fs
parenta181a74610e634e117c796b802d68421b5124eb6 (diff)
downloadlinux-7661469ef56e15c2c32fa4b7be126a6b91e265a5.tar.xz
io_uring: honor original task RLIMIT_FSIZE
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>
Diffstat (limited to 'fs')
-rw-r--r--fs/io_uring.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/fs/io_uring.c b/fs/io_uring.c
index 134964ae61f9..b2ccb908f6b6 100644
--- a/fs/io_uring.c
+++ b/fs/io_uring.c
@@ -331,6 +331,7 @@ struct io_kiocb {
#define REQ_F_ISREG 2048 /* regular file */
#define REQ_F_MUST_PUNT 4096 /* must be punted even for NONBLOCK */
#define REQ_F_TIMEOUT_NOSEQ 8192 /* no timeout sequence */
+ unsigned long fsize;
u64 user_data;
u32 result;
u32 sequence;
@@ -1085,6 +1086,9 @@ static int io_prep_rw(struct io_kiocb *req, const struct sqe_submit *s,
if (S_ISREG(file_inode(req->file)->i_mode))
req->flags |= REQ_F_ISREG;
+ if (force_nonblock)
+ req->fsize = rlimit(RLIMIT_FSIZE);
+
/*
* If the file doesn't support async, mark it as REQ_F_MUST_PUNT so
* we know to async punt it even if it was opened O_NONBLOCK
@@ -1504,10 +1508,17 @@ static int io_write(struct io_kiocb *req, const struct sqe_submit *s,
}
kiocb->ki_flags |= IOCB_WRITE;
+ if (!force_nonblock)
+ current->signal->rlim[RLIMIT_FSIZE].rlim_cur = req->fsize;
+
if (file->f_op->write_iter)
ret2 = call_write_iter(file, kiocb, &iter);
else
ret2 = loop_rw_iter(WRITE, file, kiocb, &iter);
+
+ if (!force_nonblock)
+ current->signal->rlim[RLIMIT_FSIZE].rlim_cur = RLIM_INFINITY;
+
if (!force_nonblock || ret2 != -EAGAIN) {
io_rw_done(kiocb, ret2);
} else {