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