Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp671790img; Wed, 20 Mar 2019 08:30:28 -0700 (PDT) X-Google-Smtp-Source: APXvYqwwXAlgzdDu49VXnMMRAKGPqqzCTGlVCiEv+eXLZmqRqUITu/U0ewSHppOGl09w8TQWdgi7 X-Received: by 2002:a62:5a42:: with SMTP id o63mr15713887pfb.170.1553095828464; Wed, 20 Mar 2019 08:30:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553095828; cv=none; d=google.com; s=arc-20160816; b=MlKaWNR/PPbCUKT1+xQEdyQCxKV8AvzPoZ4eHk5KSN4x/bEpzDQ7GSFyhNqqHZyIOz SG9T9QHjXWWdw9MpmDiMjIYnDh0qXsWmQZnx0tRmT3pcOeFnqB9PnZNnuKpbssx5Et8J QTSU0bz3+MUMRDtBO8ZYr4Nm2HQQEroMQ03v72WiotbjsObhl+CdQEZiJRg9mVAlCBeb mgjIJzpmc7uhVz0oSb4vM23seFSaljq8A68S3lOaBQaxeeEwwzOspN9/2Zgmmkh5p2Hw vAMH2MGdRs1nBlVTxJYTcbqZMFWjOoeTX0BTZfknXsfFQetPDWV7DzS5rA5TpNuQ/muF EuNQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=rwGFYhBdhCtEeLruvXYmJbIFZgn7DMiOJ06MFTraeH0=; b=ebL0A81gCY/swxwyoQWE4DM3iCx9H4wCzqrnu4tiE732aT93nM6wjrctx83Tsl7TMB SRx+ye1VTtgkgPnMxVph+wnWCXplnmyJJ0yu2/nPruuNIlCGnCwJrPNctXuGKYJGwfwB frBomEpJ5yqplnd06u0oYRVJxDhWczqUygKuXoQPeDsvFvMI5eM3ezk5L+MHUq/r2SSj TKewPlOrUQG5A9C/j8lEQA3MpBxsgyR/ohH8qzG6k3i3uMcZUTx2BYPoIW0J8R184N6f HZ7Qo+8E/wrym5sklphAaTYT54h7gJ+RcujnmIg8cu+CU/a76lJ9l8MLnEtXjAoZj+Ib fAtw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel-com.20150623.gappssmtp.com header.s=20150623 header.b=sFNV1rDo; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e9si1868107pgo.83.2019.03.20.08.30.12; Wed, 20 Mar 2019 08:30:28 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@intel-com.20150623.gappssmtp.com header.s=20150623 header.b=sFNV1rDo; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727582AbfCTP15 (ORCPT + 99 others); Wed, 20 Mar 2019 11:27:57 -0400 Received: from mail-ot1-f67.google.com ([209.85.210.67]:40426 "EHLO mail-ot1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726644AbfCTP15 (ORCPT ); Wed, 20 Mar 2019 11:27:57 -0400 Received: by mail-ot1-f67.google.com with SMTP id x8so611486otg.7 for ; Wed, 20 Mar 2019 08:27:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=rwGFYhBdhCtEeLruvXYmJbIFZgn7DMiOJ06MFTraeH0=; b=sFNV1rDos+zMO5kqopVV3XECY9zoXCbjNnFCXK8CI0XTjzXtUH66d8xnUN1wUa/Wae 9zkM2X02/oFoTPfXkSk3h3UevXKllX45UdUpnaq4NIduDtkzio1B0dHmOpqkusq6nlYb WhnXQei/hPdnO7kDzLLl5J8esaloI2hbEf8QW3U2cxQ4sWkw+cryN7Q3WIKjWo2vo+Mf ce0WXl/oBL8xeqvFb0oJFyliABjD+RqaA6jHisbs6EXr3TR+UbaQlRKXeijKnUQ0sORy EWKT/zMxBJiEh2dv9uzcN/jnjPDFCZ2anKgt9OHJ3w8F83Rq9b+TcL/TJCB/t55adKke wE4w== 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=rwGFYhBdhCtEeLruvXYmJbIFZgn7DMiOJ06MFTraeH0=; b=FvifjLeL5N+iwzHbPB7lKirKRprMWuG0odAtikkTPpocBq/lp++xn9LhMyl2Yt3ZMM c6rOkaVJxJ1gkWz6jdBtXu8U737rNtyOp344eCdworqDceS5hUFn2MotEMPa56ofkFQI R6RKnIQfzK8ZeqsCsg59lohYw28fUPd2IfgKW09WNcn0D3XBTvvr4zj9Nk/GPqp8bpDb IS4JhmSPPRHBwBE+IRo4obhcp2RKIJ7UlcV3CpUUPYZf0YLjCqSt7lS/vZ6WwUv/CqQV vpsQgiDeFcTwZ20gWg9y05YRiF/2xuoyl4XJ51H0WWl11PWEic7HRcRKb9DG8As8895s i22Q== X-Gm-Message-State: APjAAAXGnKljaJfbGHl02CefONJWfuslWeDZeiE+ByOV8t4VM7vSD0Vz b6Hw37UkQZvokqfdNHrhaffGG8RdfMm2z1H16s5G9A== X-Received: by 2002:a9d:2c23:: with SMTP id f32mr5999831otb.353.1553095675863; Wed, 20 Mar 2019 08:27:55 -0700 (PDT) MIME-Version: 1.0 References: <155297557534.2276575.16264199708584900090.stgit@dwillia2-desk3.amr.corp.intel.com> <155297558570.2276575.11731393787282486177.stgit@dwillia2-desk3.amr.corp.intel.com> <1553040398.4899.149.camel@linux.ibm.com> <1553049331.4899.177.camel@linux.ibm.com> <1553083579.4899.239.camel@linux.ibm.com> In-Reply-To: <1553083579.4899.239.camel@linux.ibm.com> From: Dan Williams Date: Wed, 20 Mar 2019 08:27:45 -0700 Message-ID: Subject: Re: [PATCH 2/6] security/keys/encrypted: Clean up request_trusted_key() To: Mimi Zohar Cc: keyrings@vger.kernel.org, James Bottomley , David Howells , Vishal L Verma , linux-nvdimm , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Mar 20, 2019 at 5:07 AM Mimi Zohar wrote: > > On Tue, 2019-03-19 at 22:48 -0700, Dan Williams wrote: > > On Tue, Mar 19, 2019 at 7:36 PM Mimi Zohar wrote: > > > > > > On Tue, 2019-03-19 at 17:20 -0700, Dan Williams wrote: > > > > On Tue, Mar 19, 2019 at 5:07 PM Mimi Zohar wrote: > > > > > > > > > > On Mon, 2019-03-18 at 23:06 -0700, Dan Williams wrote: > > > > > > > > > > < snip > > > > > > > > > > > > +/* > > > > > > + * request_trusted_key - request the trusted key > > > > > > + * > > > > > > + * Trusted keys are sealed to PCRs and other metadata. Although userspace > > > > > > + * manages both trusted/encrypted key-types, like the encrypted key type > > > > > > + * data, trusted key type data is not visible decrypted from userspace. > > > > > > + */ > > > > > > +static struct key *request_trusted_key(const char *trusted_desc, > > > > > > + const u8 **master_key, size_t *master_keylen) > > > > > > +{ > > > > > > + struct trusted_key_payload *tpayload; > > > > > > + struct key_type *type; > > > > > > + struct key *tkey; > > > > > > + > > > > > > + type = key_type_lookup("trusted"); > > > > > > > > > > The associated key_type_put() will need to be called. > > > > > > > > Yes. > > > > > > I don't know if defining a key_type_lookup() wrapper, perhaps named > > > is_key_type_available(), would help. Both key_type_lookup() and > > > key_type_put() would be called. The existing code could then remain > > > the same. > > > > > > > Maybe, but something still needs to pin the hosting module. I think > > this means that the first call to key_type->instantiate() pins the > > hosting module, and the ->destroy() of the last key for the key_type > > unpins the module. It does mean that the ->destroy() method is no > > longer optional. > > This sounds like it isn't a new problem. Both issues need to be > addressed, but I think we should differentiate between them and > address them separately. > > In terms of the original nvdimm encrypted/trusted key problem, the > above suggestion requires the least amount of change. For v5.2, I > would replace it with the full updated patch set. I believe smallest amount of change is this single patch: https://patchwork.kernel.org/patch/10858649/