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 <[email protected]> Signed-off-by: Al Viro <[email protected]>
1 parent c64c67c commit 609d544

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

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)