Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp3326753pxb; Mon, 1 Nov 2021 11:48:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwqs1CHrGc/atHM8Sp23WbDbnpagmxN5wyhnDnqXZnHor9PuHOUd4ilwn9IgXofK83sfVAQ X-Received: by 2002:a17:906:4fd6:: with SMTP id i22mr37819205ejw.92.1635792513145; Mon, 01 Nov 2021 11:48:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635792513; cv=none; d=google.com; s=arc-20160816; b=Xlv/SYO4lFAkPil5mb70cv60HwLoTyi59k/Ueqjugy7Y8f9QHNDPNtOgEtlicEP/7g GJXdEpB77CDzu5NwMs27PUbWke0iAeM2+YFRlfXDL2JIt3aBCxAIWVPWZoqIgIG8aNWv hjiK49mrzqxrVDc+PZv0wTQR/fPTqVE2nUFaEpdRR86Bki4Gvp8g/ZmMNdEImVRmqnCd ROL8ZO4oL95QKPMtKkY2JJPg6eIqzUCCj9idYL1nF9SpUDApM9vjvSJlCsydkkzuMCfJ kkC2ltrdxBqOHjUwAx4CYWDpEXTpNb7T7ZduKRQQ5Ulew6B5IJHItbS2IcbJHq/q/MTL krxA== 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=tK7r+aOUpXiWnfiwAPiSOz1gaCFp1ie4wKIj38RnVS0=; b=C40Vv5Q5nNPS60EbciKc+50JRP3pRMogID8qLmOpJVIs+pMjzKm3nWHALhscVvgQrM gysUSVQeLfwkDfjIRMi/Kai0Z6RdoKEp7hjGGAxj4Wm1k/pO8DqnYBQhudVqhiAAYbpd XZwdzYzoHcX19+JK7XrYiyuiPXJra6uVmopYM6HbufwRreiot7L+WvzTNXM7XT6qqgf/ ipDd2TukUh2z62bbDiJifm4s8YGHWFSoQDk5WSpwJIUvy7GLUZPiZAJowWaDy5yVAgJO dui+TDIJ/LH+yya1gUuYK0hNMnL+YNdoZjrnLdabjxttlDUWEawNfN9lrkhGpFXQoMCM NgZg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@rammhold-de.20210112.gappssmtp.com header.s=20210112 header.b=ruKobEoK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id sc20si20696946ejc.61.2021.11.01.11.47.59; Mon, 01 Nov 2021 11:48:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@rammhold-de.20210112.gappssmtp.com header.s=20210112 header.b=ruKobEoK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232124AbhKASn7 (ORCPT + 99 others); Mon, 1 Nov 2021 14:43:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57024 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232193AbhKASn5 (ORCPT ); Mon, 1 Nov 2021 14:43:57 -0400 Received: from mail-ed1-x531.google.com (mail-ed1-x531.google.com [IPv6:2a00:1450:4864:20::531]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1B2B6C061764 for ; Mon, 1 Nov 2021 11:41:23 -0700 (PDT) Received: by mail-ed1-x531.google.com with SMTP id z20so67775747edc.13 for ; Mon, 01 Nov 2021 11:41:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rammhold-de.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=tK7r+aOUpXiWnfiwAPiSOz1gaCFp1ie4wKIj38RnVS0=; b=ruKobEoKgA+9XBxDsgVW1CRTiVWK+aw/bHsUEJ0s52ltCFSRjtIqfAPoS7wGOBxQr2 IUtSLE+xTgVPnOcNQkt/Afjf+zw9SsXwnk0HQqgnjm+lFqMc2HAzqV4NMVVzFqSZ0CG3 BXtPJOl0LNHCsG2zYyU5mJqnLTUMjqf55mVBcm/8RzBGawMMHjV84a3LjCF8wbToFYig ZixbsMAyzF0XGTu1dzGfWfKJspHNy1e1BgfOs9lXaabZhexAGWali4LkDy45fbhRKFps oNvk+j1lQ6ZeZ3UD0vV9og0yfN+WHzuPp2gvKKIw52fhwJ9+3gF9OC4EyOnO6v1+q6cG iIvw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=tK7r+aOUpXiWnfiwAPiSOz1gaCFp1ie4wKIj38RnVS0=; b=UjW+NfTfPHmzQ1khYjHcZciaukuMHep76I/EaixeIMeX34mx/kDprywVOZIlGiluqX wOAeuREAyHy5RiG21I9uDg4Og3Ev7vvW6PsquaXToVnq8RHT6r7thZhWPvgZO7EL7dbW NtIZUbc/4TSFGW7p2siWJ7b6M3EWssNok5ksnGmYzVdxT9vCU4/MgL8QrCUxZOuj432L 8xlA2yBqz2A3XcllBu7Hqmlm6HOgsJHgMT3zjejtcFUcjsMEu3RUvh9td8/QBzok8alW R0lasj0mne6cQHcYUS77cpflZZgrOmnILsPuA6xQd1yZR08oJkhfYLDZcuW5reiystEt n0pg== X-Gm-Message-State: AOAM530na2iBDa/5grvtFG9iHJ7bgGWxaM7XWMSquOdS0Pd/rzhY0a9j Ad/TaEXIRjop3ttKjuioGWY5Rz/ZXaFiNjcP X-Received: by 2002:a05:6402:1242:: with SMTP id l2mr24547785edw.50.1635792081696; Mon, 01 Nov 2021 11:41:21 -0700 (PDT) Received: from localhost ([2a00:e67:5c9:a:2e15:c474:2ef7:bc26]) by smtp.gmail.com with ESMTPSA id e13sm7175182eje.95.2021.11.01.11.41.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Nov 2021 11:41:20 -0700 (PDT) From: andreas@rammhold.de To: James Bottomley , Jarkko Sakkinen , Mimi Zohar , David Howells , James Morris , "Serge E. Hallyn" , Sumit Garg Cc: Ahmad Fatoum , Andreas Rammhold , linux-integrity@vger.kernel.org, keyrings@vger.kernel.org, linux-security-module@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH RESEND] KEYS: trusted: Fix trusted key backends when building as module Date: Mon, 1 Nov 2021 19:41:14 +0100 Message-Id: <20211101184115.1468041-1-andreas@rammhold.de> X-Mailer: git-send-email 2.33.0 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Andreas Rammhold Before this commit the kernel could end up with no trusted key sources even though both of the currently supported backends (TPM and TEE) were compiled as modules. This manifested in the trusted key type not being registered at all. When checking if a CONFIG_… preprocessor variable is defined we only test for the builtin (=y) case and not the module (=m) case. By using the IS_REACHABLE() macro we do test for both cases. Fixes: 5d0682be3189 ("KEYS: trusted: Add generic trusted keys framework") Signed-off-by: Andreas Rammhold --- This is a resend becuase of this unfortunate timeline: - 2021-05-09: Regression hits mainline with v5.13-rc1 - 2021-07-16: Issue reported. v1 of this patch sent out - 2021-07-21: Ahmad sends out alternative patch to fix issue - 2021-07-27: Jarkko (Maintainer) NACKs Ahmad's patch because of scope - 2021-07-29: v2 with fixes sent out - 2021-07-29: Jarkko gives his Reviewed-by and requests one more v3 - 2021-07-31: v3 sent out - 2021-09-13: Pinged, no feedback - 2021-09-27: Pinged, Mimi (Maintainer) comments due to to misunderstanding. Question about why this is not merged ignored - 2021-10-11: Pinged, no feedback v3: * Fixed patch formatting v2: * Fixed commit message * Switched from IS_DEFINED() to IS_REACHABLE() security/keys/trusted-keys/trusted_core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/security/keys/trusted-keys/trusted_core.c b/security/keys/trusted-keys/trusted_core.c index d5c891d8d3534..5b35f1b876441 100644 --- a/security/keys/trusted-keys/trusted_core.c +++ b/security/keys/trusted-keys/trusted_core.c @@ -27,10 +27,10 @@ module_param_named(source, trusted_key_source, charp, 0); MODULE_PARM_DESC(source, "Select trusted keys source (tpm or tee)"); static const struct trusted_key_source trusted_key_sources[] = { -#if defined(CONFIG_TCG_TPM) +#if IS_REACHABLE(CONFIG_TCG_TPM) { "tpm", &trusted_key_tpm_ops }, #endif -#if defined(CONFIG_TEE) +#if IS_REACHABLE(CONFIG_TEE) { "tee", &trusted_key_tee_ops }, #endif }; -- 2.33.0