Skip to content

Commit

Permalink
crypto: simd - correctly take reqsize of wrapped skcipher into account
Browse files Browse the repository at this point in the history
The simd wrapper's skcipher request context structure consists
of a single subrequest whose size is taken from the subordinate
skcipher. However, in simd_skcipher_init(), the reqsize that is
retrieved is not from the subordinate skcipher but from the
cryptd request structure, whose size is completely unrelated to
the actual wrapped skcipher.

Reported-by: Qian Cai <[email protected]>
Signed-off-by: Ard Biesheuvel <[email protected]>
Tested-by: Qian Cai <[email protected]>
Signed-off-by: Herbert Xu <[email protected]>
  • Loading branch information
Ard Biesheuvel authored and herbertx committed Nov 9, 2018
1 parent 0b0cf6a commit 508a1c4
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions crypto/simd.c
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,9 @@ static int simd_skcipher_init(struct crypto_skcipher *tfm)

ctx->cryptd_tfm = cryptd_tfm;

reqsize = sizeof(struct skcipher_request);
reqsize += crypto_skcipher_reqsize(&cryptd_tfm->base);
reqsize = crypto_skcipher_reqsize(cryptd_skcipher_child(cryptd_tfm));
reqsize = max(reqsize, crypto_skcipher_reqsize(&cryptd_tfm->base));
reqsize += sizeof(struct skcipher_request);

crypto_skcipher_set_reqsize(tfm, reqsize);

Expand Down

0 comments on commit 508a1c4

Please sign in to comment.