|
|
d46c83 |
From b8c2b76bf8026457489948693638df321c680e7b Mon Sep 17 00:00:00 2001
|
|
|
d46c83 |
From: Joel Savitz <jsavitz@redhat.com>
|
|
|
d46c83 |
Date: Fri, 23 Jul 2021 11:26:01 -0400
|
|
|
d46c83 |
Subject: [PATCH] netfilter: x_tables: kpatch fixes for CVE-2021-22555
|
|
|
d46c83 |
|
|
|
d46c83 |
Kernels:
|
|
|
d46c83 |
4.18.0-305.el8
|
|
|
d46c83 |
4.18.0-305.3.1.el8_4
|
|
|
d46c83 |
4.18.0-305.7.1.el8_4
|
|
|
d46c83 |
4.18.0-305.10.2.el8_4
|
|
|
d46c83 |
|
|
|
d46c83 |
Changes since last build:
|
|
|
d46c83 |
arches: x86_64 ppc64le
|
|
|
d46c83 |
arp_tables.o: changed function: translate_compat_table
|
|
|
d46c83 |
ip6_tables.o: changed function: translate_compat_table
|
|
|
d46c83 |
ip_tables.o: changed function: translate_compat_table
|
|
|
d46c83 |
x_tables.o: changed function: xt_compat_match_from_user
|
|
|
d46c83 |
x_tables.o: changed function: xt_compat_target_from_user
|
|
|
d46c83 |
---------------------------
|
|
|
d46c83 |
|
|
|
d46c83 |
Kernels:
|
|
|
d46c83 |
4.18.0-305.el8
|
|
|
d46c83 |
4.18.0-305.3.1.el8_4
|
|
|
d46c83 |
4.18.0-305.7.1.el8_4
|
|
|
d46c83 |
4.18.0-305.10.2.el8_4
|
|
|
d46c83 |
|
|
|
d46c83 |
Modifications: none
|
|
|
d46c83 |
|
|
|
d46c83 |
Z-MR: https://gitlab.com/redhat/rhel/src/kernel/rhel-8/-/merge_requests/951
|
|
|
d46c83 |
|
|
|
d46c83 |
KT0: https://beaker.engineering.redhat.com/jobs/5611476 (PASS for x86_64 and queued for ppc64le)
|
|
|
d46c83 |
for scratch Build: https://brewweb.engineering.redhat.com/brew/taskinfo?taskID=38312105
|
|
|
d46c83 |
|
|
|
d46c83 |
commit a6f41b0d134d0ca62a46da0204f02018d69f19dd
|
|
|
d46c83 |
Author: Florian Westphal <fwestpha@redhat.com>
|
|
|
d46c83 |
Date: Thu Apr 15 17:12:32 2021 +0200
|
|
|
d46c83 |
|
|
|
d46c83 |
netfilter: x_tables: fix compat match/target pad out-of-bound write
|
|
|
d46c83 |
|
|
|
d46c83 |
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1980500
|
|
|
d46c83 |
Y-Commit: 67b5dd48280ef85610333da24be367188d0542cb
|
|
|
d46c83 |
O-Bugzilla: 1980501
|
|
|
d46c83 |
CVE: CVE-2021-22555
|
|
|
d46c83 |
|
|
|
d46c83 |
Upstream Status: commit b29c457a65114
|
|
|
d46c83 |
|
|
|
d46c83 |
commit b29c457a6511435960115c0f548c4360d5f4801d
|
|
|
d46c83 |
Author: Florian Westphal <fw@strlen.de>
|
|
|
d46c83 |
Date: Wed Apr 7 21:38:57 2021 +0200
|
|
|
d46c83 |
|
|
|
d46c83 |
netfilter: x_tables: fix compat match/target pad out-of-bound write
|
|
|
d46c83 |
|
|
|
d46c83 |
xt_compat_match/target_from_user doesn't check that zeroing the area
|
|
|
d46c83 |
to start of next rule won't write past end of allocated ruleset blob.
|
|
|
d46c83 |
|
|
|
d46c83 |
Remove this code and zero the entire blob beforehand.
|
|
|
d46c83 |
|
|
|
d46c83 |
Reported-by: syzbot+cfc0247ac173f597aaaa@syzkaller.appspotmail.com
|
|
|
d46c83 |
Reported-by: Andy Nguyen <theflow@google.com>
|
|
|
d46c83 |
Fixes: 9fa492cdc160c ("[NETFILTER]: x_tables: simplify compat API")
|
|
|
d46c83 |
Signed-off-by: Florian Westphal <fw@strlen.de>
|
|
|
d46c83 |
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
|
|
|
d46c83 |
|
|
|
d46c83 |
Signed-off-by: Florian Westphal <fwestpha@redhat.com>
|
|
|
d46c83 |
Signed-off-by: Jan Stancek <jstancek@redhat.com>
|
|
|
d46c83 |
|
|
|
d46c83 |
Signed-off-by: Joel Savitz <jsavitz@redhat.com>
|
|
|
d46c83 |
Acked-by: Artem Savkov <asavkov@redhat.com>
|
|
|
d46c83 |
Acked-by: Joe Lawrence <joe.lawrence@redhat.com>
|
|
|
d46c83 |
---
|
|
|
d46c83 |
net/ipv4/netfilter/arp_tables.c | 2 ++
|
|
|
d46c83 |
net/ipv4/netfilter/ip_tables.c | 2 ++
|
|
|
d46c83 |
net/ipv6/netfilter/ip6_tables.c | 2 ++
|
|
|
d46c83 |
net/netfilter/x_tables.c | 10 ++--------
|
|
|
d46c83 |
4 files changed, 8 insertions(+), 8 deletions(-)
|
|
|
d46c83 |
|
|
|
d46c83 |
diff --git a/net/ipv4/netfilter/arp_tables.c b/net/ipv4/netfilter/arp_tables.c
|
|
|
d46c83 |
index ca20efe775ee4..d2ebbeaa9870b 100644
|
|
|
d46c83 |
--- a/net/ipv4/netfilter/arp_tables.c
|
|
|
d46c83 |
+++ b/net/ipv4/netfilter/arp_tables.c
|
|
|
d46c83 |
@@ -1195,6 +1195,8 @@ static int translate_compat_table(struct net *net,
|
|
|
d46c83 |
if (!newinfo)
|
|
|
d46c83 |
goto out_unlock;
|
|
|
d46c83 |
|
|
|
d46c83 |
+ memset(newinfo->entries, 0, size);
|
|
|
d46c83 |
+
|
|
|
d46c83 |
newinfo->number = compatr->num_entries;
|
|
|
d46c83 |
for (i = 0; i < NF_ARP_NUMHOOKS; i++) {
|
|
|
d46c83 |
newinfo->hook_entry[i] = compatr->hook_entry[i];
|
|
|
d46c83 |
diff --git a/net/ipv4/netfilter/ip_tables.c b/net/ipv4/netfilter/ip_tables.c
|
|
|
d46c83 |
index 4cdfb76b9aa8c..8d1545c3bf7b1 100644
|
|
|
d46c83 |
--- a/net/ipv4/netfilter/ip_tables.c
|
|
|
d46c83 |
+++ b/net/ipv4/netfilter/ip_tables.c
|
|
|
d46c83 |
@@ -1433,6 +1433,8 @@ translate_compat_table(struct net *net,
|
|
|
d46c83 |
if (!newinfo)
|
|
|
d46c83 |
goto out_unlock;
|
|
|
d46c83 |
|
|
|
d46c83 |
+ memset(newinfo->entries, 0, size);
|
|
|
d46c83 |
+
|
|
|
d46c83 |
newinfo->number = compatr->num_entries;
|
|
|
d46c83 |
for (i = 0; i < NF_INET_NUMHOOKS; i++) {
|
|
|
d46c83 |
newinfo->hook_entry[i] = compatr->hook_entry[i];
|
|
|
d46c83 |
diff --git a/net/ipv6/netfilter/ip6_tables.c b/net/ipv6/netfilter/ip6_tables.c
|
|
|
d46c83 |
index f7f25eb536d5b..b9d05ea5b9f0f 100644
|
|
|
d46c83 |
--- a/net/ipv6/netfilter/ip6_tables.c
|
|
|
d46c83 |
+++ b/net/ipv6/netfilter/ip6_tables.c
|
|
|
d46c83 |
@@ -1448,6 +1448,8 @@ translate_compat_table(struct net *net,
|
|
|
d46c83 |
if (!newinfo)
|
|
|
d46c83 |
goto out_unlock;
|
|
|
d46c83 |
|
|
|
d46c83 |
+ memset(newinfo->entries, 0, size);
|
|
|
d46c83 |
+
|
|
|
d46c83 |
newinfo->number = compatr->num_entries;
|
|
|
d46c83 |
for (i = 0; i < NF_INET_NUMHOOKS; i++) {
|
|
|
d46c83 |
newinfo->hook_entry[i] = compatr->hook_entry[i];
|
|
|
d46c83 |
diff --git a/net/netfilter/x_tables.c b/net/netfilter/x_tables.c
|
|
|
d46c83 |
index eb66934f36ec2..e258429213cab 100644
|
|
|
d46c83 |
--- a/net/netfilter/x_tables.c
|
|
|
d46c83 |
+++ b/net/netfilter/x_tables.c
|
|
|
d46c83 |
@@ -736,7 +736,7 @@ void xt_compat_match_from_user(struct xt_entry_match *m, void **dstptr,
|
|
|
d46c83 |
{
|
|
|
d46c83 |
const struct xt_match *match = m->u.kernel.match;
|
|
|
d46c83 |
struct compat_xt_entry_match *cm = (struct compat_xt_entry_match *)m;
|
|
|
d46c83 |
- int pad, off = xt_compat_match_offset(match);
|
|
|
d46c83 |
+ int off = xt_compat_match_offset(match);
|
|
|
d46c83 |
u_int16_t msize = cm->u.user.match_size;
|
|
|
d46c83 |
char name[sizeof(m->u.user.name)];
|
|
|
d46c83 |
|
|
|
d46c83 |
@@ -746,9 +746,6 @@ void xt_compat_match_from_user(struct xt_entry_match *m, void **dstptr,
|
|
|
d46c83 |
match->compat_from_user(m->data, cm->data);
|
|
|
d46c83 |
else
|
|
|
d46c83 |
memcpy(m->data, cm->data, msize - sizeof(*cm));
|
|
|
d46c83 |
- pad = XT_ALIGN(match->matchsize) - match->matchsize;
|
|
|
d46c83 |
- if (pad > 0)
|
|
|
d46c83 |
- memset(m->data + match->matchsize, 0, pad);
|
|
|
d46c83 |
|
|
|
d46c83 |
msize += off;
|
|
|
d46c83 |
m->u.user.match_size = msize;
|
|
|
d46c83 |
@@ -1119,7 +1116,7 @@ void xt_compat_target_from_user(struct xt_entry_target *t, void **dstptr,
|
|
|
d46c83 |
{
|
|
|
d46c83 |
const struct xt_target *target = t->u.kernel.target;
|
|
|
d46c83 |
struct compat_xt_entry_target *ct = (struct compat_xt_entry_target *)t;
|
|
|
d46c83 |
- int pad, off = xt_compat_target_offset(target);
|
|
|
d46c83 |
+ int off = xt_compat_target_offset(target);
|
|
|
d46c83 |
u_int16_t tsize = ct->u.user.target_size;
|
|
|
d46c83 |
char name[sizeof(t->u.user.name)];
|
|
|
d46c83 |
|
|
|
d46c83 |
@@ -1129,9 +1126,6 @@ void xt_compat_target_from_user(struct xt_entry_target *t, void **dstptr,
|
|
|
d46c83 |
target->compat_from_user(t->data, ct->data);
|
|
|
d46c83 |
else
|
|
|
d46c83 |
memcpy(t->data, ct->data, tsize - sizeof(*ct));
|
|
|
d46c83 |
- pad = XT_ALIGN(target->targetsize) - target->targetsize;
|
|
|
d46c83 |
- if (pad > 0)
|
|
|
d46c83 |
- memset(t->data + target->targetsize, 0, pad);
|
|
|
d46c83 |
|
|
|
d46c83 |
tsize += off;
|
|
|
d46c83 |
t->u.user.target_size = tsize;
|
|
|
d46c83 |
--
|
|
|
d46c83 |
2.26.3
|
|
|
d46c83 |
|