summaryrefslogtreecommitdiffstats
path: root/crypto/af_alg.c
diff options
context:
space:
mode:
authorRabin Vincent <rabin.vincent@axis.com>2014-12-19 13:36:08 +0100
committerHerbert Xu <herbert@gondor.apana.org.au>2014-12-22 22:53:55 +1100
commit7e77bdebff5cb1e9876c561f69710b9ab8fa1f7e (patch)
treee7b4064638b86e246e6035e10a0e9910e06aad50 /crypto/af_alg.c
parent97bf6af1f928216fd6c5a66e8a57bfa95a659672 (diff)
downloadop-kernel-dev-7e77bdebff5cb1e9876c561f69710b9ab8fa1f7e.zip
op-kernel-dev-7e77bdebff5cb1e9876c561f69710b9ab8fa1f7e.tar.gz
crypto: af_alg - fix backlog handling
If a request is backlogged, it's complete() handler will get called twice: once with -EINPROGRESS, and once with the final error code. af_alg's complete handler, unlike other users, does not handle the -EINPROGRESS but instead always completes the completion that recvmsg() is waiting on. This can lead to a return to user space while the request is still pending in the driver. If userspace closes the sockets before the requests are handled by the driver, this will lead to use-after-frees (and potential crashes) in the kernel due to the tfm having been freed. The crashes can be easily reproduced (for example) by reducing the max queue length in cryptod.c and running the following (from http://www.chronox.de/libkcapi.html) on AES-NI capable hardware: $ while true; do kcapi -x 1 -e -c '__ecb-aes-aesni' \ -k 00000000000000000000000000000000 \ -p 00000000000000000000000000000000 >/dev/null & done Cc: stable@vger.kernel.org Signed-off-by: Rabin Vincent <rabin.vincent@axis.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'crypto/af_alg.c')
-rw-r--r--crypto/af_alg.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/crypto/af_alg.c b/crypto/af_alg.c
index 1fa7bc3..4665b79 100644
--- a/crypto/af_alg.c
+++ b/crypto/af_alg.c
@@ -455,6 +455,9 @@ void af_alg_complete(struct crypto_async_request *req, int err)
{
struct af_alg_completion *completion = req->data;
+ if (err == -EINPROGRESS)
+ return;
+
completion->err = err;
complete(&completion->completion);
}
OpenPOWER on IntegriCloud