]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
file: In f_dupfd read RLIMIT_NOFILE once.
authorEric W. Biederman <ebiederm@xmission.com>
Fri, 20 Nov 2020 23:14:36 +0000 (17:14 -0600)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 21 Jun 2024 12:52:49 +0000 (14:52 +0200)
commit9e8ef54ca890eda6f1993405684a68cc8dff06e7
tree5728ab7b1f333694fa88bbe1200b7415799b845c
parent89f9e529643ab5b1a98b98e30ac4177d0f7ba1cc
file: In f_dupfd read RLIMIT_NOFILE once.

Simplify the code, and remove the chance of races by reading
RLIMIT_NOFILE only once in f_dupfd.

Pass the read value of RLIMIT_NOFILE into alloc_fd which is the other
location the rlimit was read in f_dupfd.  As f_dupfd is the only
caller of alloc_fd this changing alloc_fd is trivially safe.

Further this causes alloc_fd to take all of the same arguments as
__alloc_fd except for the files_struct argument.

Acked-by: Christian Brauner <christian.brauner@ubuntu.com>
v1: https://lkml.kernel.org/r/20200817220425.9389-15-ebiederm@xmission.com
Link: https://lkml.kernel.org/r/20201120231441.29911-19-ebiederm@xmission.com
Signed-off-by: Eric W. Biederman <ebiederm@xmission.com>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
fs/file.c