From patchwork Mon Nov 1 18:41:14 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andreas Rammhold X-Patchwork-Id: 12596987 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id AA3B4C433EF for ; Mon, 1 Nov 2021 18:41:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 97FED60FC4 for ; Mon, 1 Nov 2021 18:41:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232257AbhKASn7 (ORCPT ); Mon, 1 Nov 2021 14:43:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57030 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232199AbhKASn5 (ORCPT ); Mon, 1 Nov 2021 14:43:57 -0400 Received: from mail-ed1-x534.google.com (mail-ed1-x534.google.com [IPv6:2a00:1450:4864:20::534]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 39D87C0613F5 for ; Mon, 1 Nov 2021 11:41:23 -0700 (PDT) Received: by mail-ed1-x534.google.com with SMTP id m14so14480066edd.0 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=ZKA89mEhq7jQDbN4JIhS5ZoUUq9JHLrjXZCgGE6YYFg6eaJtbBXYF2Uy3oDJPYLYk/ DE0lBcPOMHQcS9Ex9mWhUXC1NdO0GJIqdj8AVrGKNMERiT2KMLsDaIwAUezs+afX3M5G TP4j6coO8dkYFxP2mk4tPLidYooF0LLPn2E8z3aN+pOcd2RUnEPpOIbKpJiuxlbmRKtK ZpNnviVf3FZCA1Lt8ZG+Dqe7jrX2A1Wz2kr5Sq9lbCpvAYKqqYzaylhLnBn8mkUwITma zOURoPsSUFdtzWM5GNa+ORGKFHdegwzYbAafrzjNqAut708+snilZTP1Lzg9mnG+RGgt jnkg== X-Gm-Message-State: AOAM532/Pv6NP/MoRhoCILxHAq9MAxTWyiCRhcPlTOBtDXHk0ysnMZhA QiMGl9ZS2oQn2HE/AN7VSCyAlw== X-Google-Smtp-Source: ABdhPJw1o58zrRvllzKw3O/CP70fCWa3OK8W/Nc/1ktVmi36JGPjLsBMcoTFRiSdotgSABpmTqs4Uw== 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 Precedence: bulk List-ID: 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 Tested-by: Ahmad Fatoum --- 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 };