Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp6560045pxv; Thu, 29 Jul 2021 18:29:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz61ZaOQOjuM7CcEtSu977VcwB6eKauHnL7F6YCHN30SzC3FH84ln+02YgbaDmsnYqcbdEb X-Received: by 2002:a92:874f:: with SMTP id d15mr32176ilm.294.1627608593380; Thu, 29 Jul 2021 18:29:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627608593; cv=none; d=google.com; s=arc-20160816; b=DWiKqqObQ6VeTH6OZo2owF8lQmgdy2NGfc34U69bhLwLxSsARiXAr0YWDsq38Du/AN V/c7jeNTCRpOLxvAwHeiCWewBdxqnnYIdOzM6rMBX2eOMVJABnJ+ggTvrpdSwgSEVzhv hYqFuQN6JFARJ36BYXdgFcyiIKfYfcw25BMaieEf63a3oVMC4o4WCYeES1RnyEAbVvzy VqkYsa5Kpp8DtN8IWQ76fKp4guvQ7ZxkFQ9MeYE9cPBUJk+St0AoOFX0qja+CGpGOrN6 d5zCl60475BPvBvgXAaWBe+JZJT2J6Z+EbyXum4bp6a8HtOXOiG6pY9p7CdvxIQTsbHo UVCA== 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=C6s2TSTlPwvNTpp6+kKrGqk3jPYCGOkNqfSKjIV/XnM=; b=WfDETdf0iAq5uryfNSUIbm5vgCRb91GjxmxAMqV/0f1hE3lnhb6FF9eLV7heTQKwwv CXxQU8AvMY1gO4fykdN6c5KAqztE9T6DMOeXk2u59l5K7U7iPzEfUR3LU+x8qW6Gn3DC 99iusMd7XyLg1D1anzDEK+JsCzMQKuuvkHeWatSuKF9VUu8uGyaZ0AStCiCliNtf6Ksv wsW2VqBQCUqk46nPA5rYAi3XL4EiCXYGCwfLisxX7HVfFdG3yFOFFubfW8VIeF5nXI2c j1KjMYUiIAmKBzX1h5ZtWS9hyui5jSIBOeATqs3dmN3XpV09mjIwEeGw3ENQeLX+rRTe taMw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@rammhold-de.20150623.gappssmtp.com header.s=20150623 header.b=uNoDr8Wp; 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 l15si6176917jad.101.2021.07.29.18.29.40; Thu, 29 Jul 2021 18:29:53 -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.20150623.gappssmtp.com header.s=20150623 header.b=uNoDr8Wp; 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 S234305AbhG3B27 (ORCPT + 99 others); Thu, 29 Jul 2021 21:28:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49752 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229667AbhG3B27 (ORCPT ); Thu, 29 Jul 2021 21:28:59 -0400 Received: from mail-wr1-x42e.google.com (mail-wr1-x42e.google.com [IPv6:2a00:1450:4864:20::42e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 28E17C061765 for ; Thu, 29 Jul 2021 18:28:55 -0700 (PDT) Received: by mail-wr1-x42e.google.com with SMTP id b7so9098797wri.8 for ; Thu, 29 Jul 2021 18:28:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rammhold-de.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=C6s2TSTlPwvNTpp6+kKrGqk3jPYCGOkNqfSKjIV/XnM=; b=uNoDr8WpoTnjj/sNmkYAFxLSlsiyomOrmpVbWgsoacpx/vxImmMdnAXf6BE8qaplr7 W5Es1ChuRLsxy1l0Dc3Me/TELxfQYDsw5NiMmuCadFZe/pE5DpYc9S7TkhKSHqv9j1Fd Tec5G1zIl/doDQYKJJSkBPemoBOgm2cOyQfe9KBJc2vNcNAJFi/XKsM5+6UOWa7DBS9w tWXWPxpD7IOgqp0yRi/4ant5qGeMOkW+sRzlTHqrW3HpLjiX9EQmHbbiDn+RLDFj/BKI GVlpM7iZE276IEqs8t7nX0NiFLkjyLTGWlT1UGV2G1HyfqO28DBS2atO3Gadwuzf96vT nAEA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=C6s2TSTlPwvNTpp6+kKrGqk3jPYCGOkNqfSKjIV/XnM=; b=NOXmm0EGy9pyZikeqfWhhpw0yUzcsMcIVIG4xlw+8svjL2g9TGWZxf8Edc+kHgKISR T9lI/OCLYofGTsd5fLZ1eAzDoX5IXXglbvRYmed/1Jf4ov04uaO0wL2xVkPwlQBZnePr VIvHZ+J3TWK6UbQ9hqoNjDx+YKnpAlpSZAnTCF1oGMPnK5BGreolLEOHjsIaTuTNi7zK sOc6ZKd8SmqVYWJsA48mwYMzBuhOY+GkAEjnBz5D9UV3ntHGzBYCjK54vUcxdhX4iT8f XjHNxh0+tHDlNgIA4MheSE8hwLxmhrrB1RzYkCaDYHiGgRqqDQv7f8Be591dC/OStNBz QItw== X-Gm-Message-State: AOAM532YAnhXsshITyz14+fMB2IiGk6+2DnXFCgwf8wqYE3mv1MXZ6Y+ eJ5iKdxMaRdwqkbwbD7DOEidbw== X-Received: by 2002:a5d:5685:: with SMTP id f5mr221899wrv.369.1627608533781; Thu, 29 Jul 2021 18:28:53 -0700 (PDT) Received: from localhost ([2a00:e67:5c9:a:6941:c1d7:e420:cc22]) by smtp.gmail.com with ESMTPSA id m14sm5019325wrs.56.2021.07.29.18.28.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Jul 2021 18:28:53 -0700 (PDT) From: Andreas Rammhold 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 v3] KEYS: trusted: Fix trusted key backends when building as module Date: Fri, 30 Jul 2021 03:28:22 +0200 Message-Id: <20210730012822.3460913-1-andreas@rammhold.de> X-Mailer: git-send-email 2.32.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 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 Reviewed-by: Jarkko Sakkinen --- 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 d5c891d8d353..5b35f1b87644 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.32.0