]> git.baikalelectronics.ru Git - kernel.git/commit
crc-t10dif: Fix potential crypto notify dead-lock
authorHerbert Xu <herbert@gondor.apana.org.au>
Fri, 5 Jun 2020 06:59:18 +0000 (16:59 +1000)
committerHerbert Xu <herbert@gondor.apana.org.au>
Thu, 18 Jun 2020 07:26:42 +0000 (17:26 +1000)
commit9e15ca38a6d5ee1465d0ecaac01cfabacc3ba7da
tree8a877b2d3f7552a941fbdf453356a34c7127a62c
parent65dc77da4835d933d6919efae24ff45c15d67032
crc-t10dif: Fix potential crypto notify dead-lock

The crypto notify call occurs with a read mutex held so you must
not do any substantial work directly.  In particular, you cannot
call crypto_alloc_* as they may trigger further notifications
which may dead-lock in the presence of another writer.

This patch fixes this by postponing the work into a work queue and
taking the same lock in the module init function.

While we're at it this patch also ensures that all RCU accesses are
marked appropriately (tested with sparse).

Finally this also reveals a race condition in module param show
function as it may be called prior to the module init function.
It's fixed by testing whether crct10dif_tfm is NULL (this is true
iff the init function has not completed assuming fallback is false).

Fixes: 08d7d4bd35d0 ("crc-t10dif: Allow current transform to be...")
Fixes: 58d84c0ee6ba ("crc-t10dif: Pick better transform if one...")
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>
Reviewed-by: Eric Biggers <ebiggers@google.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
lib/crc-t10dif.c