Commit 38b2f68b authored by Herbert Xu's avatar Herbert Xu

crypto: aesni - Fix cryptd reordering problem on gcm

This patch fixes an old bug where gcm requests can be reordered
because some are processed by cryptd while others are processed
directly in softirq context.

The fix is to always postpone to cryptd if there are currently
requests outstanding from the same tfm.
Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
parent 81760ea6
...@@ -1098,9 +1098,12 @@ static int rfc4106_encrypt(struct aead_request *req) ...@@ -1098,9 +1098,12 @@ static int rfc4106_encrypt(struct aead_request *req)
struct cryptd_aead **ctx = crypto_aead_ctx(tfm); struct cryptd_aead **ctx = crypto_aead_ctx(tfm);
struct cryptd_aead *cryptd_tfm = *ctx; struct cryptd_aead *cryptd_tfm = *ctx;
aead_request_set_tfm(req, irq_fpu_usable() ? tfm = &cryptd_tfm->base;
cryptd_aead_child(cryptd_tfm) : if (irq_fpu_usable() && (!in_atomic() ||
&cryptd_tfm->base); !cryptd_aead_queued(cryptd_tfm)))
tfm = cryptd_aead_child(cryptd_tfm);
aead_request_set_tfm(req, tfm);
return crypto_aead_encrypt(req); return crypto_aead_encrypt(req);
} }
...@@ -1111,9 +1114,12 @@ static int rfc4106_decrypt(struct aead_request *req) ...@@ -1111,9 +1114,12 @@ static int rfc4106_decrypt(struct aead_request *req)
struct cryptd_aead **ctx = crypto_aead_ctx(tfm); struct cryptd_aead **ctx = crypto_aead_ctx(tfm);
struct cryptd_aead *cryptd_tfm = *ctx; struct cryptd_aead *cryptd_tfm = *ctx;
aead_request_set_tfm(req, irq_fpu_usable() ? tfm = &cryptd_tfm->base;
cryptd_aead_child(cryptd_tfm) : if (irq_fpu_usable() && (!in_atomic() ||
&cryptd_tfm->base); !cryptd_aead_queued(cryptd_tfm)))
tfm = cryptd_aead_child(cryptd_tfm);
aead_request_set_tfm(req, tfm);
return crypto_aead_decrypt(req); return crypto_aead_decrypt(req);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment