Message ID | 20230801135709.2218855-1-fred@cloudflare.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:918b:0:b0:3e4:2afc:c1 with SMTP id s11csp2824683vqg; Tue, 1 Aug 2023 10:32:02 -0700 (PDT) X-Google-Smtp-Source: APBJJlEdHt1Rh4HCdkYFp4pUPxEDpy6nHihIRzwOaEWBRvboW+HwuPSOF6M1ZQWED1/+6C9uYoeQ X-Received: by 2002:a05:6a20:a11c:b0:12c:2dc7:74bc with SMTP id q28-20020a056a20a11c00b0012c2dc774bcmr17749987pzk.46.1690911122486; Tue, 01 Aug 2023 10:32:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690911122; cv=none; d=google.com; s=arc-20160816; b=eUjcO2HDN4wTrQNiMjAg3ZjtEXwgxd7wxr/4eId0yuMTkSnC7p/rqPUM8F5G1VMRY/ y65M3jHnAcqbMBlt4Haxdqo9htIZfii8dK66nhdCWs5yPsBystx1tKnX0QnQ59sRnLtF sYPfaRJq2OPsB+8/F3Yr1UdjFvm+NRsiVlN4zsxoReumJbATlCYg70sCYPlPJFP6JKuo W/ERB0iJMWy6ucYScVO4CoY1kpCg5U8kq1ClFQtQ2VpXFLFpoz8QPL9XZHIeI2quBmLh 15sKe/LyRm7Ltj9Ryk+dCebDtLIj9cKqU9y3SxWz6vb1hGGJ1eoWK9W698Eld0clbedN qhGg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=V63lX8jJADmT+x3ehocFhAwNy3zEROKPKQmkKeMAkns=; fh=JhvgLcIUg4AM9IqffuCk9luRZGyvrOiZa9PqWvv0E8w=; b=hCbt845GjD/fog/qCL+L5ZJcW2sFOf+O+TRMiR0yKTxHJgxNk1beSUsV9QLQ8oY8/V u10SBNYeWVERI0v4N+1x8vQmdAajd3OW98ENCNAk1YUz+BV0NNyLscrCi2uylIfz2Okn 6g/AgR/WXTqUC8vJAojX+SiX/CGxUCJag43TqGRcsBFavCfUr6/NzY4k6UHYCcp23U5o kLwWIqYkXS+j0fWU2LU9jVyq4B18NrzVUTFv+g0AF28zOlEjGEsX8ta09B5Uf91X1723 zBibA1WdIg27jjSBMocsOeP7/ggpkNs+oSm6PgYWcm+QhkPbGFuZHaJjWvw9wWexTwht RAdw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cloudflare.com header.s=google header.b=XisN9mTl; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=cloudflare.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u191-20020a6385c8000000b005638355e990si1849599pgd.410.2023.08.01.10.31.48; Tue, 01 Aug 2023 10:32:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@cloudflare.com header.s=google header.b=XisN9mTl; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=cloudflare.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233836AbjHAN5Y (ORCPT <rfc822;maxi.paulin@gmail.com> + 99 others); Tue, 1 Aug 2023 09:57:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54700 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232243AbjHAN5X (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Tue, 1 Aug 2023 09:57:23 -0400 Received: from mail-il1-x130.google.com (mail-il1-x130.google.com [IPv6:2607:f8b0:4864:20::130]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 85AA4C3 for <linux-kernel@vger.kernel.org>; Tue, 1 Aug 2023 06:57:18 -0700 (PDT) Received: by mail-il1-x130.google.com with SMTP id e9e14a558f8ab-3491a8e6fd1so10863435ab.3 for <linux-kernel@vger.kernel.org>; Tue, 01 Aug 2023 06:57:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cloudflare.com; s=google; t=1690898238; x=1691503038; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=V63lX8jJADmT+x3ehocFhAwNy3zEROKPKQmkKeMAkns=; b=XisN9mTlhuU084244jOxq6rmViLU82rCKFQtm0CjqcgougXjSCdQGow1jYSz+tRjh8 lxKt+UFf9ri4gIjw4gO7pdos4kpYqyVdP8WGa7uZobSlzhZpe8z0+qtU+O/07MtbRbD1 MvcryH0sBl7lUx4XFlKiVasvyU+Y3XSotWELQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690898238; x=1691503038; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=V63lX8jJADmT+x3ehocFhAwNy3zEROKPKQmkKeMAkns=; b=a3xjL1OwLzzxTQGwv+9kwTCKXZeHuIX0fkBgVI4Iwej4HvwF7k62LnGPZXXJ3L2lZx Og/6XCyKd6kvyaTqVQt5QicvTpvrppWzywX5FrOVW+4oCyFSG9Xua+i504MbKsAdxCl8 +7EtFeGZ4H2wY4UhO+EGHaJRxbTmnZrDFNg878fpF4hAVJy1nGrNNCSVcpVKSKjP6B5J qslO+77aXjBKx1AJXA4wq6nG6xsWoB04WrWvntAyto3JdrDExXXZqzpu9fEsCfbjLvCt vPNfIBPGyp+PA+rS7fqglLqU2rGDydTIHaJPUHSd493YUgas0JaUaix88FeI417eTZ/2 WkGg== X-Gm-Message-State: ABy/qLbPLBwKiQBaS94QoRXkDDj/5Ej9/WMl7NmzJN4tc3fdZDu/FIN5 iow5X70vWVQD0HvYvOohccyBgA== X-Received: by 2002:a92:c9c3:0:b0:348:f28d:d06 with SMTP id k3-20020a92c9c3000000b00348f28d0d06mr5261388ilq.31.1690898237863; Tue, 01 Aug 2023 06:57:17 -0700 (PDT) Received: from CMGLRV3.. ([2a09:bac5:9478:4e6::7d:54]) by smtp.gmail.com with ESMTPSA id x1-20020a92de01000000b00342f537e3c3sm3834793ilm.2.2023.08.01.06.57.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Aug 2023 06:57:17 -0700 (PDT) From: Frederick Lawler <fred@cloudflare.com> To: herbert@gondor.apana.org.au, davem@davemloft.net Cc: linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-team@cloudflare.com, Frederick Lawler <fred@cloudflare.com>, stable@vger.kernel.org Subject: [PATCH] crypto: af_alg - Decrement struct key.usage in alg_set_by_key_serial() Date: Tue, 1 Aug 2023 08:57:09 -0500 Message-Id: <20230801135709.2218855-1-fred@cloudflare.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1773048821297393049 X-GMAIL-MSGID: 1773048821297393049 |
Series |
crypto: af_alg - Decrement struct key.usage in alg_set_by_key_serial()
|
|
Commit Message
Frederick Lawler
Aug. 1, 2023, 1:57 p.m. UTC
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>
---
This is rebased ontop of Linus's 6.5-rc1. Original patch was introduced in 6.2.
---
crypto/af_alg.c | 3 +++
1 file changed, 3 insertions(+)
Comments
On Tue, Aug 01, 2023 at 08:57:09AM -0500, Frederick Lawler wrote: > 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> > --- > This is rebased ontop of Linus's 6.5-rc1. Original patch was introduced in 6.2. > --- > crypto/af_alg.c | 3 +++ > 1 file changed, 3 insertions(+) Patch applied. Thanks.
diff --git a/crypto/af_alg.c b/crypto/af_alg.c index 6218c773d71c..295ede1996a4 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);