Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp5731255pxu; Thu, 22 Oct 2020 09:37:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxkRoGBGYCp6VaYORv8I24M4rkxWxy+ZUaaox+B2AHToBemihrjKaoxZLy5sySW3k1RNQk1 X-Received: by 2002:a17:906:2649:: with SMTP id i9mr3279365ejc.449.1603384670776; Thu, 22 Oct 2020 09:37:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603384670; cv=none; d=google.com; s=arc-20160816; b=eYMGu2ueofJ1H+OW7urmY22sGMtFKlKAs2RgX8Azkx+QYfwxf+PrVw3wrJG2VsKgow p5oLxu86Cn+W8GjLsXhEZ2N+J16DydH9lmBj1P2gh84g5DA+RiJvhcATTWFO1lh2Cyf2 hj67Ob9O7Oom3dmxY2fJpHypQ8dTEhggBwvYwl+hRbQahnouYoRarjzErq98Cq3EHrF1 7RjNZtboK8lynCieSiEnMBJZpvCyRPSJox34ia0FzaaYeJ5bTiqxWufhnYpyX2jC5QQe N0F6udyl6N45T2d+S4mNWblAxMKeVcLA8u4ENOwRxPFHtf0iIip7gKCjMNQ7F5Q0RANo ZHuw== 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=5gzlInlR4QMg3ZQ/I04CuQTpDYmT0qaMY9vRAxu4Izc=; b=HIsGzxtyOuc/LdplNz4BuC21UBfoyujcOd4dD7zMbCI1b8HmcvPqqnHUMSkp2A2IqX w/79Sel9Z9gv5dSRXOhzV3EY79p8Yrg4ThToDkycAi6q0fE8wc7cZZPCn/+C2sm3z1pn eBAqbxdMdabzd1h+zDiyV9GYyzqzgfuUW9G3JL9XleaBBlicbCWBZwRO1df9jSxuBECA TBe+vU0BI38QDKLVk8BvGFINrzrJ0QcBqjw1N+OLlYTPNiJOue0YLfmA86YeplqfQLjv idqDFR760bf5MWBlynqlVjzxtbXfM8SVCbw9GpP9YwUcbnNogAyzLiWvmbPEOTN65zjW N28A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="mTKSsn/Q"; 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 l6si1284079eds.406.2020.10.22.09.37.27; Thu, 22 Oct 2020 09:37:50 -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="mTKSsn/Q"; 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 S2897435AbgJVLlA (ORCPT + 99 others); Thu, 22 Oct 2020 07:41:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35432 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2441517AbgJVLlA (ORCPT ); Thu, 22 Oct 2020 07:41:00 -0400 Received: from mail-lj1-x242.google.com (mail-lj1-x242.google.com [IPv6:2a00:1450:4864:20::242]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1D385C0613CE for ; Thu, 22 Oct 2020 04:41:00 -0700 (PDT) Received: by mail-lj1-x242.google.com with SMTP id c21so1543804ljn.13 for ; Thu, 22 Oct 2020 04:41:00 -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=5gzlInlR4QMg3ZQ/I04CuQTpDYmT0qaMY9vRAxu4Izc=; b=mTKSsn/Q3P3WeHCjoX5IQNxgRPV8RleCVN6AJn7mcrVmanmbBnlGkT50iAk+PxYC5j qQp9dWwiw/3KBUeWUcdU8Fz65Z4hbWiPLxYfYlJ2km2Apub6hdQ90j9/EiD63ru4QnUC 35Uu1f/K8zugcF0ZzbhV7dVmvdFnKt8vmm0OwH+9M+1zea7hY/I8uqan0ceGDBy9koWS /SDmF5NqmFjznRTDWV9I8pKTm6iE2ADiCMXGzc9L7H0LAPxeKUHetrcuREUBZUMYa317 N/Dl8oD6wbmqaIyz6NX3u4V0w3I3OT4GnY6XMDFUUV8EWkgXIogzyJhTUm/ubnNSrbib Vy9w== 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=5gzlInlR4QMg3ZQ/I04CuQTpDYmT0qaMY9vRAxu4Izc=; b=OAP3LkzsGYd5CRhZVAqvHP1zUI3LXcqKt67dwvSwysU8wzDWnFHyVja2lUbz/flRJ8 s1LXcsYygkQU5n9jRaYcOM1LZC2vEbDRP0DBqXH+ItVkkS+JtRUFh61gQkAEPlL44B6n 79sfzo98MfPFZCbIkWfiuHwX4XmxXrjYzjoyInbJjkktItC09ke73XY77VgLKDy5elpj K8zg4HfPlQP5gWGSWJWdfMP2dsYqoTlWCCaMCgDCN/Dx+84oqOq/q/wYy1J9K5DF56Fn 4sTEx52Kdrqu6S54VU71M/BARcE8uutxhw5AzbKCpx+Xds6uaHKdvMSJgiGxiIyRD9ij 3HAw== X-Gm-Message-State: AOAM5313t0YhxVJ9gnmYOoywIvz4TdSr5JLFnmCbLH2dzbKoC20Zu2kJ tHwKAkzmokBNoZhfiOGh3ls2xTon0YKjgRyV03U/cQ== X-Received: by 2002:a2e:b009:: with SMTP id y9mr751337ljk.372.1603366858536; Thu, 22 Oct 2020 04:40:58 -0700 (PDT) MIME-Version: 1.0 References: <1602065268-26017-1-git-send-email-sumit.garg@linaro.org> <1602065268-26017-2-git-send-email-sumit.garg@linaro.org> <8e07f9401c9f7e18fb1453b7b290472c0049c6e6.camel@linux.ibm.com> <7b2ccd620a9de5c2fd57b8e8aeb41d5476f83b28.camel@linux.ibm.com> In-Reply-To: <7b2ccd620a9de5c2fd57b8e8aeb41d5476f83b28.camel@linux.ibm.com> From: Sumit Garg Date: Thu, 22 Oct 2020 17:10:46 +0530 Message-ID: Subject: Re: [PATCH v7 1/4] KEYS: trusted: Add generic trusted keys framework To: Mimi Zohar Cc: Jarkko Sakkinen , 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 Wed, 21 Oct 2020 at 17:55, Mimi Zohar wrote: > > On Wed, 2020-10-21 at 11:16 +0530, Sumit Garg wrote: > > Thanks Mimi for your comments. > > > > On Wed, 21 Oct 2020 at 08:51, Mimi Zohar wrote: > > > > > > On Wed, 2020-10-07 at 15:37 +0530, Sumit Garg wrote: > > > > > > > +/* > > > > + * trusted_destroy - clear and free the key's payload > > > > + */ > > > > +static void trusted_destroy(struct key *key) > > > > +{ > > > > + kfree_sensitive(key->payload.data[0]); > > > > +} > > > > + > > > > +struct key_type key_type_trusted = { > > > > + .name = "trusted", > > > > + .instantiate = trusted_instantiate, > > > > + .update = trusted_update, > > > > + .destroy = trusted_destroy, > > > > + .describe = user_describe, > > > > + .read = trusted_read, > > > > +}; > > > > +EXPORT_SYMBOL_GPL(key_type_trusted); > > > > + > > > > +static int __init init_trusted(void) > > > > +{ > > > > + int i, ret = 0; > > > > + > > > > + 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) > > > > + break; > > > > + } > > > > > > In the case when the module paramater isn't specified and both TPM and > > > TEE are enabled, trusted_key_ops is set to the last source initialized. > > > > I guess there is some misunderstanding. Here it's only a single trust > > source (TPM *or* TEE) is initialized and only that trust source would > > be active at runtime. And trusted_key_ops would be initialized to the > > first trust source whose initialization is successful (see check: "if > > (!ret)"). > > My mistake. > > > > > > After patch 2/4, the last trusted source initialized is TEE. If the > > > intention is to limit it to either TPM or TEE, then trusted_key_ops > > > should have a default value, which could be overwritten at runtime. > > > That would address Luke Hind's concerns of making the decision at > > > compile time. > > > > I think traversing the trust source list with the initial value being > > TPM would be default value. > > Agreed > > > > > > > > trusted_key_ops should be defined as __ro_after_init, like is currently > > > done for other LSM structures. > > > > Sure, will do. > > Thanks > > > > > > > > > + > > > > + /* > > > > + * encrypted_keys.ko depends on successful load of this module even if > > > > + * trusted key implementation is not found. > > > > + */ > > > > + if (ret == -ENODEV) > > > > + return 0; > > > > + > > > > + return ret; > > > > +} > > > > + > > > > +static void __exit cleanup_trusted(void) > > > > +{ > > > > + trusted_key_ops->exit(); > > > > > > If the intention is really to support both TPM and TEE trusted keys at > > > the same time, as James suggested, then the same "for" loop as in > > > init_trusted() is needed here and probably elsewhere. > > > > Current intention is to only support a single trust source (TPM or > > TEE) at runtime. But in future if there are use-cases then framework > > can be extended to support multiple trust sources at runtime as well. > > Ok, the last sentence of the patch description, "Also, add a module > parameter in order to select a particular trust source in case a > platform support multiple trust sources.", needs to be expanded to: > - indicate only one trust source at a time is supported > - indicate the default, if the module_param is not specified > Sure, I will expand that. > I would also change the word from "add" to "define". Ack. > The new "source" > module parameter needs to be added to the admin-guide/kernel-parameters > documentation. Okay, will update documentation as well. -Sumit > > thanks, > > Mimi > >