Skip to contentSkip to conversation

crypto: skcipher - add might_sleep() to skcipher_walk_virt()

PATCH In review Eric Biggers 2 participants 2 messages Dec 15, 2018 – Dec 23, 2018 Crypto API

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 crypto: skcipher - add might_sleep() to skcipher_walk_virt()

From: Eric Biggers <[email protected]>

skcipher_walk_virt() can still sleep even with atomic=true, since that only affects the later calls to skcipher_walk_done(). But, skcipher_walk_virt() only has to allocate memory for some input data layouts, so incorrectly calling it with preemption disabled can go undetected. Use might_sleep() so that it's detected reliably.

---
 crypto/skcipher.c | 2 ++
 1 file changed, 2 insertions(+)
crypto/skcipher.c +2 -0
index 17be8d9c714eb..41b4f7f27f454 100644
@@ -474,6 +474,8 @@ int skcipher_walk_virt(struct skcipher_walk *walk,
 {
 	int err;
 
+	might_sleep_if(req->base.flags & CRYPTO_TFM_REQ_MAY_SLEEP);
+
 	walk->flags &= ~SKCIPHER_WALK_PHYS;
 
 	err = skcipher_walk_skcipher(walk, req);
Signature · 1 line
2.19.2
maintainer
#1 lore raw
Quoted 8 lines · Eric Biggers

From: Eric Biggers <[email protected]>

skcipher_walk_virt() can still sleep even with atomic=true, since that only affects the later calls to skcipher_walk_done(). But, skcipher_walk_virt() only has to allocate memory for some input data layouts, so incorrectly calling it with preemption disabled can go undetected. Use might_sleep() so that it's detected reliably.

Quoted 4 lines
---
 crypto/skcipher.c | 2 ++
 1 file changed, 2 insertions(+)

Patch applied. Thanks.

Signature · 3 lines
Email: Herbert Xu <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt