|
|
cc95c1 |
From e414978bb06091697e96008f8500db4e86dc8b23 Mon Sep 17 00:00:00 2001
|
|
|
cc95c1 |
From: Artem Savkov <asavkov@redhat.com>
|
|
|
cc95c1 |
Date: Fri, 5 Nov 2021 15:13:50 +0100
|
|
|
cc95c1 |
Subject: [KPATCH CVE-2021-43267] tipc: fix size validations for the MSG_CRYPTO
|
|
|
cc95c1 |
type
|
|
|
cc95c1 |
|
|
|
cc95c1 |
Kernels:
|
|
|
cc95c1 |
4.18.0-348.el8
|
|
|
cc95c1 |
4.18.0-348.1.1.el8_5
|
|
|
cc95c1 |
|
|
|
cc95c1 |
Changes since last build:
|
|
|
cc95c1 |
arches: x86_64 ppc64le
|
|
|
cc95c1 |
crypto.o: changed function: tipc_crypto_msg_rcv
|
|
|
cc95c1 |
---------------------------
|
|
|
cc95c1 |
|
|
|
cc95c1 |
Kpatch-MR: https://gitlab.com/redhat/prdsc/rhel/src/kpatch/rhel-8/-/merge_requests/7
|
|
|
cc95c1 |
Approved-by: Joe Lawrence (@joe.lawrence)
|
|
|
cc95c1 |
Kernels:
|
|
|
cc95c1 |
4.18.0-348.el8
|
|
|
cc95c1 |
|
|
|
cc95c1 |
Modifications: none
|
|
|
cc95c1 |
|
|
|
cc95c1 |
commit ff06de0480d0fdbdd6a3a9db663ffcd0297025c0
|
|
|
cc95c1 |
Author: Bruno Meneguele <bmeneg@redhat.com>
|
|
|
cc95c1 |
Date: Fri Nov 5 10:38:28 2021 -0300
|
|
|
cc95c1 |
|
|
|
cc95c1 |
tipc: fix size validations for the MSG_CRYPTO type
|
|
|
cc95c1 |
|
|
|
cc95c1 |
Bugzilla: https://bugzilla.redhat.com/2020506
|
|
|
cc95c1 |
CVE: CVE-2021-43267
|
|
|
cc95c1 |
Y-Commit: fa40d9734a57bcbfa79a280189799f76c88f7bb0
|
|
|
cc95c1 |
|
|
|
cc95c1 |
O-Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2020506
|
|
|
cc95c1 |
O-CVE: CVE-2021-43267
|
|
|
cc95c1 |
|
|
|
cc95c1 |
The function tipc_crypto_key_rcv is used to parse MSG_CRYPTO messages
|
|
|
cc95c1 |
to receive keys from other nodes in the cluster in order to decrypt any
|
|
|
cc95c1 |
further messages from them.
|
|
|
cc95c1 |
This patch verifies that any supplied sizes in the message body are
|
|
|
cc95c1 |
valid for the received message.
|
|
|
cc95c1 |
|
|
|
cc95c1 |
Fixes: 1ef6f7c9390f ("tipc: add automatic session key exchange")
|
|
|
cc95c1 |
Signed-off-by: Max VA <maxv@sentinelone.com>
|
|
|
cc95c1 |
Acked-by: Ying Xue <ying.xue@windriver.com>
|
|
|
cc95c1 |
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
|
|
|
cc95c1 |
Acked-by: Jon Maloy <jmaloy@redhat.com>
|
|
|
cc95c1 |
Signed-off-by: David S. Miller <davem@davemloft.net>
|
|
|
cc95c1 |
(cherry picked from commit fa40d9734a57bcbfa79a280189799f76c88f7bb0)
|
|
|
cc95c1 |
Signed-off-by: Bruno Meneguele <bmeneg@redhat.com>
|
|
|
cc95c1 |
|
|
|
cc95c1 |
Signed-off-by: Artem Savkov <asavkov@redhat.com>
|
|
|
cc95c1 |
---
|
|
|
cc95c1 |
net/tipc/crypto.c | 32 +++++++++++++++++++++-----------
|
|
|
cc95c1 |
1 file changed, 21 insertions(+), 11 deletions(-)
|
|
|
cc95c1 |
|
|
|
cc95c1 |
diff --git a/net/tipc/crypto.c b/net/tipc/crypto.c
|
|
|
cc95c1 |
index 40ff244f2499..b4f8c0a234a0 100644
|
|
|
cc95c1 |
--- a/net/tipc/crypto.c
|
|
|
cc95c1 |
+++ b/net/tipc/crypto.c
|
|
|
cc95c1 |
@@ -2279,43 +2279,53 @@ static bool tipc_crypto_key_rcv(struct tipc_crypto *rx, struct tipc_msg *hdr)
|
|
|
cc95c1 |
u16 key_gen = msg_key_gen(hdr);
|
|
|
cc95c1 |
u16 size = msg_data_sz(hdr);
|
|
|
cc95c1 |
u8 *data = msg_data(hdr);
|
|
|
cc95c1 |
+ unsigned int keylen;
|
|
|
cc95c1 |
+
|
|
|
cc95c1 |
+ /* Verify whether the size can exist in the packet */
|
|
|
cc95c1 |
+ if (unlikely(size < sizeof(struct tipc_aead_key) + TIPC_AEAD_KEYLEN_MIN)) {
|
|
|
cc95c1 |
+ pr_debug("%s: message data size is too small\n", rx->name);
|
|
|
cc95c1 |
+ goto exit;
|
|
|
cc95c1 |
+ }
|
|
|
cc95c1 |
+
|
|
|
cc95c1 |
+ keylen = ntohl(*((__be32 *)(data + TIPC_AEAD_ALG_NAME)));
|
|
|
cc95c1 |
+
|
|
|
cc95c1 |
+ /* Verify the supplied size values */
|
|
|
cc95c1 |
+ if (unlikely(size != keylen + sizeof(struct tipc_aead_key) ||
|
|
|
cc95c1 |
+ keylen > TIPC_AEAD_KEY_SIZE_MAX)) {
|
|
|
cc95c1 |
+ pr_debug("%s: invalid MSG_CRYPTO key size\n", rx->name);
|
|
|
cc95c1 |
+ goto exit;
|
|
|
cc95c1 |
+ }
|
|
|
cc95c1 |
|
|
|
cc95c1 |
spin_lock(&rx->lock);
|
|
|
cc95c1 |
if (unlikely(rx->skey || (key_gen == rx->key_gen && rx->key.keys))) {
|
|
|
cc95c1 |
pr_err("%s: key existed <%p>, gen %d vs %d\n", rx->name,
|
|
|
cc95c1 |
rx->skey, key_gen, rx->key_gen);
|
|
|
cc95c1 |
- goto exit;
|
|
|
cc95c1 |
+ goto exit_unlock;
|
|
|
cc95c1 |
}
|
|
|
cc95c1 |
|
|
|
cc95c1 |
/* Allocate memory for the key */
|
|
|
cc95c1 |
skey = kmalloc(size, GFP_ATOMIC);
|
|
|
cc95c1 |
if (unlikely(!skey)) {
|
|
|
cc95c1 |
pr_err("%s: unable to allocate memory for skey\n", rx->name);
|
|
|
cc95c1 |
- goto exit;
|
|
|
cc95c1 |
+ goto exit_unlock;
|
|
|
cc95c1 |
}
|
|
|
cc95c1 |
|
|
|
cc95c1 |
/* Copy key from msg data */
|
|
|
cc95c1 |
- skey->keylen = ntohl(*((__be32 *)(data + TIPC_AEAD_ALG_NAME)));
|
|
|
cc95c1 |
+ skey->keylen = keylen;
|
|
|
cc95c1 |
memcpy(skey->alg_name, data, TIPC_AEAD_ALG_NAME);
|
|
|
cc95c1 |
memcpy(skey->key, data + TIPC_AEAD_ALG_NAME + sizeof(__be32),
|
|
|
cc95c1 |
skey->keylen);
|
|
|
cc95c1 |
|
|
|
cc95c1 |
- /* Sanity check */
|
|
|
cc95c1 |
- if (unlikely(size != tipc_aead_key_size(skey))) {
|
|
|
cc95c1 |
- kfree(skey);
|
|
|
cc95c1 |
- skey = NULL;
|
|
|
cc95c1 |
- goto exit;
|
|
|
cc95c1 |
- }
|
|
|
cc95c1 |
-
|
|
|
cc95c1 |
rx->key_gen = key_gen;
|
|
|
cc95c1 |
rx->skey_mode = msg_key_mode(hdr);
|
|
|
cc95c1 |
rx->skey = skey;
|
|
|
cc95c1 |
rx->nokey = 0;
|
|
|
cc95c1 |
mb(); /* for nokey flag */
|
|
|
cc95c1 |
|
|
|
cc95c1 |
-exit:
|
|
|
cc95c1 |
+exit_unlock:
|
|
|
cc95c1 |
spin_unlock(&rx->lock);
|
|
|
cc95c1 |
|
|
|
cc95c1 |
+exit:
|
|
|
cc95c1 |
/* Schedule the key attaching on this crypto */
|
|
|
cc95c1 |
if (likely(skey && queue_delayed_work(tx->wq, &rx->work, 0)))
|
|
|
cc95c1 |
return true;
|
|
|
cc95c1 |
--
|
|
|
cc95c1 |
2.31.1
|
|
|
cc95c1 |
|
|
|
cc95c1 |
|