Skip to content

Commit f3ad587

Browse files
Gilad Ben-Yossefherbertx
authored andcommitted
crypto: gcm - wait for crypto op not signal safe
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]>
1 parent a5dfefb commit f3ad587

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

crypto/gcm.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -152,10 +152,8 @@ static int crypto_gcm_setkey(struct crypto_aead *aead, const u8 *key,
152152

153153
err = crypto_skcipher_encrypt(&data->req);
154154
if (err == -EINPROGRESS || err == -EBUSY) {
155-
err = wait_for_completion_interruptible(
156-
&data->result.completion);
157-
if (!err)
158-
err = data->result.err;
155+
wait_for_completion(&data->result.completion);
156+
err = data->result.err;
159157
}
160158

161159
if (err)

0 commit comments

Comments
 (0)