Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp8568981ioo; Sat, 4 Jun 2022 11:55:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw53o9sESK6iYV1AcJu7DnCCv3MEunHYVDpJgSUR78nvZ8GtzXQEJ0OL3j0fgBA0Z276ifU X-Received: by 2002:a63:69c5:0:b0:3fb:a606:819a with SMTP id e188-20020a6369c5000000b003fba606819amr13901705pgc.81.1654368925418; Sat, 04 Jun 2022 11:55:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654368925; cv=none; d=google.com; s=arc-20160816; b=aRZWh5oPQDsGBL1EGfX1VMo6ynaS/oo1aLu1hQmiu2J0meISZiXip5Z8Ax0HRXBN/r YHtM3Rgc6A0h7TeqcXlymaIlhKdmYIa1KGx38ToSeGoA71W9wLlu/TMrvatLKNnjUSK8 Y9o7FjOApCnlepjWLSt3tacKKsNly0krbSNj4/zctBvAHPek1UjuaZ0fPlsaL3jwSMCX yw6HDo/MXHgXrBAOlSKLbJkLTA3WuML0quaY3mkiavNkQCG/e3+ix6c4QTq2mupLTKy/ DpDkbkv6+X0Qb+ldJdeurly8swQCl+0ad3wlqDm1q9a5bMDBTel5iMyENQSmpyplF4N0 znTw== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=KH/v67o0loL9JKGQavibtJBS9wWrqeRilo4nK8lfJNo=; b=hMieAiqm8iOvT1cEfjPYzKvTL9kyfoPH+ih36nVvzb5wNFc5/ah1m/dgXdP4+GOYU+ EYlFxToDbJQMHDwip6YReW/ftH9m2QDcWwXt09Tf1+z7pTFMg0phl09P9L9fpJbTRKLq 2YSg+TLbtk6pcCz2/w8qTRQWSR+AtwmoMfUnGo2g7/z+tdNqCL8cyLP0NlSvBjQ8EBOU Da7EEN+UnxB9coabK7ujcuw8g6maZZDZNmHVjDioZ9Vg5MUo6Tc0hhWcn3Rz3x4ankfY LSlctXjd9ujdXf08ZNAI0s6CAKLVhA9Rj1Y0MH8n8AXVOWb7DKpZooeIrdsfXSwG5SFg EsWQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=tXDsy+tW; 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=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j9-20020a170903028900b001619fbc05desi13834369plr.598.2022.06.04.11.55.13; Sat, 04 Jun 2022 11:55:25 -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=@linuxfoundation.org header.s=korg header.b=tXDsy+tW; 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=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345081AbiFCRpf (ORCPT + 99 others); Fri, 3 Jun 2022 13:45:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56112 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344791AbiFCRoj (ORCPT ); Fri, 3 Jun 2022 13:44:39 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1213D5534B; Fri, 3 Jun 2022 10:42:38 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 6977B61B38; Fri, 3 Jun 2022 17:42:38 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 70291C385A9; Fri, 3 Jun 2022 17:42:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1654278157; bh=F/0peBmLuxmM9kFRIm+u7NDg01nwTZbsksRv6qgOMnw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tXDsy+tWYKI+7giSoGGaTWWG+InJqzu+zTd3Wqc4Zk/yFvvP91om3h1dJB89U4ql7 fb8sTeCNK6sRnw9cewQimfKosPKozkKtqkU/Lm6IWvXmrJsIkgTb4up9ohZy8bGEPr DE8/FzzW1Pad3/gInw5ZjIA4ENmJERWnAq1rgYDA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Thomas Bartschies , Steffen Klassert , Sasha Levin Subject: [PATCH 4.19 07/30] net: af_key: check encryption module availability consistency Date: Fri, 3 Jun 2022 19:39:35 +0200 Message-Id: <20220603173815.309144798@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220603173815.088143764@linuxfoundation.org> References: <20220603173815.088143764@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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: X-Mailing-List: linux-kernel@vger.kernel.org From: Thomas Bartschies [ Upstream commit 015c44d7bff3f44d569716117becd570c179ca32 ] Since the recent introduction supporting the SM3 and SM4 hash algos for IPsec, the kernel produces invalid pfkey acquire messages, when these encryption modules are disabled. This happens because the availability of the algos wasn't checked in all necessary functions. This patch adds these checks. Signed-off-by: Thomas Bartschies Signed-off-by: Steffen Klassert Signed-off-by: Sasha Levin --- net/key/af_key.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/net/key/af_key.c b/net/key/af_key.c index 170960ef7e36..1bbb6ec89ff3 100644 --- a/net/key/af_key.c +++ b/net/key/af_key.c @@ -2910,7 +2910,7 @@ static int count_ah_combs(const struct xfrm_tmpl *t) break; if (!aalg->pfkey_supported) continue; - if (aalg_tmpl_set(t, aalg)) + if (aalg_tmpl_set(t, aalg) && aalg->available) sz += sizeof(struct sadb_comb); } return sz + sizeof(struct sadb_prop); @@ -2928,7 +2928,7 @@ static int count_esp_combs(const struct xfrm_tmpl *t) if (!ealg->pfkey_supported) continue; - if (!(ealg_tmpl_set(t, ealg))) + if (!(ealg_tmpl_set(t, ealg) && ealg->available)) continue; for (k = 1; ; k++) { @@ -2939,7 +2939,7 @@ static int count_esp_combs(const struct xfrm_tmpl *t) if (!aalg->pfkey_supported) continue; - if (aalg_tmpl_set(t, aalg)) + if (aalg_tmpl_set(t, aalg) && aalg->available) sz += sizeof(struct sadb_comb); } } -- 2.35.1