Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp4820926rwb; Sun, 13 Nov 2022 14:46:16 -0800 (PST) X-Google-Smtp-Source: AA0mqf6fqHKksvn0d78U/gP/aUM8uUHgmzWKOjOuNdlUsBFDOe/PZlbvuqsuCsTP6njt/w9Zi8Jg X-Received: by 2002:a17:90a:9746:b0:214:2920:4675 with SMTP id i6-20020a17090a974600b0021429204675mr11228533pjw.0.1668379575897; Sun, 13 Nov 2022 14:46:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668379575; cv=none; d=google.com; s=arc-20160816; b=mfxdFekcKjyx0EMXrX0hhtdSlkCkO3bgQnqrwrRR999LC2cHRDyF2BPOAyroMM28Bt WWS6dDNU57nPuWnenWG2dheOapu5wwEJKUwizlli2BvQ22pgXegavDLwN4d1hA1Zl8dI W1mELdrlI2GGtiqn4vrEv+DBPWC55+WSVq0qB739y7RHz+hRR+Odnr6yk37+W83jH79l 48eRB+SzKub8IcEc1zRUvTtF9dEYUEkYnLOV2/4jqsu7xvUSMvuldn4aQzF7x5OzumEg EAQvAgzWjgibMvuwLhOe0Cl6cGfVPsOe8wSKF6ctNzANDUegybzWO7pECeZJHfNhMwCe 0pfg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=qjq6v+ZRFgCBMfqKOV2QFF+b30ZEui0OIPNhZykTpEs=; b=EzQMXKn/swlVdy4hSek2DWGBDBSAkj/nsw4EIdxwP4VtPOAHObJpC109wqjeZfrDSQ lHIGNzvXz2mUWnNciW07SVUwemN8Yg+FJfUvD7nWM3Uy0ROdnVzLMGGDJBOpysOLQrtg uyMyhYBujOlzevlCrKdEHeBf7irPB+zcUlLFoYd0tgc4pfuZZiRMUb4XVqnkZKMWE7k+ UCfHDKu25nugj1IG8SjdBzEFrlphRNYPil/+pcMVgoByvszGPic1vrfjOIUXX+KTxoI3 BRtel07gw5Jpk8l0eEageEngdFFap9qyKpWEF5HjSqMCTWcgTQQzqA7CNt5Z+KQJpJG0 tlZA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=YU8MQ8uM; 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=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k14-20020a170902760e00b0017f8d9b7e5fsi7851898pll.133.2022.11.13.14.46.04; Sun, 13 Nov 2022 14:46:15 -0800 (PST) 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=@kernel.org header.s=k20201202 header.b=YU8MQ8uM; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235377AbiKMWBP (ORCPT + 89 others); Sun, 13 Nov 2022 17:01:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51444 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229692AbiKMWBN (ORCPT ); Sun, 13 Nov 2022 17:01:13 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6F1201054A; Sun, 13 Nov 2022 14:01:11 -0800 (PST) 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 dfw.source.kernel.org (Postfix) with ESMTPS id A051260BDE; Sun, 13 Nov 2022 22:01:10 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 35D8AC433C1; Sun, 13 Nov 2022 22:01:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1668376870; bh=K5+D7God8Baxo1J6cPFLSl608FEFDRggQ4yke5n3xdE=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=YU8MQ8uMV2XGwHl63jHpURf7CVlgD2sGJcgA/Vo+inaOVcnjT5WSW2iyX72mpUFOj iCKmhuiRkxg05XsVFjGnyWJGL5uoWzsT3pZRXB1kujV3uphhELxAe+ajAAF3ExVVeV 9JBXvRpzHaeIY2u8ld5OOK3gcoqilNy7qFC7L2MQ2uBMF/xGFsZ1PcjRdEJKjgwZ84 0KAwSycBi6In4UgdButVUW6xxLEIicmsTcKkaekhG9JgUWw4z+E6owDOzac7c5xUb9 xnuVK41dQkrLdni402swB4wKlQzm9WHn5X9dWDGhyD8koWrT6keFjwzzJmZMFmkoc4 FD2u3YES7Dq2Q== Date: Sun, 13 Nov 2022 14:01:07 -0800 From: Eric Biggers To: Evan Green Cc: linux-kernel@vger.kernel.org, corbet@lwn.net, linux-integrity@vger.kernel.org, gwendal@chromium.org, dianders@chromium.org, apronin@chromium.org, Pavel Machek , Ben Boeckel , rjw@rjwysocki.net, jejb@linux.ibm.com, Kees Cook , dlunev@google.com, zohar@linux.ibm.com, Matthew Garrett , jarkko@kernel.org, linux-pm@vger.kernel.org, Matthew Garrett , Ben Boeckel , David Howells , James Morris , Paul Moore , "Serge E. Hallyn" , keyrings@vger.kernel.org, linux-doc@vger.kernel.org, linux-security-module@vger.kernel.org Subject: Re: [PATCH v5 05/11] security: keys: trusted: Allow storage of PCR values in creation data Message-ID: References: <20221111231636.3748636-1-evgreen@chromium.org> <20221111151451.v5.5.I32591db064b6cdc91850d777f363c9d05c985b39@changeid> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20221111151451.v5.5.I32591db064b6cdc91850d777f363c9d05c985b39@changeid> X-Spam-Status: No, score=-7.1 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 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 On Fri, Nov 11, 2022 at 03:16:30PM -0800, Evan Green wrote: > + creationpcrs= hex integer representing the set of PCRs to be > + included in the creation data. For each bit set, the > + corresponding PCR will be included in the key creation > + data. Bit 0 corresponds to PCR0. Currently only the first > + PC standard 24 PCRs are supported on the currently active > + bank. Leading zeroes are optional. TPM2 only. What does "currently active bank" mean? > + /* PCR bitmask */ > + for (i = 0; i < 3; i++) { > + char tmp = 0; > + > + for (j = 0; j < 8; j++) { > + char bit = (i * 8) + j; > + > + if (options->creation_pcrs & (1 << bit)) > + tmp |= (1 << j); > + } > + tpm_buf_append_u8(&buf, tmp); > + } Why not just: tpm_buf_append_u8(&buf, options->creation_pcrs); tpm_buf_append_u8(&buf, options->creation_pcrs >> 8); tpm_buf_append_u8(&buf, options->creation_pcrs >> 16); Also what if bit 24 or above is set? Should an error be returned? - Eric