When we perform a walk in the completion function, we need to ensure that it is atomic. Fixes: ac3c8f36c31d ("crypto: lrw - Do not use auxiliary buffer") Cc: <stable@xxxxxxxxxxxxxxx> Signed-off-by: Herbert Xu <herbert@xxxxxxxxxxxxxxxxxxx> diff --git a/crypto/lrw.c b/crypto/lrw.c index 0430ccd08728..aef3588e1550 100644 --- a/crypto/lrw.c +++ b/crypto/lrw.c @@ -143,7 +143,8 @@ static int next_index(u32 *counter) * mutliple calls to the 'ecb(..)' instance, which usually would be slower than * just doing the next_index() calls again. */ -static int xor_tweak(struct skcipher_request *req, bool second_pass) +static int xor_tweak(struct skcipher_request *req, bool second_pass, + bool atomic) { const int bs = LRW_BLOCK_SIZE; struct crypto_skcipher *tfm = crypto_skcipher_reqtfm(req); @@ -161,7 +162,7 @@ static int xor_tweak(struct skcipher_request *req, bool second_pass) skcipher_request_set_tfm(req, tfm); } - err = skcipher_walk_virt(&w, req, false); + err = skcipher_walk_virt(&w, req, atomic); iv = (__be32 *)w.iv; counter[0] = be32_to_cpu(iv[3]); @@ -200,12 +201,12 @@ static int xor_tweak(struct skcipher_request *req, bool second_pass) static int xor_tweak_pre(struct skcipher_request *req) { - return xor_tweak(req, false); + return xor_tweak(req, false, false); } -static int xor_tweak_post(struct skcipher_request *req) +static int xor_tweak_post(struct skcipher_request *req, bool atomic) { - return xor_tweak(req, true); + return xor_tweak(req, true, atomic); } static void crypt_done(struct crypto_async_request *areq, int err) @@ -213,7 +214,7 @@ static void crypt_done(struct crypto_async_request *areq, int err) struct skcipher_request *req = areq->data; if (!err) - err = xor_tweak_post(req); + err = xor_tweak_post(req, true); skcipher_request_complete(req, err); } @@ -245,7 +246,7 @@ static int encrypt(struct skcipher_request *req) init_crypt(req); return xor_tweak_pre(req) ?: crypto_skcipher_encrypt(subreq) ?: - xor_tweak_post(req); + xor_tweak_post(req, false); } static int decrypt(struct skcipher_request *req) @@ -256,7 +257,7 @@ static int decrypt(struct skcipher_request *req) init_crypt(req); return xor_tweak_pre(req) ?: crypto_skcipher_decrypt(subreq) ?: - xor_tweak_post(req); + xor_tweak_post(req, false); } static int init_tfm(struct crypto_skcipher *tfm) -- Email: Herbert Xu <herbert@xxxxxxxxxxxxxxxxxxx> Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt