|
|
731417 |
From c17b58ebffbfa862b3f1815e208db340bd1664eb Mon Sep 17 00:00:00 2001
|
|
|
731417 |
From: Yannick Cote <ycote@redhat.com>
|
|
|
731417 |
Date: Tue, 1 Feb 2022 14:14:41 -0500
|
|
|
731417 |
Subject: [KPATCH CVE-2020-0466] epoll: kpatch fixes for CVE-2020-0466
|
|
|
731417 |
|
|
|
731417 |
Kernels:
|
|
|
731417 |
3.10.0-1160.15.2.el7
|
|
|
731417 |
3.10.0-1160.21.1.el7
|
|
|
731417 |
3.10.0-1160.24.1.el7
|
|
|
731417 |
3.10.0-1160.25.1.el7
|
|
|
731417 |
3.10.0-1160.31.1.el7
|
|
|
731417 |
3.10.0-1160.36.2.el7
|
|
|
731417 |
3.10.0-1160.41.1.el7
|
|
|
731417 |
3.10.0-1160.42.2.el7
|
|
|
731417 |
3.10.0-1160.45.1.el7
|
|
|
731417 |
3.10.0-1160.49.1.el7
|
|
|
731417 |
3.10.0-1160.53.1.el7
|
|
|
731417 |
|
|
|
731417 |
Changes since last build:
|
|
|
731417 |
[x86_64]:
|
|
|
731417 |
eventpoll.o: changed function: SyS_epoll_ctl
|
|
|
731417 |
eventpoll.o: changed function: clear_tfile_check_list
|
|
|
731417 |
eventpoll.o: changed function: ep_loop_check_proc
|
|
|
731417 |
|
|
|
731417 |
[ppc64le]:
|
|
|
731417 |
eventpoll.o: changed function: SyS_epoll_ctl
|
|
|
731417 |
eventpoll.o: changed function: ep_loop_check_proc
|
|
|
731417 |
|
|
|
731417 |
---------------------------
|
|
|
731417 |
|
|
|
731417 |
Kpatch-MR: https://gitlab.com/redhat/prdsc/rhel/src/kpatch/rhel-7/-/merge_requests/22
|
|
|
731417 |
Approved-by: Artem Savkov (@artem.savkov)
|
|
|
731417 |
Kernels:
|
|
|
731417 |
3.10.0-1160.21.1.el7
|
|
|
731417 |
3.10.0-1160.24.1.el7
|
|
|
731417 |
3.10.0-1160.25.1.el7
|
|
|
731417 |
3.10.0-1160.31.1.el7
|
|
|
731417 |
3.10.0-1160.36.2.el7
|
|
|
731417 |
3.10.0-1160.41.1.el7
|
|
|
731417 |
3.10.0-1160.42.2.el7
|
|
|
731417 |
3.10.0-1160.45.1.el7
|
|
|
731417 |
3.10.0-1160.49.1.el7
|
|
|
731417 |
3.10.0-1160.53.1.el7
|
|
|
731417 |
|
|
|
731417 |
Modifications: none
|
|
|
731417 |
|
|
|
731417 |
commit f771ed0537c55c506dc846cb8f3da60f6383a2b3
|
|
|
731417 |
Author: Carlos Maiolino <cmaiolino@redhat.com>
|
|
|
731417 |
Date: Sat Dec 18 09:23:31 2021 +0100
|
|
|
731417 |
|
|
|
731417 |
epoll: Keep a reference on files added to the check list
|
|
|
731417 |
|
|
|
731417 |
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2042760
|
|
|
731417 |
Tested: Sanity check only
|
|
|
731417 |
CVE: CVE-2020-0466
|
|
|
731417 |
|
|
|
731417 |
Conflicts:
|
|
|
731417 |
- RHEL7 has no support for non-blocking do_epoll_ctl(), so the
|
|
|
731417 |
original patch got this part stripped.
|
|
|
731417 |
|
|
|
731417 |
When adding a new fd to an epoll, and that this new fd is an
|
|
|
731417 |
epoll fd itself, we recursively scan the fds attached to it
|
|
|
731417 |
to detect cycles, and add non-epool files to a "check list"
|
|
|
731417 |
that gets subsequently parsed.
|
|
|
731417 |
|
|
|
731417 |
However, this check list isn't completely safe when deletions
|
|
|
731417 |
can happen concurrently. To sidestep the issue, make sure that
|
|
|
731417 |
a struct file placed on the check list sees its f_count increased,
|
|
|
731417 |
ensuring that a concurrent deletion won't result in the file
|
|
|
731417 |
disapearing from under our feet.
|
|
|
731417 |
|
|
|
731417 |
Cc: stable@vger.kernel.org
|
|
|
731417 |
Signed-off-by: Marc Zyngier <maz@kernel.org>
|
|
|
731417 |
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
|
|
|
731417 |
(cherry picked from commit a9ed4a6560b8562b7e2e2bed9527e88001f7b682)
|
|
|
731417 |
|
|
|
731417 |
Signed-off-by: Carlos Maiolino <cmaiolino@redhat.com>
|
|
|
731417 |
|
|
|
731417 |
commit 0875a380011a7ff7f4504b72890c29fec420d1cd
|
|
|
731417 |
Author: Carlos Maiolino <cmaiolino@redhat.com>
|
|
|
731417 |
Date: Sat Dec 18 09:23:47 2021 +0100
|
|
|
731417 |
|
|
|
731417 |
fix regression in "epoll: Keep a reference on files added to the check list"
|
|
|
731417 |
|
|
|
731417 |
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2042760
|
|
|
731417 |
Tested: Sanity check only
|
|
|
731417 |
CVE: CVE-2020-0466
|
|
|
731417 |
|
|
|
731417 |
epoll_loop_check_proc() can run into a file already committed to destruction;
|
|
|
731417 |
we can't grab a reference on those and don't need to add them to the set for
|
|
|
731417 |
reverse path check anyway.
|
|
|
731417 |
|
|
|
731417 |
Tested-by: Marc Zyngier <maz@kernel.org>
|
|
|
731417 |
Fixes: a9ed4a6560b8 ("epoll: Keep a reference on files added to the check list")
|
|
|
731417 |
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
|
|
|
731417 |
(cherry picked from commit 77f4689de17c0887775bb77896f4cc11a39bf848)
|
|
|
731417 |
|
|
|
731417 |
Signed-off-by: Carlos Maiolino <cmaiolino@redhat.com>
|
|
|
731417 |
|
|
|
731417 |
Signed-off-by: Yannick Cote <ycote@redhat.com>
|
|
|
731417 |
---
|
|
|
731417 |
fs/eventpoll.c | 13 +++++++++----
|
|
|
731417 |
1 file changed, 9 insertions(+), 4 deletions(-)
|
|
|
731417 |
|
|
|
731417 |
diff --git a/fs/eventpoll.c b/fs/eventpoll.c
|
|
|
731417 |
index 6731b99a481f..ca0eb701eeb4 100644
|
|
|
731417 |
--- a/fs/eventpoll.c
|
|
|
731417 |
+++ b/fs/eventpoll.c
|
|
|
731417 |
@@ -1750,9 +1750,11 @@ static int ep_loop_check_proc(void *priv, void *cookie, int call_nests)
|
|
|
731417 |
* not already there, and calling reverse_path_check()
|
|
|
731417 |
* during ep_insert().
|
|
|
731417 |
*/
|
|
|
731417 |
- if (list_empty(&epi->ffd.file->f_tfile_llink))
|
|
|
731417 |
- list_add(&epi->ffd.file->f_tfile_llink,
|
|
|
731417 |
- &tfile_check_list);
|
|
|
731417 |
+ if (list_empty(&epi->ffd.file->f_tfile_llink)) {
|
|
|
731417 |
+ if (get_file_rcu(epi->ffd.file))
|
|
|
731417 |
+ list_add(&epi->ffd.file->f_tfile_llink,
|
|
|
731417 |
+ &tfile_check_list);
|
|
|
731417 |
+ }
|
|
|
731417 |
}
|
|
|
731417 |
}
|
|
|
731417 |
mutex_unlock(&ep->mtx);
|
|
|
731417 |
@@ -1796,6 +1798,7 @@ static void clear_tfile_check_list(void)
|
|
|
731417 |
file = list_first_entry(&tfile_check_list, struct file,
|
|
|
731417 |
f_tfile_llink);
|
|
|
731417 |
list_del_init(&file->f_tfile_llink);
|
|
|
731417 |
+ fput(file);
|
|
|
731417 |
}
|
|
|
731417 |
INIT_LIST_HEAD(&tfile_check_list);
|
|
|
731417 |
}
|
|
|
731417 |
@@ -1951,9 +1954,11 @@ SYSCALL_DEFINE4(epoll_ctl, int, epfd, int, op, int, fd,
|
|
|
731417 |
clear_tfile_check_list();
|
|
|
731417 |
goto error_tgt_fput;
|
|
|
731417 |
}
|
|
|
731417 |
- } else
|
|
|
731417 |
+ } else {
|
|
|
731417 |
+ get_file(tf.file);
|
|
|
731417 |
list_add(&tf.file->f_tfile_llink,
|
|
|
731417 |
&tfile_check_list);
|
|
|
731417 |
+ }
|
|
|
731417 |
mutex_lock_nested(&ep->mtx, 0);
|
|
|
731417 |
if (is_file_epoll(tf.file)) {
|
|
|
731417 |
tep = tf.file->private_data;
|
|
|
731417 |
--
|
|
|
731417 |
2.26.3
|
|
|
731417 |
|
|
|
731417 |
|