Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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: <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>

authored by

Eric Biggers and committed by
Herbert Xu
a24611ea d3481acc

+2
+2
crypto/rsa-pkcs1pad.c
··· 476 476 pos++; 477 477 478 478 if (digest_info) { 479 + if (digest_info->size > dst_len - pos) 480 + goto done; 479 481 if (crypto_memneq(out_buf + pos, digest_info->data, 480 482 digest_info->size)) 481 483 goto done;