Blame SOURCES/CVE-2021-3715.patch

da5326
From: Artem Savkov <asavkov@redhat.com>
da5326
Subject: [RHEL-7.9 CVE-2021-3715 KPATCH] net_sched: cls_route: remove the right filter from hashtable
da5326
Date: Mon, 30 Aug 2021 17:33:51 +0200
da5326
da5326
Kernels:
da5326
3.10.0-1160.el7
da5326
3.10.0-1160.2.1.el7
da5326
3.10.0-1160.2.2.el7
da5326
3.10.0-1160.6.1.el7
da5326
3.10.0-1160.11.1.el7
da5326
3.10.0-1160.15.2.el7
da5326
3.10.0-1160.21.1.el7
da5326
3.10.0-1160.24.1.el7
da5326
3.10.0-1160.25.1.el7
da5326
3.10.0-1160.31.1.el7
da5326
3.10.0-1160.36.2.el7
da5326
3.10.0-1160.41.1.el7
da5326
da5326
Changes since last build:
da5326
arches: x86_64 ppc64le
da5326
cls_route.o: changed function: route4_change
da5326
---------------------------
da5326
da5326
Kernels:
da5326
3.10.0-1160.el7
da5326
3.10.0-1160.2.1.el7
da5326
3.10.0-1160.2.2.el7
da5326
3.10.0-1160.6.1.el7
da5326
3.10.0-1160.11.1.el7
da5326
3.10.0-1160.15.2.el7
da5326
3.10.0-1160.21.1.el7
da5326
3.10.0-1160.24.1.el7
da5326
3.10.0-1160.25.1.el7
da5326
3.10.0-1160.31.1.el7
da5326
3.10.0-1160.36.2.el7
da5326
da5326
Modifications: none
da5326
Z-MR: https://gitlab.com/redhat/rhel/src/kernel/rhel-7/-/merge_requests/251
da5326
da5326
commit f4e1814eb56167451ddd819fccb951178f97660b
da5326
Author: Ivan Vecera <ivecera@redhat.com>
da5326
Date:   Tue Aug 17 12:21:33 2021 +0200
da5326
da5326
    net_sched: cls_route: remove the right filter from hashtable
da5326
da5326
    Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1992926
da5326
da5326
    commit ef299cc3fa1a9e1288665a9fdc8bff55629fd359
da5326
    Author: Cong Wang <xiyou.wangcong@gmail.com>
da5326
    Date:   Fri Mar 13 22:29:54 2020 -0700
da5326
da5326
        net_sched: cls_route: remove the right filter from hashtable
da5326
da5326
        route4_change() allocates a new filter and copies values from
da5326
        the old one. After the new filter is inserted into the hash
da5326
        table, the old filter should be removed and freed, as the final
da5326
        step of the update.
da5326
da5326
        However, the current code mistakenly removes the new one. This
da5326
        looks apparently wrong to me, and it causes double "free" and
da5326
        use-after-free too, as reported by syzbot.
da5326
da5326
        Reported-and-tested-by: syzbot+f9b32aaacd60305d9687@syzkaller.appspotmail.com
da5326
        Reported-and-tested-by: syzbot+2f8c233f131943d6056d@syzkaller.appspotmail.com
da5326
        Reported-and-tested-by: syzbot+9c2df9fd5e9445b74e01@syzkaller.appspotmail.com
da5326
        Fixes: 1109c00547fc ("net: sched: RCU cls_route")
da5326
        Cc: Jamal Hadi Salim <jhs@mojatatu.com>
da5326
        Cc: Jiri Pirko <jiri@resnulli.us>
da5326
        Cc: John Fastabend <john.fastabend@gmail.com>
da5326
        Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
da5326
        Signed-off-by: David S. Miller <davem@davemloft.net>
da5326
da5326
    Signed-off-by: Ivan Vecera <ivecera@redhat.com>
da5326
da5326
Signed-off-by: Artem Savkov <asavkov@redhat.com>
da5326
Acked-by: Joe Lawrence <joe.lawrence@redhat.com>
da5326
---
da5326
 net/sched/cls_route.c | 4 ++--
da5326
 1 file changed, 2 insertions(+), 2 deletions(-)
da5326
da5326
diff --git a/net/sched/cls_route.c b/net/sched/cls_route.c
da5326
index 7bd464e8d084..2fed29fa504e 100644
da5326
--- a/net/sched/cls_route.c
da5326
+++ b/net/sched/cls_route.c
da5326
@@ -534,8 +534,8 @@ static int route4_change(struct net *net, struct sk_buff *in_skb,
da5326
 			fp = &b->ht[h];
da5326
 			for (pfp = rtnl_dereference(*fp); pfp;
da5326
 			     fp = &pfp->next, pfp = rtnl_dereference(*fp)) {
da5326
-				if (pfp == f) {
da5326
-					*fp = f->next;
da5326
+				if (pfp == fold) {
da5326
+					rcu_assign_pointer(*fp, fold->next);
da5326
 					break;
da5326
 				}
da5326
 			}
da5326
-- 
da5326
2.31.1
da5326
da5326