diff mbox series

[5.10,002/306] io_uring: limit fixed table size by RLIMIT_NOFILE

Message ID 20210916155753.989906303@linuxfoundation.org
State New
Headers show
Series None | expand

Commit Message

Greg Kroah-Hartman Sept. 16, 2021, 3:55 p.m. UTC
From: Pavel Begunkov <asml.silence@gmail.com>

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>
---
 fs/io_uring.c |    2 ++
 1 file changed, 2 insertions(+)

Comments

Pavel Machek Sept. 19, 2021, 7:04 p.m. UTC | #1
Hi!

> From: Pavel Begunkov <asml.silence@gmail.com>

> 

> 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


5.13 and 5.14 backports do have "upstream" marking, but this one does
not. It is commit 3a1b8a4e843f96b636431450d8d79061605cf74b
upstream. But I guess it is too late to fix that.

Best regards,
								Pavel

-- 
DENX Software Engineering GmbH,      Managing Director:    Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194    Groebenzell, Germany
diff mbox series

Patch

--- a/fs/io_uring.c
+++ b/fs/io_uring.c
@@ -7579,6 +7579,8 @@  static int io_sqe_files_register(struct
 		return -EINVAL;
 	if (nr_args > IORING_MAX_FIXED_FILES)
 		return -EMFILE;
+	if (nr_args > rlimit(RLIMIT_NOFILE))
+		return -EMFILE;
 
 	file_data = kzalloc(sizeof(*ctx->file_data), GFP_KERNEL);
 	if (!file_data)