Skip to content

Commit

Permalink
crypto: gcm - wait for crypto op not signal safe
Browse files Browse the repository at this point in the history
crypto_gcm_setkey() was using wait_for_completion_interruptible() to
wait for completion of async crypto op but if a signal occurs it
may return before DMA ops of HW crypto provider finish, thus
corrupting the data buffer that is kfree'ed in this case.

Resolve this by using wait_for_completion() instead.

Reported-by: Eric Biggers <[email protected]>
Signed-off-by: Gilad Ben-Yossef <[email protected]>
CC: [email protected]
Signed-off-by: Herbert Xu <[email protected]>
  • Loading branch information
gby authored and herbertx committed May 23, 2017
1 parent a5dfefb commit f3ad587
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions crypto/gcm.c
Original file line number Diff line number Diff line change
Expand Up @@ -152,10 +152,8 @@ static int crypto_gcm_setkey(struct crypto_aead *aead, const u8 *key,

err = crypto_skcipher_encrypt(&data->req);
if (err == -EINPROGRESS || err == -EBUSY) {
err = wait_for_completion_interruptible(
&data->result.completion);
if (!err)
err = data->result.err;
wait_for_completion(&data->result.completion);
err = data->result.err;
}

if (err)
Expand Down

0 comments on commit f3ad587

Please sign in to comment.