Skip to content

Commit f2ff8b0

Browse files
committed
protect the fetch of ->fd[fd] in do_dup2() from mispredictions
jira LE-3201 cve CVE-2024-42265 Rebuild_History Non-Buildable kernel-rt-4.18.0-553.22.1.rt7.363.el8_10 Rebuild_CHGLOG: - protect the fetch of ->fd[fd] in do_dup2() from mispredictions (CKI Backport Bot) [RHEL-55123] {CVE-2024-42265} Rebuild_FUZZ: 95.80% commit-author Al Viro <viro@zeniv.linux.org.uk> commit 8aa37bd both callers have verified that fd is not greater than ->max_fds; however, misprediction might end up with tofree = fdt->fd[fd]; being speculatively executed. That's wrong for the same reasons why it's wrong in close_fd()/file_close_fd_locked(); the same solution applies - array_index_nospec(fd, fdt->max_fds) could differ from fd only in case of speculative execution on mispredicted path. Cc: stable@vger.kernel.org Signed-off-by: Al Viro <viro@zeniv.linux.org.uk> (cherry picked from commit 8aa37bd) Signed-off-by: Jonathan Maple <jmaple@ciq.com>
1 parent 9b51761 commit f2ff8b0

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
@@ -1064,6 +1064,7 @@ __releases(&files->file_lock)
10641064
* tables and this condition does not arise without those.
10651065
*/
10661066
fdt = files_fdtable(files);
1067+
fd = array_index_nospec(fd, fdt->max_fds);
10671068
tofree = fdt->fd[fd];
10681069
if (!tofree && fd_is_open(fd, fdt))
10691070
goto Ebusy;

0 commit comments

Comments
 (0)