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 32223C433EF for ; Mon, 16 May 2022 12:57:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242341AbiEPM5o (ORCPT ); Mon, 16 May 2022 08:57:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52790 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236295AbiEPM5f (ORCPT ); Mon, 16 May 2022 08:57:35 -0400 Received: from cvk-fw1.cvk.de (cvk-fw1.cvk.de [194.39.189.11]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 08D47393E0; Mon, 16 May 2022 05:57:32 -0700 (PDT) Received: from localhost (cvk-fw1 [127.0.0.1]) by cvk-fw1.cvk.de (Postfix) with ESMTP id 4L1zmp2D78z4wCd; Mon, 16 May 2022 14:57:30 +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=1652705850; x=1654520251; bh=Utam1949PRlwRKGxLcllKJ7LrsVNbIWe hFQQTs1q+cw=; b=paQJWPWFMcO2U2DHv9w4nWP+VYpxbv5RHTW50GuzrcxmsxT7 v7dcFqTfrRMuSd8yQOEhepHz0nJ/y2nI4/ahfgikllyNkfvp/Xnj+PyhjC/F4p8v QBN3+OMcbLrNvwOElQ5kcevJHEXh09GuhWxnPKCBZaffqiPPODbI+DfEYBgifIpy uknpk2xgl1we5F45CyDJ03s+BtNZoqACzpth36BqDvUnA6I538A4DoMyjxEyROqA UPa27D86M0L6O6/88rg8oO89DuukRz//zjUf7S/n0qCW5Ojh1r4PynoDcHVeWPnw 3Nrzu92LJkuAKyP+90GfSqdtOtx1e1Jy9g8XSw== 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 jEhoRymj2iNT; Mon, 16 May 2022 14:57:30 +0200 (CEST) Received: from cvk027.cvk.de (cvk027.cvk.de [10.11.25.27]) by cvk-fw1.cvk.de (Postfix) with ESMTP; Mon, 16 May 2022 14:57:30 +0200 (CEST) Received: by cvk027.cvk.de (Postfix, from userid 0) id 4446D160219F3; Mon, 16 May 2022 14:57:30 +0200 (CEST) From: Thomas Bartschies Cc: Thomas Bartschies Subject: [Patch] net: af_key: check encryption module availability consistency Message-Id: <20220516125730.4446D160219F3@cvk027.cvk.de> Date: Mon, 16 May 2022 14:57:30 +0200 (CEST) To: unlisted-recipients:; (no To-header on input) 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); } }