Blame SOURCES/CVE-2023-42753.patch

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