Skip to content

Commit 609d544

Browse files
tytsoAl Viro
authored andcommitted
fs: prevent out-of-bounds array speculation when closing a file descriptor
Google-Bug-Id: 114199369 Signed-off-by: Theodore Ts'o <tytso@mit.edu> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
1 parent c64c67c commit 609d544

1 file changed

Lines changed: 1 addition & 0 deletions

File tree

fs/file.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -642,6 +642,7 @@ static struct file *pick_file(struct files_struct *files, unsigned fd)
642642
if (fd >= fdt->max_fds)
643643
return NULL;
644644

645+
fd = array_index_nospec(fd, fdt->max_fds);
645646
file = fdt->fd[fd];
646647
if (file) {
647648
rcu_assign_pointer(fdt->fd[fd], NULL);

0 commit comments

Comments
 (0)