[PATCH 02/10] crypto: marvell - Fix AEAD key buffer overflow for SHA-384/512 HMAC
From: Lee Jones
Date: Mon Nov 23 2026 - 10:11:30 EST
Commit 311eea7e37c4 ("crypto: octeontx - Fix authenc setkey") and commit
7ccb750dcac8 ("crypto: octeontx2 - Fix authenc setkey") updated
aead_hmac_init() in the OcteonTX and OcteonTX2 CPT VF drivers to hash
authentication keys only when authkeylen exceeds the hash block size
(128 bytes for SHA-384 and SHA-512), copying shorter keys directly into
ctx->key followed by the encryption key.
However, OTX_CPT_MAX_HASH_KEY_SIZE and OTX2_CPT_MAX_HASH_KEY_SIZE are
defined as 64 rather than 128, sizing ctx->key at only 96 bytes. An
HMAC-SHA384 or HMAC-SHA512 AEAD key with an authentication key between
65 and 128 bytes writes up to 160 bytes into ctx->key, clobbering the
adjacent hashalg, sdesc, ipad, and opad pointers in struct
otx_cpt_aead_ctx and struct otx2_cpt_aead_ctx before writing through
ctx->ipad.
Increase OTX_CPT_MAX_HASH_KEY_SIZE and OTX2_CPT_MAX_HASH_KEY_SIZE to
128 to accommodate a full SHA-384/512 block-sized HMAC key.
Fixes: 311eea7e37c4 ("crypto: octeontx - Fix authenc setkey")
Fixes: 7ccb750dcac8 ("crypto: octeontx2 - Fix authenc setkey")
Closes: https://sashiko.dev/#/bug/linux-bf3e3416-972b-4a32-bb3c-9fe7d3f28c9d
Cc: stable@xxxxxxxxxxxxxxx
Signed-off-by: Lee Jones <lee@xxxxxxxxxx>
---
drivers/crypto/marvell/octeontx/otx_cptvf_algs.h | 2 +-
drivers/crypto/marvell/octeontx2/otx2_cptvf_algs.h | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/crypto/marvell/octeontx/otx_cptvf_algs.h b/drivers/crypto/marvell/octeontx/otx_cptvf_algs.h
index a50b5e2f8d00..29976126d5cf 100644
--- a/drivers/crypto/marvell/octeontx/otx_cptvf_algs.h
+++ b/drivers/crypto/marvell/octeontx/otx_cptvf_algs.h
@@ -15,7 +15,7 @@
#include "otx_cpt_common.h"
#define OTX_CPT_MAX_ENC_KEY_SIZE 32
-#define OTX_CPT_MAX_HASH_KEY_SIZE 64
+#define OTX_CPT_MAX_HASH_KEY_SIZE 128
#define OTX_CPT_MAX_KEY_SIZE (OTX_CPT_MAX_ENC_KEY_SIZE + \
OTX_CPT_MAX_HASH_KEY_SIZE)
enum otx_cpt_request_type {
diff --git a/drivers/crypto/marvell/octeontx2/otx2_cptvf_algs.h b/drivers/crypto/marvell/octeontx2/otx2_cptvf_algs.h
index d29f84f01cee..cbc590e9e020 100644
--- a/drivers/crypto/marvell/octeontx2/otx2_cptvf_algs.h
+++ b/drivers/crypto/marvell/octeontx2/otx2_cptvf_algs.h
@@ -12,7 +12,7 @@
#include "cn10k_cpt.h"
#define OTX2_CPT_MAX_ENC_KEY_SIZE 32
-#define OTX2_CPT_MAX_HASH_KEY_SIZE 64
+#define OTX2_CPT_MAX_HASH_KEY_SIZE 128
#define OTX2_CPT_MAX_KEY_SIZE (OTX2_CPT_MAX_ENC_KEY_SIZE + \
OTX2_CPT_MAX_HASH_KEY_SIZE)
enum otx2_cpt_request_type {
--
2.56.1.750.gf70dc682cf-goog