Blame SOURCES/CVE-2021-22555.patch

fb740d
From: Joel Savitz <jsavitz@redhat.com>
fb740d
Subject: [KPATCH 7.9] netfilter: x_tables: kpatch fixes for CVE-2021-22555
fb740d
Date: Wed, 28 Jul 2021 12:03:15 -0400
fb740d
fb740d
Kernels:
fb740d
3.10.0-1160.el7
fb740d
3.10.0-1160.2.1.el7
fb740d
3.10.0-1160.2.2.el7
fb740d
3.10.0-1160.6.1.el7
fb740d
3.10.0-1160.11.1.el7
fb740d
3.10.0-1160.15.2.el7
fb740d
3.10.0-1160.21.1.el7
fb740d
3.10.0-1160.24.1.el7
fb740d
3.10.0-1160.25.1.el7
fb740d
3.10.0-1160.31.1.el7
fb740d
3.10.0-1160.36.2.el7
fb740d
fb740d
Changes since last build:
fb740d
arches: x86_64 ppc64le
fb740d
arp_tables.o: changed function: translate_compat_table
fb740d
ip6_tables.o: changed function: translate_compat_table
fb740d
ip_tables.o: changed function: translate_compat_table
fb740d
x_tables.o: changed function: xt_compat_match_from_user
fb740d
x_tables.o: changed function: xt_compat_target_from_user
fb740d
---------------------------
fb740d
fb740d
Kernels:
fb740d
3.10.0-1160.el7
fb740d
3.10.0-1160.2.1.el7
fb740d
3.10.0-1160.2.2.el7
fb740d
3.10.0-1160.6.1.el7
fb740d
3.10.0-1160.11.1.el7
fb740d
3.10.0-1160.15.2.el7
fb740d
3.10.0-1160.21.1.el7
fb740d
3.10.0-1160.24.1.el7
fb740d
3.10.0-1160.25.1.el7
fb740d
3.10.0-1160.31.1.el7
fb740d
3.10.0-1160.36.2.el7
fb740d
fb740d
Modifications: none
fb740d
fb740d
Z-MR: https://gitlab.com/redhat/rhel/src/kernel/rhel-7/-/merge_requests/201
fb740d
KT0 test PASS: https://beaker.engineering.redhat.com/jobs/5642298
fb740d
for scratch build: https://brewweb.engineering.redhat.com/brew/taskinfo?taskID=38448253
fb740d
fb740d
commit 06215319786b979bed0f5eb3138de0506db9d39f
fb740d
Author: Florian Westphal <fwestpha@redhat.com>
fb740d
Date:   Fri Jul 9 11:42:55 2021 +0200
fb740d
fb740d
    netfilter: x_tables: fix compat match/target pad out-of-bound write
fb740d
fb740d
    Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1980489
fb740d
    Upstream Status: commit b29c457a65114
fb740d
    CVE: CVE-2021-22555
fb740d
fb740d
    commit b29c457a6511435960115c0f548c4360d5f4801d
fb740d
    Author: Florian Westphal <fw@strlen.de>
fb740d
    Date:   Wed Apr 7 21:38:57 2021 +0200
fb740d
fb740d
        netfilter: x_tables: fix compat match/target pad out-of-bound write
fb740d
fb740d
        xt_compat_match/target_from_user doesn't check that zeroing the area
fb740d
        to start of next rule won't write past end of allocated ruleset blob.
fb740d
fb740d
        Remove this code and zero the entire blob beforehand.
fb740d
fb740d
        Reported-by: syzbot+cfc0247ac173f597aaaa@syzkaller.appspotmail.com
fb740d
        Reported-by: Andy Nguyen <theflow@google.com>
fb740d
        Fixes: 9fa492cdc160c ("[NETFILTER]: x_tables: simplify compat API")
fb740d
        Signed-off-by: Florian Westphal <fw@strlen.de>
fb740d
        Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
fb740d
fb740d
    Signed-off-by: Florian Westphal <fwestpha@redhat.com>
fb740d
fb740d
Signed-off-by: Joel Savitz <jsavitz@redhat.com>
fb740d
Acked-by: Joe Lawrence <joe.lawrence@redhat.com>
fb740d
Acked-by: Artem Savkov <asavkov@redhat.com>
fb740d
Acked-by: Yannick Cote <ycote@redhat.com>
fb740d
---
fb740d
 net/ipv4/netfilter/arp_tables.c |  2 ++
fb740d
 net/ipv4/netfilter/ip_tables.c  |  2 ++
fb740d
 net/ipv6/netfilter/ip6_tables.c |  2 ++
fb740d
 net/netfilter/x_tables.c        | 10 ++--------
fb740d
 4 files changed, 8 insertions(+), 8 deletions(-)
