Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp2183980iof; Tue, 7 Jun 2022 22:29:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwRZrzXVcSg1dtO+9DfAXsHvNLLdNxT1C0LadClwcvqy5gCSZ8+9w4iRWmPinb20035XyDq X-Received: by 2002:a65:6e8b:0:b0:3ab:a3fb:e95a with SMTP id bm11-20020a656e8b000000b003aba3fbe95amr28289848pgb.433.1654666167393; Tue, 07 Jun 2022 22:29:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654666167; cv=none; d=google.com; s=arc-20160816; b=tVpkjtxYv6fO6yGsr47vxlJ5+/D9/uHOTiQm+jq0zvwXhvUZrlKSb135ZYl6L51flp kDe2mT2kxmVnU6h+H1G5aWNpw+9DxBH0MsDCb/8eyJEzRwDST54acadAdUa5XtppMwNJ 5i00sSD+3ugq3H+waLRY18l6kQfmKhHY3TKfPttFI2kWJ0dcRSQau+scjvJEuomP+QNw gcOZzE6S3kBo1+HcPSIHbXPN3pQ4qd1/eEJ9tQOSctwc4Wej87ZgpTa7dmX5FEPTu1Zr MttAybB0UVJ7HgpjNEUJoi8nlahHalpOINTFpYgJ9IDsgkPglXuqK7F8ZfhhfdVHk0lQ lUuA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id; bh=Y32SBTvA9JyQBtOK2qsC8W9o71pJOU84M7SMQ9d6pl0=; b=Jug4s1eF/oPLcbkA5ctbHlzVgzQS+cYEX/ueLxzAiIl0zHJ+16pOIVCRdV2IcotW3S Fq8zlb+7iiOABmLLmFfWIAVZdE5Yw/0UuplHw+2j3BMY/yErBxSYz7mEdp/I3DdXRzwF dPEl1/BQVYTVOdhYDsr5Uv2OgmfBTqeYj1G6iNM/NkA0MfmgruV72KWF2RvYpmFpUAXR WfO5gTwrjaxJcbIV//5gTiw7P9WDwTHa+BuMo42ebL1c3tNfFuICCqQKuB0oLxyC+ifB cL1SvOWipJ0TaoCSLBh0kt93Oa2X/6xZfLIXnibM2mcLQsS2rPZrOsYF7I9uO/hjRTcF jMsA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id o14-20020a17090ac70e00b001e28e2f497fsi23773616pjt.161.2022.06.07.22.29.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jun 2022 22:29:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 4983647E410; Tue, 7 Jun 2022 21:55:17 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1380237AbiFGWRh (ORCPT + 99 others); Tue, 7 Jun 2022 18:17:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35092 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1379995AbiFGVLW (ORCPT ); Tue, 7 Jun 2022 17:11:22 -0400 Received: from metis.ext.pengutronix.de (metis.ext.pengutronix.de [IPv6:2001:67c:670:201:290:27ff:fe1d:cc33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 69E2121734C for ; Tue, 7 Jun 2022 11:52:49 -0700 (PDT) Received: from ptz.office.stw.pengutronix.de ([2a0a:edc0:0:900:1d::77] helo=[127.0.0.1]) by metis.ext.pengutronix.de with esmtp (Exim 4.92) (envelope-from ) id 1nyeJf-0007KB-17; Tue, 07 Jun 2022 20:52:35 +0200 Message-ID: <0429fbb6-691d-1283-e364-209054bc38a7@pengutronix.de> Date: Tue, 7 Jun 2022 20:52:29 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.9.0 Subject: Re: [PATCH v2] KEYS: trusted: tpm2: Fix migratable logic Content-Language: en-US To: david.safford@gmail.com, Jarkko Sakkinen , James Bottomley , Mimi Zohar , David Howells , James Morris , "SergeE.Hallyn" Cc: linux-integrity@vger.kernel.org, keyrings@vger.kernel.org, linux-security-module@vger.kernel.org, linux-kernel@vger.kernel.org References: <141492344ae13c9842626e696685316ee340d717.camel@gmail.com> From: Ahmad Fatoum In-Reply-To: <141492344ae13c9842626e696685316ee340d717.camel@gmail.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-SA-Exim-Connect-IP: 2a0a:edc0:0:900:1d::77 X-SA-Exim-Mail-From: a.fatoum@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org X-Spam-Status: No, score=-3.1 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,NICE_REPLY_A, RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 07.06.22 20:07, david.safford@gmail.com wrote: > When creating (sealing) a new trusted key, migratable > trusted keys have the FIXED_TPM and FIXED_PARENT attributes > set, and non-migratable keys don't. This is backwards, and > also causes creation to fail when creating a migratable key > under a migratable parent. (The TPM thinks you are trying to > seal a non-migratable blob under a migratable parent.) > > The following simple patch fixes the logic, and has been > tested for all four combinations of migratable and non-migratable > trusted keys and parent storage keys. With this logic, you will > get a proper failure if you try to create a non-migratable > trusted key under a migratable parent storage key, and all other > combinations work correctly. > > Fixes: e5fb5d2c5a03 ("security: keys: trusted: Make sealed key properly interoperable") > Signed-off-by: David Safford Reviewed-by: Ahmad Fatoum Thanks, Ahmad > --- > Changelog: > * v2: > * added Signed-off-by, Fixes, proper Subject and distribution > . > security/keys/trusted-keys/trusted_tpm2.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/security/keys/trusted-keys/trusted_tpm2.c b/security/keys/trusted-keys/trusted_tpm2.c > index 0165da386289..2b2c8eb258d5 100644 > --- a/security/keys/trusted-keys/trusted_tpm2.c > +++ b/security/keys/trusted-keys/trusted_tpm2.c > @@ -283,8 +283,8 @@ int tpm2_seal_trusted(struct tpm_chip *chip, > /* key properties */ > flags = 0; > flags |= options->policydigest_len ? 0 : TPM2_OA_USER_WITH_AUTH; > - flags |= payload->migratable ? (TPM2_OA_FIXED_TPM | > - TPM2_OA_FIXED_PARENT) : 0; > + flags |= payload->migratable ? 0 : (TPM2_OA_FIXED_TPM | > + TPM2_OA_FIXED_PARENT); > tpm_buf_append_u32(&buf, flags); > > /* policy */ > -- > 2.36.1 > -- Pengutronix e.K. | | Steuerwalder Str. 21 | http://www.pengutronix.de/ | 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |