diff options
author | Eric Biggers <ebiggers@google.com> | 2022-01-19 03:13:05 +0300 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2022-04-08 15:39:57 +0300 |
commit | 37d2b4fa5cddc567e7570e89982978017272fe20 (patch) | |
tree | cacff0f237e26e7fd06128d0a6bbf6164db4e9df | |
parent | b89fb8b8824222c0568ad03e02c612df0746959e (diff) | |
download | linux-37d2b4fa5cddc567e7570e89982978017272fe20.tar.xz |
crypto: rsa-pkcs1pad - fix buffer overread in pkcs1pad_verify_complete()
commit a24611ea356c7f3f0ec926da11b9482ac1f414fd upstream.
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: <stable@vger.kernel.org> # v4.6+
Cc: Tadeusz Struk <tadeusz.struk@linaro.org>
Signed-off-by: Eric Biggers <ebiggers@google.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r-- | crypto/rsa-pkcs1pad.c | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/crypto/rsa-pkcs1pad.c b/crypto/rsa-pkcs1pad.c index 6b556ddeb3a0..9d804831c8b3 100644 --- a/crypto/rsa-pkcs1pad.c +++ b/crypto/rsa-pkcs1pad.c @@ -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; |