summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPavel Begunkov <asml.silence@gmail.com>2021-08-20 10:36:35 +0100
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2021-09-15 10:02:32 +0200
commit917342c3714358991d8ac2bd29bff8f6ea62f077 (patch)
treefc5fa4502dddb376b3e32e1017b8dc6db85e3698
parent1b19425f8e2af878840897d09b3d2759b254d04e (diff)
downloadlinux-stable-917342c3714358991d8ac2bd29bff8f6ea62f077.tar.gz
linux-stable-917342c3714358991d8ac2bd29bff8f6ea62f077.tar.bz2
linux-stable-917342c3714358991d8ac2bd29bff8f6ea62f077.zip
io_uring: limit fixed table size by RLIMIT_NOFILE
commit 3a1b8a4e843f96b636431450d8d79061605cf74b upstream. Limit the number of files in io_uring fixed tables by RLIMIT_NOFILE, that's the first and the simpliest restriction that we should impose. Cc: stable@vger.kernel.org Suggested-by: Jens Axboe <axboe@kernel.dk> Signed-off-by: Pavel Begunkov <asml.silence@gmail.com> Link: https://lore.kernel.org/r/b2756c340aed7d6c0b302c26dab50c6c5907f4ce.1629451684.git.asml.silence@gmail.com Signed-off-by: Jens Axboe <axboe@kernel.dk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--fs/io_uring.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/fs/io_uring.c b/fs/io_uring.c
index a2e20a6fbfed..0d6f1b335fb3 100644
--- a/fs/io_uring.c
+++ b/fs/io_uring.c
@@ -7722,6 +7722,8 @@ static int io_sqe_files_register(struct io_ring_ctx *ctx, void __user *arg,
return -EINVAL;
if (nr_args > IORING_MAX_FIXED_FILES)
return -EMFILE;
+ if (nr_args > rlimit(RLIMIT_NOFILE))
+ return -EMFILE;
ret = io_rsrc_node_switch_start(ctx);
if (ret)
return ret;