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:
committed by
Greg Kroah-Hartman
parent
955623617f
commit
a759905de9
@@ -677,6 +677,7 @@ static struct file *pick_file(struct files_struct *files, unsigned fd)
|
|||||||
fdt = files_fdtable(files);
|
fdt = files_fdtable(files);
|
||||||
if (fd >= fdt->max_fds)
|
if (fd >= fdt->max_fds)
|
||||||
goto out_unlock;
|
goto out_unlock;
|
||||||
|
fd = array_index_nospec(fd, fdt->max_fds);
|
||||||
file = fdt->fd[fd];
|
file = fdt->fd[fd];
|
||||||
if (!file)
|
if (!file)
|
||||||
goto out_unlock;
|
goto out_unlock;
|
||||||
|
|||||||
Reference in New Issue
Block a user