diff options
author | Jens Axboe <axboe@kernel.dk> | 2020-03-20 02:23:18 +0100 |
---|---|---|
committer | Jens Axboe <axboe@kernel.dk> | 2020-03-20 15:47:27 +0100 |
commit | 4022e7af86be2dd62975dedb6b7ea551d108695e (patch) | |
tree | f8fe39d2782257cac15532721624a766f670442e /fs/file.c | |
parent | io_uring: NULL-deref for IOSQE_{ASYNC,DRAIN} (diff) | |
download | linux-4022e7af86be2dd62975dedb6b7ea551d108695e.tar.xz linux-4022e7af86be2dd62975dedb6b7ea551d108695e.zip |
io_uring: make sure openat/openat2 honor rlimit nofile
Dmitry reports that a test case shows that io_uring isn't honoring a
modified rlimit nofile setting. get_unused_fd_flags() checks the task
signal->rlimi[] for the limits. As this isn't easily inheritable,
provide a __get_unused_fd_flags() that takes the value instead. Then we
can grab it when the request is prepared (from the original task), and
pass that in when we do the async part part of the open.
Reported-by: Dmitry Kadashev <dkadashev@gmail.com>
Tested-by: Dmitry Kadashev <dkadashev@gmail.com>
Acked-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'fs/file.c')
-rw-r--r-- | fs/file.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/fs/file.c b/fs/file.c index a364e1a9b7e8..c8a4e4c86e55 100644 --- a/fs/file.c +++ b/fs/file.c @@ -540,9 +540,14 @@ static int alloc_fd(unsigned start, unsigned flags) return __alloc_fd(current->files, start, rlimit(RLIMIT_NOFILE), flags); } +int __get_unused_fd_flags(unsigned flags, unsigned long nofile) +{ + return __alloc_fd(current->files, 0, nofile, flags); +} + int get_unused_fd_flags(unsigned flags) { - return __alloc_fd(current->files, 0, rlimit(RLIMIT_NOFILE), flags); + return __get_unused_fd_flags(flags, rlimit(RLIMIT_NOFILE)); } EXPORT_SYMBOL(get_unused_fd_flags); |