Blame SOURCES/CVE-2023-3609.patch

f1789a
From 889eaaeaa5aa88308347b90f53e1bd2301a50dec Mon Sep 17 00:00:00 2001
f1789a
From: Ryan Sullivan <rysulliv@redhat.com>
f1789a
Date: Mon, 25 Sep 2023 10:50:48 -0400
f1789a
Subject: [KPATCH CVE-2023-3609] kpatch fixes for CVE-2023-3609
f1789a
f1789a
Kernels:
f1789a
3.10.0-1160.88.1.el7
f1789a
3.10.0-1160.90.1.el7
f1789a
3.10.0-1160.92.1.el7
f1789a
3.10.0-1160.95.1.el7
f1789a
3.10.0-1160.99.1.el7
f1789a
f1789a
f1789a
Kpatch-MR: https://gitlab.com/redhat/prdsc/rhel/src/kpatch/rhel-7/-/merge_requests/59
f1789a
Approved-by: Yannick Cote (@ycote1)
f1789a
Changes since last build:
f1789a
[x86_64]:
f1789a
cls_u32.o: changed function: u32_set_parms.isra.21
f1789a
nf_tables_api.o: changed function: nf_tables_newsetelem
f1789a
nf_tables_api.o: changed function: nf_tables_set_lookup
f1789a
nf_tables_api.o: changed function: nf_tables_set_lookup_byid
f1789a
nft_byteorder.o: changed function: nft_byteorder_eval
f1789a
nft_dynset.o: changed function: nft_dynset_init
f1789a
nft_lookup.o: changed function: nft_lookup_init
f1789a
f1789a
[ppc64le]:
f1789a
cls_u32.o: changed function: u32_set_parms.isra.21
f1789a
nf_tables_api.o: changed function: nf_tables_delset
f1789a
nf_tables_api.o: changed function: nf_tables_dump_set
f1789a
nf_tables_api.o: changed function: nf_tables_getset
f1789a
nf_tables_api.o: changed function: nf_tables_getsetelem
f1789a
nf_tables_api.o: changed function: nf_tables_newsetelem
f1789a
nf_tables_api.o: changed function: nf_tables_set_lookup
f1789a
nf_tables_api.o: changed function: nf_tables_set_lookup_byid
f1789a
nft_byteorder.o: changed function: nft_byteorder_eval
f1789a
nft_dynset.o: changed function: nft_dynset_init
f1789a
nft_lookup.o: changed function: nft_lookup_init
f1789a
f1789a
---------------------------
f1789a
f1789a
Modifications: none
f1789a
f1789a
commit 867fb59af8011c735d38c08d6e6ecef67265cb4e
f1789a
Author: Davide Caratti <dcaratti@redhat.com>
f1789a
Date:   Tue Aug 8 11:18:31 2023 +0200
f1789a
f1789a
    net/sched: cls_u32: Fix reference counter leak leading to overflow
f1789a
f1789a
    Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2225486
f1789a
    CVE: CVE-2023-3609
f1789a
    Upstream Status: net.git commit 04c55383fa56
f1789a
    Conflicts:
f1789a
      - net/sched/cls_u32.c: we still have CONFIG_NET_CLS_IND in rhel7,
