dm crypt: fix deadlock when async crypto algorithm returns -EBUSY
authorBen Collins <ben.c@servergy.com>
Fri, 3 Apr 2015 16:09:46 +0000 (16:09 +0000)
committerMike Snitzer <snitzer@redhat.com>
Wed, 15 Apr 2015 16:10:26 +0000 (12:10 -0400)
commit0618764cb25f6fa9fb31152995de42a8a0496475
tree16e5a37e6f584465d05c8df160a81e35609182a8
parent5977907937afa2b5584a874d44ba6c0f56aeaa9c
dm crypt: fix deadlock when async crypto algorithm returns -EBUSY

I suspect this doesn't show up for most anyone because software
algorithms typically don't have a sense of being too busy.  However,
when working with the Freescale CAAM driver it will return -EBUSY on
occasion under heavy -- which resulted in dm-crypt deadlock.

After checking the logic in some other drivers, the scheme for
crypt_convert() and it's callback, kcryptd_async_done(), were not
correctly laid out to properly handle -EBUSY or -EINPROGRESS.

Fix this by using the completion for both -EBUSY and -EINPROGRESS.  Now
crypt_convert()'s use of completion is comparable to
af_alg_wait_for_completion().  Similarly, kcryptd_async_done() follows
the pattern used in af_alg_complete().

Before this fix dm-crypt would lockup within 1-2 minutes running with
the CAAM driver.  Fix was regression tested against software algorithms
on PPC32 and x86_64, and things seem perfectly happy there as well.

Signed-off-by: Ben Collins <ben.c@servergy.com>
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
Cc: stable@vger.kernel.org
drivers/md/dm-crypt.c