Skip to contentSkip to conversation

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

PATCH Applied Theodore Ts'o 2 participants 2 messages Mar 6, 2023 – Mar 10, 2023 VFS

lore
Share & tools
lore
#0 lore raw

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

Google-Bug-Id: 114199369

---

I had sent this a while back, and failed to follow up when it apparently get missed. $WORK has been carrying this (or the equivalent) as an out-of-tree security patch since 2018, and now some folks are now nagging me about why hasn't this gone upstream yet...

 fs/file.c | 1 +
 1 file changed, 1 insertion(+)
fs/file.c +1 -0
index c942c89ca4cd..7893ea161d77 100644
@@ -642,6 +642,7 @@ static struct file *pick_file(struct files_struct *files, unsigned fd)
 	if (fd >= fdt->max_fds)
 		return NULL;
 
+	fd = array_index_nospec(fd, fdt->max_fds);
 	file = fdt->fd[fd];
 	if (file) {
 		rcu_assign_pointer(fdt->fd[fd], NULL);
Signature · 1 line
2.31.0
maintainer
#1 lore raw
Quoted 8 lines · Theodore Ts'o

Google-Bug-Id: 114199369

---

I had sent this a while back, and failed to follow up when it apparently get missed. $WORK has been carrying this (or the equivalent) as an out-of-tree security patch since 2018, and now some folks are now nagging me about why hasn't this gone upstream yet...

Applied (#fixes), will go to Linus this weekend.