fb740d
fb740d
diff --git a/net/ipv4/netfilter/arp_tables.c b/net/ipv4/netfilter/arp_tables.c
fb740d
index 602d92697038..66ad3b4e194c 100644
fb740d
--- a/net/ipv4/netfilter/arp_tables.c
fb740d
+++ b/net/ipv4/netfilter/arp_tables.c
fb740d
@@ -1364,6 +1364,8 @@ static int translate_compat_table(struct xt_table_info **pinfo,
fb740d
 	if (!newinfo)
fb740d
 		goto out_unlock;
fb740d
 
fb740d
+	memset(newinfo->entries, 0, size);
fb740d
+
fb740d
 	newinfo->number = compatr->num_entries;
fb740d
 	for (i = 0; i < NF_ARP_NUMHOOKS; i++) {
fb740d
 		newinfo->hook_entry[i] = info->hook_entry[i];
fb740d
diff --git a/net/ipv4/netfilter/ip_tables.c b/net/ipv4/netfilter/ip_tables.c
fb740d
index 3559f7ffa430..d9de653be67e 100644
fb740d
--- a/net/ipv4/netfilter/ip_tables.c
fb740d
+++ b/net/ipv4/netfilter/ip_tables.c
fb740d
@@ -1622,6 +1622,8 @@ translate_compat_table(struct net *net,
fb740d
 	if (!newinfo)
fb740d
 		goto out_unlock;
fb740d
 
fb740d
+	memset(newinfo->entries, 0, size);
fb740d
+
fb740d
 	newinfo->number = compatr->num_entries;
fb740d
 	for (i = 0; i < NF_INET_NUMHOOKS; i++) {
fb740d
 		newinfo->hook_entry[i] = compatr->hook_entry[i];
fb740d
diff --git a/net/ipv6/netfilter/ip6_tables.c b/net/ipv6/netfilter/ip6_tables.c
fb740d
index 1772a1797e79..d112bfc86aac 100644
fb740d
--- a/net/ipv6/netfilter/ip6_tables.c
fb740d
+++ b/net/ipv6/netfilter/ip6_tables.c
fb740d
@@ -1626,6 +1626,8 @@ translate_compat_table(struct net *net,
fb740d
 	if (!newinfo)
fb740d
 		goto out_unlock;
fb740d
 
fb740d
+	memset(newinfo->entries, 0, size);
fb740d
+
fb740d
 	newinfo->number = compatr->num_entries;
fb740d
 	for (i = 0; i < NF_INET_NUMHOOKS; i++) {
fb740d
 		newinfo->hook_entry[i] = compatr->hook_entry[i];
fb740d
diff --git a/net/netfilter/x_tables.c b/net/netfilter/x_tables.c
fb740d
index 76e40ff48b10..affd08ce7df8 100644
fb740d
--- a/net/netfilter/x_tables.c
fb740d
+++ b/net/netfilter/x_tables.c
fb740d
@@ -564,7 +564,7 @@ void xt_compat_match_from_user(struct xt_entry_match *m, void **dstptr,
fb740d
 {
fb740d
 	const struct xt_match *match = m->u.kernel.match;
fb740d
 	struct compat_xt_entry_match *cm = (struct compat_xt_entry_match *)m;
fb740d
-	int pad, off = xt_compat_match_offset(match);
fb740d
+	int off = xt_compat_match_offset(match);
fb740d
 	u_int16_t msize = cm->u.user.match_size;
fb740d
 	char name[sizeof(m->u.user.name)];
fb740d
 
fb740d
@@ -574,9 +574,6 @@ void xt_compat_match_from_user(struct xt_entry_match *m, void **dstptr,
fb740d
 		match->compat_from_user(m->data, cm->data);
fb740d
 	else
fb740d
 		memcpy(m->data, cm->data, msize - sizeof(*cm));
fb740d
-	pad = XT_ALIGN(match->matchsize) - match->matchsize;
fb740d
-	if (pad > 0)
fb740d
-		memset(m->data + match->matchsize, 0, pad);
fb740d
 
fb740d
 	msize += off;
fb740d
 	m->u.user.match_size = msize;
fb740d
@@ -913,7 +910,7 @@ void xt_compat_target_from_user(struct xt_entry_target *t, void **dstptr,
fb740d
 {
fb740d
 	const struct xt_target *target = t->u.kernel.target;
fb740d
 	struct compat_xt_entry_target *ct = (struct compat_xt_entry_target *)t;
fb740d
-	int pad, off = xt_compat_target_offset(target);
fb740d
+	int off = xt_compat_target_offset(target);
fb740d
 	u_int16_t tsize = ct->u.user.target_size;
fb740d
 	char name[sizeof(t->u.user.name)];
fb740d
 
fb740d
@@ -923,9 +920,6 @@ void xt_compat_target_from_user(struct xt_entry_target *t, void **dstptr,
fb740d
 		target->compat_from_user(t->data, ct->data);
fb740d
 	else
fb740d
 		memcpy(t->data, ct->data, tsize - sizeof(*ct));
fb740d
-	pad = XT_ALIGN(target->targetsize) - target->targetsize;
fb740d
-	if (pad > 0)
fb740d
-		memset(t->data + target->targetsize, 0, pad);
fb740d
 
fb740d
 	tsize += off;
fb740d
 	t->u.user.target_size = tsize;
fb740d
-- 
fb740d
2.27.0
fb740d
fb740d