summaryrefslogtreecommitdiffstats
path: root/crypto
diff options
context:
space:
mode:
authorFrederick Lawler <fred@cloudflare.com>2023-08-01 15:57:09 +0200
committerHerbert Xu <herbert@gondor.apana.org.au>2023-08-11 13:19:27 +0200
commit6b4b53ca0b7300ba2af98a49dbce22054bf034fe (patch)
tree975733217d41070d06a3c6c139499a64f5e5bb7d /crypto
parentcrypto: arm64/aes - remove Makefile hack (diff)
downloadlinux-6b4b53ca0b7300ba2af98a49dbce22054bf034fe.tar.xz
linux-6b4b53ca0b7300ba2af98a49dbce22054bf034fe.zip
crypto: af_alg - Decrement struct key.usage in alg_set_by_key_serial()
Calls to lookup_user_key() require a corresponding key_put() to decrement the usage counter. Once it reaches zero, we schedule key GC. Therefore decrement struct key.usage in alg_set_by_key_serial(). Fixes: 7984ceb134bf ("crypto: af_alg - Support symmetric encryption via keyring keys") Cc: <stable@vger.kernel.org> Signed-off-by: Frederick Lawler <fred@cloudflare.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'crypto')
-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 9ee8575d3b1a..e9969dc0e83c 100644
--- a/crypto/af_alg.c
+++ b/crypto/af_alg.c
@@ -320,18 +320,21 @@ static int alg_setkey_by_key_serial(struct alg_sock *ask, sockptr_t optval,
if (IS_ERR(ret)) {
up_read(&key->sem);
+ key_put(key);
return PTR_ERR(ret);
}
key_data = sock_kmalloc(&ask->sk, key_datalen, GFP_KERNEL);
if (!key_data) {
up_read(&key->sem);
+ key_put(key);
return -ENOMEM;
}
memcpy(key_data, ret, key_datalen);
up_read(&key->sem);
+ key_put(key);
err = type->setkey(ask->private, key_data, key_datalen);