From: Gilad Ben-Yossef Date: Thu, 18 May 2017 13:29:25 +0000 (+0300) Subject: crypto: gcm - wait for crypto op not signal safe X-Git-Tag: v3.2.93~66 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ed64640fc387a764b18e2961dc9abd5dba22e313;p=thirdparty%2Fkernel%2Fstable.git crypto: gcm - wait for crypto op not signal safe commit f3ad587070d6bd961ab942b3fd7a85d00dfc934b upstream. 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 Signed-off-by: Gilad Ben-Yossef Signed-off-by: Herbert Xu Signed-off-by: Ben Hutchings --- diff --git a/crypto/gcm.c b/crypto/gcm.c index dd3bf30f260bc..9f740857f9f98 100644 --- a/crypto/gcm.c +++ b/crypto/gcm.c @@ -140,10 +140,8 @@ static int crypto_gcm_setkey(struct crypto_aead *aead, const u8 *key, err = crypto_ablkcipher_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)