Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp632512iog; Mon, 13 Jun 2022 09:31:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwDH7l0UyMSVugF8zgVLk+GIiZ0sdMFIE48FsrMWKySCiPlBr0GlY/W95sskmk2CizUqb9H X-Received: by 2002:a05:6a00:24c1:b0:51c:784:cb59 with SMTP id d1-20020a056a0024c100b0051c0784cb59mr134410pfv.57.1655137916104; Mon, 13 Jun 2022 09:31:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655137916; cv=none; d=google.com; s=arc-20160816; b=BVM8ZcF/C9vSgRRElbx+C5phxHeFGtCdVcj22dkaX7130aP6Mje8wpSEXOqeOZFoUl kZfz3gVcXbH6oQqghREsGCeYgUedU6gDEcfT+3+bF8qOvTaUVurCJb2olT2FVGHQZ2pg 4s7X9j0EFswnh6wSTRjc5aWGZ7TXZVuW4Nhem5UFbMOWhcR00y+pvntUeWHG6Zu5BR2x mb1dSZE9kM1hbQdoiP+Qg3mdgTGQoOgmr6wzZfGCwn2MiVsRnWnzC4+BkbsNIcZP6czy gtdLX8lO6wcVN36g+kTHmlEX1kx17P3Tg04qQs0dWzSR19SgEFVxPu1XPN96QDogpFyg ILLg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=WdsRiqCs4OvFJ9hSMOo88gt4zNS2xLM0/VoFE8lrNbU=; b=dP6zOZQ2UfG8t134B+MamfzYn0b+YI4uJzBpC/m9k4Vg3N38Zgl6QGmE4F22H0lwgZ WPsZRGMreGz8d6b7BZd5snRh1eNSWkj3FR7KzxhaHU5/xm99ROM0+OwZwAkD6KJf2tcE CUXFX2IATS8aqXgOdAeEv0zEHbOM1sniKMxbCs4THFWP7Kuzd98cwJpftubfv1ev4LaJ hMgdmcEXqSyLYdxVyZZWXKsVsL5F0+Gy4AHhx8ikAAxsXlVPxiqV4kICuDIL3XhE6uBv YXg1cL7fhttk7otUlLqMF55ti7Mc9ouFb1i1yv/daEjbXFGZrNu/r0MjUfu/fflMLAli n8/g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=nKRK+DqZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z28-20020a630a5c000000b003fe49e8de38si11332286pgk.409.2022.06.13.09.31.43; Mon, 13 Jun 2022 09:31:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=nKRK+DqZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1382402AbiFMOOM (ORCPT + 99 others); Mon, 13 Jun 2022 10:14:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43276 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1381074AbiFMODp (ORCPT ); Mon, 13 Jun 2022 10:03:45 -0400 Received: from sin.source.kernel.org (sin.source.kernel.org [IPv6:2604:1380:40e1:4800::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 70B2790CE9; Mon, 13 Jun 2022 04:38:37 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sin.source.kernel.org (Postfix) with ESMTPS id CECD2CE1174; Mon, 13 Jun 2022 11:38:35 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B7891C34114; Mon, 13 Jun 2022 11:38:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1655120314; bh=sXhm+oMCrui/y0I0+QBtmpIK+POYQhAS48jgfA/2Ycw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nKRK+DqZuP+QUyrxRbz5ACpcf2kEAMtYMXN7Pj03Ql6kIoo370ndhmE3QrfOZ1pW8 +emRuoRJIa8PSkapsjiuGvT0c8se38oyRcF3nkoIAwN7ApLC2t0CbxggEd0f/Zp/Es cIbW9LM7erHTRm8Uh4SlhHOkKVfY+cqqMfuORTBw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, David Safford , Ahmad Fatoum , Jarkko Sakkinen Subject: [PATCH 5.18 308/339] KEYS: trusted: tpm2: Fix migratable logic Date: Mon, 13 Jun 2022 12:12:13 +0200 Message-Id: <20220613094936.097972286@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220613094926.497929857@linuxfoundation.org> References: <20220613094926.497929857@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-8.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham 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 From: David Safford commit dda5384313a40ecbaafd8a9a80f47483255e4c4d upstream. 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. Cc: stable@vger.kernel.org # v5.13+ Fixes: e5fb5d2c5a03 ("security: keys: trusted: Make sealed key properly interoperable") Signed-off-by: David Safford Reviewed-by: Ahmad Fatoum Reviewed-by: Jarkko Sakkinen Signed-off-by: Jarkko Sakkinen Signed-off-by: Greg Kroah-Hartman --- security/keys/trusted-keys/trusted_tpm2.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) --- 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 *c /* 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 */