Blame SOURCES/CVE-2023-3609.patch

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