]> git.baikalelectronics.ru Git - kernel.git/commitdiff
io_uring: remove bogus RLIMIT_NOFILE check in file registration
authorJens Axboe <axboe@kernel.dk>
Fri, 3 Apr 2020 19:54:26 +0000 (13:54 -0600)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 17 Apr 2020 08:50:11 +0000 (10:50 +0200)
commit 4bea2adc406b9b720b57ad3febd38be9603842dc upstream.

We already checked this limit when the file was opened, and we keep it
open in the file table. Hence when we added unit_inflight to the count
we want to register, we're doubly accounting these files. This results
in -EMFILE for file registration, if we're at half the limit.

Cc: stable@vger.kernel.org # v5.1+
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/io_uring.c

index e37b841464537312c08f840120b218ef5ed83ddf..134964ae61f9bc20bbf50fd2c501ef71dfdcea9b 100644 (file)
@@ -3092,13 +3092,6 @@ static int __io_sqe_files_scm(struct io_ring_ctx *ctx, int nr, int offset)
        struct sk_buff *skb;
        int i;
 
-       if (!capable(CAP_SYS_RESOURCE) && !capable(CAP_SYS_ADMIN)) {
-               unsigned long inflight = ctx->user->unix_inflight + nr;
-
-               if (inflight > task_rlimit(current, RLIMIT_NOFILE))
-                       return -EMFILE;
-       }
-
        fpl = kzalloc(sizeof(*fpl), GFP_KERNEL);
        if (!fpl)
                return -ENOMEM;