Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp599178img; Wed, 20 Mar 2019 07:09:37 -0700 (PDT) X-Google-Smtp-Source: APXvYqyH9SnqJ0TmwxSpJ6boe1HwkQHBTlQRQFV5P2fa/3Mm72qhiIfUpypjwsckiNdOp5l5hgkm X-Received: by 2002:a65:51c2:: with SMTP id i2mr7542533pgq.295.1553090977632; Wed, 20 Mar 2019 07:09:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553090977; cv=none; d=google.com; s=arc-20160816; b=Fnxt+mUCZJDRyAqPS5jBWGWJnZrHKXgJqi7v8c3lTycLYWHPo0gbKUeItOPoQsDlvR GAal9shRch7KEMOOZUI4Zgti+dACVWmql5bi1hUwxQbXN9QId1MnFLoxniO/3SqcuZIZ EPymKeMr4HJVYqm5La353Zgyq2yCq0pHPKwgl2jOYsJca7whYMIoSlobYviZQo2f7HC1 dfs4eQABw15LMgRgRY2BR5l7nd9SYX26nSEyN1nV7AJZQwRNi01mC4IGnYaiXJqcBCMr M93rckMQVmo+nKmFVzYF3GJaxzmeUzmrV7YSm5MGU/OkOBEXPo4N8Cizh7w8ttrd6ELs zeWQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:content-transfer-encoding :mime-version:references:in-reply-to:date:cc:to:from:subject; bh=VoWqHUhJFiBs0Erd9uTfBAHzGRMIjTCNQF2ahrx1U6I=; b=DHe2zAklG9IM7yJqsGdE0++ShBOw4iXkK2Njyw4XfxWWr8bs7ucB9EsgEVi4SVegvZ ZLF5m98UiYMKmY4HxyY+y0q9bCfGaSLJQBNblQcN1P2M27HDkLHiw3Rdnr9tRmGMuIlZ Gy5D29wLeVeQbXULW2c88aFLVG4tU5N1GW/pP8RS0uFvsuPmbLhFUq27VSLRUDGeNQjX /v6BQlkU8mijBMj3/3dnawuY1ooOWHV2Bc0gBXHVLvhxtlm13H3dvnO4LELXxFGPOjvq hSf3eZqooix8MDXw86rM3wm6gWEFbhnNqEH5r8c4wPeBPnAf3d1s0jP6xGGvXIytf+m8 Iakw== ARC-Authentication-Results: i=1; mx.google.com; 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=ibm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a22si1701705pfn.155.2019.03.20.07.09.20; Wed, 20 Mar 2019 07:09:37 -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; 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=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727268AbfCTMGj (ORCPT + 99 others); Wed, 20 Mar 2019 08:06:39 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:56130 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726417AbfCTMGj (ORCPT ); Wed, 20 Mar 2019 08:06:39 -0400 Received: from pps.filterd (m0098409.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x2KBxnIM022674 for ; Wed, 20 Mar 2019 08:06:38 -0400 Received: from e06smtp07.uk.ibm.com (e06smtp07.uk.ibm.com [195.75.94.103]) by mx0a-001b2d01.pphosted.com with ESMTP id 2rbkrsn7t4-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 20 Mar 2019 08:06:37 -0400 Received: from localhost by e06smtp07.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 20 Mar 2019 12:06:34 -0000 Received: from b06cxnps4075.portsmouth.uk.ibm.com (9.149.109.197) by e06smtp07.uk.ibm.com (192.168.101.137) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Wed, 20 Mar 2019 12:06:31 -0000 Received: from d06av26.portsmouth.uk.ibm.com (d06av26.portsmouth.uk.ibm.com [9.149.105.62]) by b06cxnps4075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id x2KC6UQf33619984 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 20 Mar 2019 12:06:30 GMT Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D8E96AE055; Wed, 20 Mar 2019 12:06:30 +0000 (GMT) Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id ED020AE04D; Wed, 20 Mar 2019 12:06:29 +0000 (GMT) Received: from localhost.localdomain (unknown [9.80.93.235]) by d06av26.portsmouth.uk.ibm.com (Postfix) with ESMTP; Wed, 20 Mar 2019 12:06:29 +0000 (GMT) Subject: Re: [PATCH 2/6] security/keys/encrypted: Clean up request_trusted_key() From: Mimi Zohar To: Dan Williams Cc: keyrings@vger.kernel.org, James Bottomley , David Howells , Vishal L Verma , linux-nvdimm , Linux Kernel Mailing List Date: Wed, 20 Mar 2019 08:06:19 -0400 In-Reply-To: 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> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.20.5 (3.20.5-1.fc24) Mime-Version: 1.0 Content-Transfer-Encoding: 8bit X-TM-AS-GCONF: 00 x-cbid: 19032012-0028-0000-0000-000003564121 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19032012-0029-0000-0000-00002414E274 Message-Id: <1553083579.4899.239.camel@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2019-03-20_07:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1903200095 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. Mimi