fs: prevent out-of-bounds array speculation when closing a file descriptor

commit 609d544414 upstream.

Google-Bug-Id: 114199369
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
Theodore Ts'o 2023-03-06 13:54:50 -05:00 committed by Greg Kroah-Hartman
parent e7a701196c
commit f31cd5da63
1 changed files with 1 additions and 0 deletions

View File

@ -629,6 +629,7 @@ int __close_fd(struct files_struct *files, unsigned fd)
fdt = files_fdtable(files);
if (fd >= fdt->max_fds)
goto out_unlock;
fd = array_index_nospec(fd, fdt->max_fds);
file = fdt->fd[fd];
if (!file)
goto out_unlock;