From ad98438baaae5dc0e58e19e2a7bd62f7b5452c49 Mon Sep 17 00:00:00 2001 From: Daniel Pouzzner Date: Mon, 8 Jun 2026 18:15:51 -0500 Subject: [PATCH] fixes for F-5335: ECDH overflow paths do not report the required output length F-5336: RSA PKCS#1 overflow paths do not report the required output length --- linuxkm/lkcapi_ecdh_glue.c | 2 ++ linuxkm/lkcapi_rsa_glue.c | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/linuxkm/lkcapi_ecdh_glue.c b/linuxkm/lkcapi_ecdh_glue.c index 57a0831547..a9325c23e0 100644 --- a/linuxkm/lkcapi_ecdh_glue.c +++ b/linuxkm/lkcapi_ecdh_glue.c @@ -493,6 +493,7 @@ static int km_ecdh_gen_pub(struct kpp_request *req) pr_err("error: dst_len too small: %d\n", req->dst_len); #endif /* WOLFKM_DEBUG_ECDH */ err = -EOVERFLOW; + req->dst_len = raw_pub_len; goto ecdh_gen_pub_end; } @@ -650,6 +651,7 @@ static int km_ecdh_compute_shared_secret(struct kpp_request *req) if (req->dst_len < shared_secret_len) { err = -EOVERFLOW; + req->dst_len = shared_secret_len; goto ecdh_shared_secret_end; } diff --git a/linuxkm/lkcapi_rsa_glue.c b/linuxkm/lkcapi_rsa_glue.c index f76a8cbee9..2a0dba6cfe 100644 --- a/linuxkm/lkcapi_rsa_glue.c +++ b/linuxkm/lkcapi_rsa_glue.c @@ -832,6 +832,7 @@ static int km_direct_rsa_dec(struct akcipher_request *req) if (out_len > req->dst_len) { err = -EOVERFLOW; + req->dst_len = out_len; goto rsa_dec_out; } @@ -1121,6 +1122,7 @@ static int km_pkcs1pad_sign(struct akcipher_request *req) if (req->dst_len < ctx->key_len) { err = -EOVERFLOW; + req->dst_len = ctx->key_len; goto pkcs1pad_sign_out; } @@ -1688,6 +1690,7 @@ static int km_pkcs1pad_enc(struct akcipher_request *req) if (req->dst_len < ctx->key_len) { err = -EOVERFLOW; + req->dst_len = ctx->key_len; goto pkcs1_enc_out; } @@ -1806,6 +1809,7 @@ static int km_pkcs1pad_dec(struct akcipher_request *req) if (dec_len > req->dst_len) { err = -EOVERFLOW; + req->dst_len = dec_len; goto pkcs1_dec_out; }