diff options
author | Herbert Xu <herbert@gondor.apana.org.au> | 2006-12-10 10:45:28 +1100 |
---|---|---|
committer | Herbert Xu <herbert@gondor.apana.org.au> | 2007-02-07 09:20:58 +1100 |
commit | fb469840b8c34b2f95b40a64b271f245cc1075b7 (patch) | |
tree | 8013f8beb39c83b80be0e40195005b0482cea69b /crypto/blkcipher.c | |
parent | 62d0cfcb27cf755cebdc93ca95dabc83608007cd (diff) | |
download | lwn-fb469840b8c34b2f95b40a64b271f245cc1075b7.tar.gz lwn-fb469840b8c34b2f95b40a64b271f245cc1075b7.zip |
[CRYPTO] all: Check for usage in hard IRQ context
Using blkcipher/hash crypto operations in hard IRQ context can lead
to random memory corruption due to the reuse of kmap_atomic slots.
Since crypto operations were never meant to be used in hard IRQ
contexts, this patch checks for such usage and returns an error
before kmap_atomic is performed.
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'crypto/blkcipher.c')
-rw-r--r-- | crypto/blkcipher.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/crypto/blkcipher.c b/crypto/blkcipher.c index 6e93004f2181..cbb4c4e5c229 100644 --- a/crypto/blkcipher.c +++ b/crypto/blkcipher.c @@ -16,6 +16,7 @@ #include <linux/crypto.h> #include <linux/errno.h> +#include <linux/hardirq.h> #include <linux/kernel.h> #include <linux/module.h> #include <linux/scatterlist.h> @@ -313,6 +314,9 @@ static int blkcipher_walk_first(struct blkcipher_desc *desc, struct crypto_blkcipher *tfm = desc->tfm; unsigned int alignmask = crypto_blkcipher_alignmask(tfm); + if (WARN_ON_ONCE(in_irq())) + return -EDEADLK; + walk->nbytes = walk->total; if (unlikely(!walk->total)) return 0; |