From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 58B8AC433F5 for ; Tue, 24 May 2022 16:04:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239539AbiEXQE4 (ORCPT ); Tue, 24 May 2022 12:04:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47030 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239607AbiEXQEO (ORCPT ); Tue, 24 May 2022 12:04:14 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4843D77F1A; Tue, 24 May 2022 09:01:50 -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 ams.source.kernel.org (Postfix) with ESMTPS id ADC15B81A3A; Tue, 24 May 2022 16:01:48 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4213BC34115; Tue, 24 May 2022 16:01:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1653408107; bh=XlJudae/Rd1WLA5BHjtLGkYAM0ugWuB95uLJVf7nEp4=; h=From:To:Cc:Subject:Date:From; b=Q9XiEWuoGcQKLseZ2DaicMw5n0RQPGFB5Qa2IXQl5pib+cCvxrgwhSB5luQ2O4ySy ONKS0r8w4rlnY/TKI6PcUyejsUZM3A8FDbH4s6A25Z+zSXP2B5BNSi80IhdxylyX43 kP2UoZZjYe0QNSa6GIaUDBKnJrfxbALu3PCvCpVlsDR2GW/osuZrwgF1sjB2N4Z9N3 TqcvZ7JqhgGkIaprcxUAXkMVOgJgflWq5mIZYGVKlYr7rXg7g7kBI1RGhPzs2XlWJ0 ixiChC/InlShMw0wwbgFCzL3UaPJqqNeZ3VWztTo0pOX73o2RXINrV2ylT3ogR7OYU rV3fIuRPmvucQ== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Thomas Bartschies , Steffen Klassert , Sasha Levin , davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, netdev@vger.kernel.org Subject: [PATCH AUTOSEL 4.9 1/2] net: af_key: check encryption module availability consistency Date: Tue, 24 May 2022 12:01:43 -0400 Message-Id: <20220524160144.827435-1-sashal@kernel.org> X-Mailer: git-send-email 2.35.1 MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: stable@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 c9cc9f75b099..60136e8fc180 100644 --- a/net/key/af_key.c +++ b/net/key/af_key.c @@ -2933,7 +2933,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); @@ -2951,7 +2951,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++) { @@ -2962,7 +2962,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