Blame SOURCES/CVE-2023-42753.patch

1cfc9d
From 6631a62473656c61d7f82cda8ba490c9ba952b96 Mon Sep 17 00:00:00 2001
1cfc9d
From: Joe Lawrence <joe.lawrence@redhat.com>
1cfc9d
Date: Mon, 27 Nov 2023 15:50:24 -0500
1cfc9d
Subject: [KPATCH CVE-2023-42753] kpatch fixes for CVE-2023-42753
1cfc9d
1cfc9d
Kernels:
1cfc9d
3.10.0-1160.92.1.el7
1cfc9d
3.10.0-1160.95.1.el7
1cfc9d
3.10.0-1160.99.1.el7
1cfc9d
3.10.0-1160.102.1.el7
1cfc9d
3.10.0-1160.105.1.el7
1cfc9d
1cfc9d
1cfc9d
Kpatch-MR: https://gitlab.com/redhat/prdsc/rhel/src/kpatch/rhel-7/-/merge_requests/64
1cfc9d
Approved-by: Yannick Cote (@ycote1)
1cfc9d
Changes since last build:
1cfc9d
arches: x86_64 ppc64le
1cfc9d
ip_set_hash_netportnet.o: changed function: hash_netportnet4_uadt
1cfc9d
ip_set_hash_netportnet.o: changed function: hash_netportnet6_uadt
1cfc9d
---------------------------
1cfc9d
1cfc9d
Modifications:
1cfc9d
- Z-stream sets IP_SET_HASH_WITH_NET0, which kicks off a bunch of
1cfc9d
  preprocessor defined function and data changes, including struct
1cfc9d
  hash_netportnet{4,6}.nets[] array sizing and iteration.  Instead of
1cfc9d
  deploying shadow variables to trace new/old instances, just reject
1cfc9d
  CIDR/CIDR2 if they are 0, i.e. remove support for /0 wildcard matching
1cfc9d
  so users get an error when they try to insert a new /0 element.
1cfc9d
1cfc9d
commit 8de5d63e7ee39b62f71af7cd95990d99d300e8ec
1cfc9d
Author: Phil Sutter <psutter@redhat.com>
1cfc9d
Date:   Wed Nov 22 19:24:24 2023 +0100
1cfc9d
1cfc9d
    netfilter: ipset: add the missing IP_SET_HASH_WITH_NET0 macro for ip_set_hash_netportnet.c
1cfc9d
1cfc9d
    JIRA: https://issues.redhat.com/browse/RHEL-8433
1cfc9d
    Upstream Status: commit 050d91c03b28ca479df13dfb02bcd2c60dd6a878
1cfc9d
    CVE: CVE-2023-42753
1cfc9d
1cfc9d
    commit 050d91c03b28ca479df13dfb02bcd2c60dd6a878
1cfc9d
    Author: Kyle Zeng <zengyhkyle@gmail.com>
1cfc9d
    Date:   Tue Sep 5 15:04:09 2023 -0700
1cfc9d
1cfc9d
        netfilter: ipset: add the missing IP_SET_HASH_WITH_NET0 macro for ip_set_hash_netportnet.c
1cfc9d
1cfc9d
        The missing IP_SET_HASH_WITH_NET0 macro in ip_set_hash_netportnet can
1cfc9d
        lead to the use of wrong `CIDR_POS(c)` for calculating array offsets,
1cfc9d
        which can lead to integer underflow. As a result, it leads to slab
1cfc9d
        out-of-bound access.
1cfc9d
        This patch adds back the IP_SET_HASH_WITH_NET0 macro to
1cfc9d
        ip_set_hash_netportnet to address the issue.
1cfc9d
1cfc9d
        Fixes: 886503f34d63 ("netfilter: ipset: actually allow allowable CIDR 0 in hash:net,port,net")
1cfc9d
        Suggested-by: Jozsef Kadlecsik <kadlec@netfilter.org>
1cfc9d
        Signed-off-by: Kyle Zeng <zengyhkyle@gmail.com>
1cfc9d
        Acked-by: Jozsef Kadlecsik <kadlec@netfilter.org>
1cfc9d
        Signed-off-by: Florian Westphal <fw@strlen.de>
1cfc9d
1cfc9d
    Signed-off-by: Phil Sutter <psutter@redhat.com>
1cfc9d
1cfc9d
Signed-off-by: Joe Lawrence <joe.lawrence@redhat.com>
1cfc9d
---
1cfc9d
 net/netfilter/ipset/ip_set_hash_netportnet.c | 8 ++++++++
1cfc9d
 1 file changed, 8 insertions(+)
1cfc9d
1cfc9d
diff --git a/net/netfilter/ipset/ip_set_hash_netportnet.c b/net/netfilter/ipset/ip_set_hash_netportnet.c
1cfc9d
index 613e18e720a4..57043081d04c 100644
1cfc9d
--- a/net/netfilter/ipset/ip_set_hash_netportnet.c
1cfc9d
+++ b/net/netfilter/ipset/ip_set_hash_netportnet.c
1cfc9d
@@ -213,12 +213,16 @@ hash_netportnet4_uadt(struct ip_set *set, struct nlattr *tb[],
1cfc9d
 
1cfc9d
 	if (tb[IPSET_ATTR_CIDR]) {
1cfc9d
 		e.cidr[0] = nla_get_u8(tb[IPSET_ATTR_CIDR]);
1cfc9d
+		if (e.cidr[0] == 0)
1cfc9d
+			return -IPSET_ERR_INVALID_CIDR;
1cfc9d
 		if (e.cidr[0] > HOST_MASK)
1cfc9d
 			return -IPSET_ERR_INVALID_CIDR;
1cfc9d
 	}
1cfc9d
 
1cfc9d
 	if (tb[IPSET_ATTR_CIDR2]) {
1cfc9d
 		e.cidr[1] = nla_get_u8(tb[IPSET_ATTR_CIDR2]);
1cfc9d
+		if (e.cidr[1] == 0)
1cfc9d
+			return -IPSET_ERR_INVALID_CIDR;
1cfc9d
 		if (e.cidr[1] > HOST_MASK)
1cfc9d
 			return -IPSET_ERR_INVALID_CIDR;
1cfc9d
 	}
1cfc9d
@@ -493,12 +497,16 @@ hash_netportnet6_uadt(struct ip_set *set, struct nlattr *tb[],
1cfc9d
 
1cfc9d
 	if (tb[IPSET_ATTR_CIDR]) {
1cfc9d
 		e.cidr[0] = nla_get_u8(tb[IPSET_ATTR_CIDR]);
1cfc9d
+		if (e.cidr[0] == 0)
1cfc9d
+			return -IPSET_ERR_INVALID_CIDR;
1cfc9d
 		if (e.cidr[0] > HOST_MASK)
1cfc9d
 			return -IPSET_ERR_INVALID_CIDR;
1cfc9d
 	}
1cfc9d
 
1cfc9d
 	if (tb[IPSET_ATTR_CIDR2]) {
1cfc9d
 		e.cidr[1] = nla_get_u8(tb[IPSET_ATTR_CIDR2]);
1cfc9d
+		if (e.cidr[1] == 0)
1cfc9d
+			return -IPSET_ERR_INVALID_CIDR;
1cfc9d
 		if (e.cidr[1] > HOST_MASK)
1cfc9d
 			return -IPSET_ERR_INVALID_CIDR;
1cfc9d
 	}
1cfc9d
-- 
1cfc9d
2.43.0
1cfc9d
1cfc9d