f1789a
        because of missing upstream commit a51486266c3b ("net: sched: remove
f1789a
        NET_CLS_IND config option"), so the patch has been manually reworked
f1789a
        to preserve use of #ifdef CONFIG_NET_CLS_IND
f1789a
      - we also don't have extacks because of missing backport of upstream
f1789a
        commit 4b981dbc2272 ("net: sched: cls_u32: add extack support"), so
f1789a
        the call to tcf_change_indev() has no 'extack' parameter
f1789a
f1789a
    commit 04c55383fa5689357bcdd2c8036725a55ed632bc
f1789a
    Author: Lee Jones <lee@kernel.org>
f1789a
    Date:   Thu Jun 8 08:29:03 2023 +0100
f1789a
f1789a
        net/sched: cls_u32: Fix reference counter leak leading to overflow
f1789a
f1789a
        In the event of a failure in tcf_change_indev(), u32_set_parms() will
f1789a
        immediately return without decrementing the recently incremented
f1789a
        reference counter.  If this happens enough times, the counter will
f1789a
        rollover and the reference freed, leading to a double free which can be
f1789a
        used to do 'bad things'.
f1789a
f1789a
        In order to prevent this, move the point of possible failure above the
f1789a
        point where the reference counter is incremented.  Also save any
f1789a
        meaningful return values to be applied to the return data at the
f1789a
        appropriate point in time.
f1789a
f1789a
        This issue was caught with KASAN.
f1789a
f1789a
        Fixes: 705c7091262d ("net: sched: cls_u32: no need to call tcf_exts_change for newly allocated struct")
f1789a
        Suggested-by: Eric Dumazet <edumazet@google.com>
f1789a
        Signed-off-by: Lee Jones <lee@kernel.org>
f1789a
        Reviewed-by: Eric Dumazet <edumazet@google.com>
f1789a
        Acked-by: Jamal Hadi Salim <jhs@mojatatu.com>
f1789a
        Signed-off-by: David S. Miller <davem@davemloft.net>
f1789a
f1789a
    Signed-off-by: Davide Caratti <dcaratti@redhat.com>
f1789a
f1789a
Signed-off-by: Ryan Sullivan <rysulliv@redhat.com>
f1789a
---
f1789a
 net/sched/cls_u32.c | 21 ++++++++++++++-------
f1789a
 1 file changed, 14 insertions(+), 7 deletions(-)
f1789a
f1789a
diff --git a/net/sched/cls_u32.c b/net/sched/cls_u32.c
f1789a
index 269dcb08fed5..cc9398e10451 100644
f1789a
--- a/net/sched/cls_u32.c
f1789a
+++ b/net/sched/cls_u32.c
f1789a
@@ -768,11 +768,22 @@ static int u32_set_parms(struct net *net, struct tcf_proto *tp,
f1789a
 			 struct nlattr *est, bool ovr)
f1789a
 {
f1789a
 	int err;
f1789a
+#ifdef CONFIG_NET_CLS_IND
f1789a
+	int ifindex = -1;
f1789a
+#endif
f1789a
 
f1789a
 	err = tcf_exts_validate(net, tp, tb, est, &n->exts, ovr);
f1789a
 	if (err < 0)
f1789a
 		return err;
f1789a
 
f1789a
+#ifdef CONFIG_NET_CLS_IND
f1789a
+	if (tb[TCA_U32_INDEV]) {
f1789a
+		ifindex = tcf_change_indev(net, tb[TCA_U32_INDEV]);
f1789a
+		if (ifindex < 0)
f1789a
+			return -EINVAL;
f1789a
+	}
f1789a
+#endif
f1789a
+
f1789a
 	if (tb[TCA_U32_LINK]) {
f1789a
 		u32 handle = nla_get_u32(tb[TCA_U32_LINK]);
f1789a
 		struct tc_u_hnode *ht_down = NULL, *ht_old;
f1789a
@@ -800,14 +811,10 @@ static int u32_set_parms(struct net *net, struct tcf_proto *tp,
f1789a
 	}
f1789a
 
f1789a
 #ifdef CONFIG_NET_CLS_IND
f1789a
-	if (tb[TCA_U32_INDEV]) {
f1789a
-		int ret;
f1789a
-		ret = tcf_change_indev(net, tb[TCA_U32_INDEV]);
f1789a
-		if (ret < 0)
f1789a
-			return -EINVAL;
f1789a
-		n->ifindex = ret;
f1789a
-	}
f1789a
+	if (ifindex >= 0)
f1789a
+		n->ifindex = ifindex;
f1789a
 #endif
f1789a
+
f1789a
 	return 0;
f1789a
 }
f1789a
 
f1789a
-- 
f1789a
2.40.1
f1789a
f1789a