Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp983476pxk; Fri, 18 Sep 2020 00:05:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwuHkgYDhx5Cz8d0z+neVnUPSRPp4Ash4HJDN+CZoNBmc3KWDrJAf0+FsRnY/bV6M1j1iEq X-Received: by 2002:a50:fb99:: with SMTP id e25mr36788517edq.281.1600412726169; Fri, 18 Sep 2020 00:05:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600412726; cv=none; d=google.com; s=arc-20160816; b=Dg+meWir4eWnVRumZryOS2FsZvJRl68Zo5kwFNUEeDzTcHcQr/j0EL1lh6y4xnp6a2 cngZ0cpKKdiA0Mpw3Wwifu+c02aoEt8SrK019OrlW7Mut9ZaJUttvusHfWkiT1yNs0++ W/XBnFwYC6hG5t+Rtcc+ZtmKLYzd9pcckGkkhwONZICjwQ1tO7r+7Pu+w5XN0gvXj0YO ScnJg2zjz9HLj+mQp3EeiWsyPn8yVAA2WzH9mmkgAmkxtP6gMnRVrVCmD/CXj0nY3mYU R5xwSBKSMwQnMXhaZW/93+a6Z8CM/01rDtOmP7e5bbTrwrdKg50/hpOezBgTVlg01CpH UOWw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=NmmjmHcBY8BbhioV7WK8K+GOMybyd/oBkZZKD/aKF+E=; b=wrOjyb7+CQCY5RPoJu1/gQTESl0dPQPDRm2DrNlR+8x2K9nmkDe7h9w7lFeUWcxDPH +2hKRcX2ymjIAJF4G1xVGx8A2QBQp0a2hRMoRT+4FEg93vvzXKLGbLwF4sIyAUPkX+Q7 U0qS8E/1LOZc0hJXyhy0uZLBmmHJ5voqWp51HUPtxIcT8CMrhh3ariUb7zFh34Tm9uOw xpyxzxi4Pv1gy2HJKyCnXq1xnQT41HCuJH4c0oKoheQOeI3ayGpkT+91KoVD3QbkIH49 BbJi1+OCVa4PbVtIIHcZPp8cIUPHTURPmA8YcYpcQyEK9bKKjI8pKYKa6SJNz1svYzbk mLGw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=aYMkTBVE; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id pk27si1567522ejb.715.2020.09.18.00.05.02; Fri, 18 Sep 2020 00:05:26 -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=@linaro.org header.s=google header.b=aYMkTBVE; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726572AbgIRHDb (ORCPT + 99 others); Fri, 18 Sep 2020 03:03:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43190 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726551AbgIRHDa (ORCPT ); Fri, 18 Sep 2020 03:03:30 -0400 Received: from mail-lf1-x141.google.com (mail-lf1-x141.google.com [IPv6:2a00:1450:4864:20::141]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 545A1C06178B for ; Fri, 18 Sep 2020 00:03:30 -0700 (PDT) Received: by mail-lf1-x141.google.com with SMTP id u8so4995173lff.1 for ; Fri, 18 Sep 2020 00:03:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=NmmjmHcBY8BbhioV7WK8K+GOMybyd/oBkZZKD/aKF+E=; b=aYMkTBVEhpmeibkJNMW8F0pM9TM7QFOuWu/3srU31dDTGy8DT7vhwP20g1CaVTkKED tln3quJTl/JUFcaUYDO+GW1fOyC7OZcRlLfOjlVvUTecHce9SzjaOVjHH1Pqyll8JB4K GqE11kfv6p9VAaMUrG+NvXu5AnHWPGGxmemtz02FxTVDSwd33MMwzBDPoL9q+VRvzXk+ isfXxEhOGHr08L0zlwQO0PZI+6DtNPGih9FniPrTlrkE3HHi3NudmVg7zO+gZMdIjknU /+Ovorz6Sc/96FRDNZIJAVDrUI0mfOkt3rPTpKfRJ8iuKXg0vYQRu9k7jw//2ksgPGnd Hekg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=NmmjmHcBY8BbhioV7WK8K+GOMybyd/oBkZZKD/aKF+E=; b=q24l4sOJFUhsTT8GyROV4HUh4E6QW5sycw0dgmQKDBed5XxBKZQ68hyBoTzmoqr8dF 6dVVHmCF9EWpRon6ljqtFrpFatZYzdE1z3j72ILkVUWVxZuNsjS0xHlckNEF36MGhXtP 2rN4j7B8bnf0eFH4kR496c8tJ/VsqppQyWt1aBZU0CXpgdJZx5ElAWTyAQbvhur5IugZ towdwTEMFhmEQUQRC+1CQKMDQEc8zl+vkiPDK8Zp7Gcg/rXCW107JXhG3DpNCF9NuBkU j5CvCimY1OzIIaf33HCc6oGerdi1LA8nmApuir4BqcfcPEy3wHbcTzg2chDxihsfuQRE JHHA== X-Gm-Message-State: AOAM532akUo25H2nBX2U7zPmwif8k0rAxCFqMXGp0OM5VyJDwTzbF1kw 9tivSk0PMk0QXaXxk7LkEQUzhVtjNGTBmRqt5hmbMQ== X-Received: by 2002:a05:6512:2e5:: with SMTP id m5mr9808120lfq.598.1600412608442; Fri, 18 Sep 2020 00:03:28 -0700 (PDT) MIME-Version: 1.0 References: <1600350398-4813-1-git-send-email-sumit.garg@linaro.org> <1600350398-4813-2-git-send-email-sumit.garg@linaro.org> <20200917162142.GB9750@linux.intel.com> <20200917162506.GC9750@linux.intel.com> In-Reply-To: <20200917162506.GC9750@linux.intel.com> From: Sumit Garg Date: Fri, 18 Sep 2020 12:33:17 +0530 Message-ID: Subject: Re: [PATCH v6 1/4] KEYS: trusted: Add generic trusted keys framework To: Jarkko Sakkinen Cc: Mimi Zohar , James Bottomley , David Howells , Jens Wiklander , Jonathan Corbet , James Morris , "Serge E. Hallyn" , Casey Schaufler , Janne Karhunen , Daniel Thompson , Markus Wamser , Luke Hinds , "open list:ASYMMETRIC KEYS" , linux-integrity@vger.kernel.org, linux-security-module@vger.kernel.org, Linux Doc Mailing List , Linux Kernel Mailing List , linux-arm-kernel , op-tee@lists.trustedfirmware.org Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 17 Sep 2020 at 21:55, Jarkko Sakkinen wrote: > > On Thu, Sep 17, 2020 at 07:21:49PM +0300, Jarkko Sakkinen wrote: > > On Thu, Sep 17, 2020 at 07:16:35PM +0530, Sumit Garg wrote: > > > Current trusted keys framework is tightly coupled to use TPM device as > > > an underlying implementation which makes it difficult for implementations > > > like Trusted Execution Environment (TEE) etc. to provide trusted keys > > > support in case platform doesn't posses a TPM device. > > > > > > So this patch tries to add generic trusted keys framework where underlying > > > implementations like TPM, TEE etc. could be easily plugged-in. > > > > I would rephrase this a bit: > > > > "Add a generic trusted keys framework where underlying implementations > > can be easily plugged in. Create struct trusted_key_ops to achieve this, > > which contains necessary functions of a backend." > > Okay, will use it instead. > > I remember asking about this approach that what if there was just a > > header for trusted key functions and a compile time decision, which C > > file to include instead of ops struct. I don't remember if these was a > > conclusion on this or not. This approach was implemented as part of v5 and we concluded here [1] to revert back to the dynamic approach as distro vendors won't like to make opinionated selection at compile time which could rather be achieved dynamically based on platform capability. [1] https://www.spinics.net/lists/keyrings/msg08161.html > > > > E.g. lets say you have a device with TEE and TPM, should you be able > > to be use both at run-time? I might play along how this works now but > > somehow, in the commit message preferably, it should be conclude why > > one alternative is chosen over another. > Okay, so how about adding a kernel module parameter which can enforce the user's preference about which trust source to use at runtime? And we should only check availability for that trust source if preference is provided otherwise by default we can traverse the trust sources list. See following change, if this approach looks sane, I can include it in next version: diff --git a/include/keys/trusted-type.h b/include/keys/trusted-type.h index edd635a..a566451 100644 --- a/include/keys/trusted-type.h +++ b/include/keys/trusted-type.h @@ -63,6 +63,11 @@ struct trusted_key_ops { void (*exit)(void); }; +struct trusted_key_source { + char *name; + struct trusted_key_ops *ops; +}; + extern struct key_type key_type_trusted; #define TRUSTED_DEBUG 0 diff --git a/security/keys/trusted-keys/trusted_core.c b/security/keys/trusted-keys/trusted_core.c index 83a6a15..74a3d80 100644 --- a/security/keys/trusted-keys/trusted_core.c +++ b/security/keys/trusted-keys/trusted_core.c @@ -21,12 +21,16 @@ #include #include -static struct trusted_key_ops *available_trusted_key_ops[] = { +static char *trusted_key_source; +module_param_named(source, trusted_key_source, charp, 0); +MODULE_PARM_DESC(source, "Select trusted keys source (tpm or tee)"); + +static struct trusted_key_source trusted_key_sources[] = { #if defined(CONFIG_TCG_TPM) - &tpm_trusted_key_ops, + { "tpm", &tpm_trusted_key_ops }, #endif #if defined(CONFIG_TEE) - &tee_trusted_key_ops, + { "tee", &tee_trusted_key_ops }, #endif }; static struct trusted_key_ops *trusted_key_ops; @@ -296,8 +300,13 @@ static int __init init_trusted(void) { int i, ret = 0; - for (i = 0; i < sizeof(available_trusted_key_ops); i++) { - trusted_key_ops = available_trusted_key_ops[i]; + for (i = 0; i < ARRAY_SIZE(trusted_key_sources); i++) { + if (trusted_key_source && + strncmp(trusted_key_source, trusted_key_sources[i].name, + strlen(trusted_key_sources[i].name))) + continue; + + trusted_key_ops = trusted_key_sources[i].ops; ret = trusted_key_ops->init(); if (!ret) > We must somehow seal this discussion because the other changes are > based on this decision. > > I don't think tail of this patch set takes a long time spin. This > is the main architectural decision. Agree. -Sumit > > /Jarkko