Blame SOURCES/CVE-2023-3609.patch

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