diff --git a/fs/file.c b/fs/file.c index 214364e19d76..ee1c350ec58a 100644 --- a/fs/file.c +++ b/fs/file.c @@ -646,6 +646,7 @@ static struct file *pick_file(struct files_struct *files, unsigned fd) file = ERR_PTR(-EINVAL); goto out_unlock; } + fd = array_index_nospec(fd, fdt->max_fds); file = fdt->fd[fd]; if (!file) { file = ERR_PTR(-EBADF);