Skip to content

Commit

Permalink
crypto: rsa-pkcs1pad - fix buffer overread in pkcs1pad_verify_complete()
Browse files Browse the repository at this point in the history
commit a24611e upstream.

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

Fixes: a49de37 ("crypto: Add hash param to pkcs1pad")
Cc: <[email protected]> # v4.6+
Cc: Tadeusz Struk <[email protected]>
Signed-off-by: Eric Biggers <[email protected]>
Signed-off-by: Herbert Xu <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
  • Loading branch information
ebiggers authored and Sasha Levin committed Apr 7, 2022
1 parent c2e1525 commit e997e9e
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions crypto/rsa-pkcs1pad.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit e997e9e

Please sign in to comment.