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 13808C433F5 for ; Wed, 18 May 2022 06:32:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231500AbiERGcd (ORCPT ); Wed, 18 May 2022 02:32:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33458 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231466AbiERGcX (ORCPT ); Wed, 18 May 2022 02:32:23 -0400 Received: from cvk-fw1.cvk.de (cvk-fw1.cvk.de [194.39.189.11]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 77C486C544; Tue, 17 May 2022 23:32:20 -0700 (PDT) Received: from localhost (cvk-fw1 [127.0.0.1]) by cvk-fw1.cvk.de (Postfix) with ESMTP id 4L337Q3Y88z4w3c; Wed, 18 May 2022 08:32:18 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=cvk.de; h=date :date:message-id:subject:subject:from:from; s=mailcvk20190509; t=1652855538; x=1654669939; bh=Utam1949PRlwRKGxLcllKJ7LrsVNbIWe hFQQTs1q+cw=; b=jMmAXKasRGBs/HHHcj/yDwnUqrCecV3ASiKTQ9PoCvW44Unv jtpgU8pdzksHg7/K0Tv89+/T0kM2fWG0AImUmgEl5e0KBpF8atXyWhZ7JEDKwNI1 iegTqMNJHaEc09nXOJ5auWLcmwNCElEDFsSMzd72akvLjMDRNeI8nW5ngc+TT5ZX w6pntzglMKhX1ZYx7/qI4zdjlLMM2Y6GZYrH5yVal7obho37HYieQpi73G+cz//j r1ujxKELpMb/hVqPMJzwJPkU7DE7jf48IKuRYcA2GzstG60XiNvYLChHH26aAQgS FaWWYboibI8NzpqRzf9Txf9QoI6jhmGTNUreNA== X-Virus-Scanned: by amavisd-new at cvk.de Received: from cvk-fw1.cvk.de ([127.0.0.1]) by localhost (cvk-fw1.cvk.de [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id QIwtZT_K6MI9; Wed, 18 May 2022 08:32:18 +0200 (CEST) Received: from cvk027.cvk.de (cvk027.cvk.de [10.11.25.27]) by cvk-fw1.cvk.de (Postfix) with ESMTP; Wed, 18 May 2022 08:32:18 +0200 (CEST) Received: by cvk027.cvk.de (Postfix, from userid 0) id 5336B160CF38F; Wed, 18 May 2022 08:32:18 +0200 (CEST) From: Thomas Bartschies To: davem@davemloft.net Cc: steffen.klassert@secunet.com, herbert@gondor.apana.org.au, kuba@kernel.org, pabeni@redhat.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [Patch] net: af_key: check encryption module availability consistency Message-Id: <20220518063218.5336B160CF38F@cvk027.cvk.de> Date: Wed, 18 May 2022 08:32:18 +0200 (CEST) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 diff -uprN a/net/key/af_key.c b/net/key/af_key.c --- a/net/key/af_key.c 2022-05-09 09:16:33.000000000 +0200 +++ b/net/key/af_key.c 2022-05-13 13:51:58.286250337 +0200 @@ -2898,7 +2898,7 @@ static int count_ah_combs(const struct x 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); @@ -2916,7 +2916,7 @@ static int count_esp_combs(const struct if (!ealg->pfkey_supported) continue; - if (!(ealg_tmpl_set(t, ealg))) + if (!(ealg_tmpl_set(t, ealg) && ealg->available)) continue; for (k = 1; ; k++) { @@ -2927,7 +2927,7 @@ static int count_esp_combs(const struct if (!aalg->pfkey_supported) continue; - if (aalg_tmpl_set(t, aalg)) + if (aalg_tmpl_set(t, aalg) && aalg->available) sz += sizeof(struct sadb_comb); } }