Skip to contentSkip to conversation

FAILED: patch "[PATCH] crypto: rsa-pkcs1pad - fix buffer overread in" failed to apply to 4.19-stable tree

PATCH [email protected] 1 participant 1 message Apr 2, 2022

Subsystems (3)
lore
Share & tools
lore

[email protected]

author maintainer
#0 lore raw

The patch below does not apply to the 4.19-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.

thanks,

greg k-h

------------------ original commit in Linus's tree ------------------

From a24611ea356c7f3f0ec926da11b9482ac1f414fd Mon Sep 17 00:00:00 2001
From: Eric Biggers <[email protected]>
Date: Tue, 18 Jan 2022 16:13:05 -0800
Subject: [PATCH] crypto: rsa-pkcs1pad - fix buffer overread in
pkcs1pad_verify_complete()

Before checking whether the expected digest_info is present, we need to check that there are enough bytes remaining.

Fixes a49de377e051 ("crypto: Add hash param to pkcs1pad")
Cc <[email protected]> # v4.6+
Cc Tadeusz Struk <[email protected]>
crypto/rsa-pkcs1pad.c +2 -0
index 6b556ddeb3a0..9d804831c8b3 100644
@@ -476,6 +476,8 @@ static int pkcs1pad_verify_complete(struct akcipher_request *req, int err)
 	pos++;
 
 	if (digest_info) {
+		if (digest_info->size > dst_len - pos)
+			goto done;
 		if (crypto_memneq(out_buf + pos, digest_info->data,
 				  digest_info->size))
 			goto done;