Received: by 2002:a05:6358:16cd:b0:dc:6189:e246 with SMTP id r13csp1304278rwl; Fri, 4 Nov 2022 12:14:48 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4kkhnI1twek9ELtc0kDPr7uGdvrpOAtEdMG5X4gPJXZE1/pR5vU9gmA+fVR0tKeVVMFf5f X-Received: by 2002:a17:907:75f4:b0:7ad:b868:ccf2 with SMTP id jz20-20020a17090775f400b007adb868ccf2mr32932890ejc.733.1667589288393; Fri, 04 Nov 2022 12:14:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667589288; cv=none; d=google.com; s=arc-20160816; b=OQq4EI9yY/Ol7RA5JYmrVxWBEiPNN02zZLUQgIgavHa6sgvVshzmOy05eeLsV8YyQj HrMVqGtsL+KK1HkmloXPGkO1nbf1CEeJwhfYYOAYeLf7Pe+aGqjVnLP94BE7Hm6zAD3c OVz0uasK397Z/7PyNi0J6SU2F3bIaTNtyAmEmvRSZSf1lWNEq9X28H5+7r9/jK7tL0q0 OlEDLiazEhIUbNPpyCO3Hp91YwI13NnH67uX+avrwQlJxcps9FJw9oUjBXYcGNFgnWvA KbMxmhskz5ey1G/0Y/x1HNFeLFAwinqYWgclyCQLwEtZ27tcg3cY08g7UdoDO2kFNoBv bJ/A== 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=cHlujkwLHQA1OWRlitXKA2okTr4nOrBSjZdPzF8hE5c=; b=RSdEJ97luWfx/ayhZTb+yEdvzSsR9S6oFh49Mwhk8WJSKOH811jQ6lrTaJiqIPwH9R Xr4PVAjgl1CDKYE4KM3HY93vMAxB/Ttv1Qt/yFsxmR/+u+BUIsCZbRYfM9FJnUr7KB7p tNGBTVEHXBofWYBeKymC+8WTtUX/ADhCeAr/NS9v3DHJfJB7cLxaQKLOUOV0SCEtJcJc gcAlAqiez0HjtbUY980mPT2CJmqLcLyXDDdOdqF52/Q0bSHixfXLovx+NxEa4V4zG0W0 Vzcp/c55j+4f27Qrq9Ex5xQQxXEtK+8Y8Hg3I+mRg85q26Yw4ESKQGG8NGfalZJsj/+g w0Lw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b="fYGdM/Tg"; 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=chromium.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ga17-20020a1709070c1100b007addf59b7f5si6409601ejc.794.2022.11.04.12.14.24; Fri, 04 Nov 2022 12:14:48 -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=@chromium.org header.s=google header.b="fYGdM/Tg"; 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=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232146AbiKDSeE (ORCPT + 96 others); Fri, 4 Nov 2022 14:34:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52806 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232144AbiKDSd6 (ORCPT ); Fri, 4 Nov 2022 14:33:58 -0400 Received: from mail-pf1-x431.google.com (mail-pf1-x431.google.com [IPv6:2607:f8b0:4864:20::431]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 849972AC6 for ; Fri, 4 Nov 2022 11:33:56 -0700 (PDT) Received: by mail-pf1-x431.google.com with SMTP id y13so5225526pfp.7 for ; Fri, 04 Nov 2022 11:33:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=cHlujkwLHQA1OWRlitXKA2okTr4nOrBSjZdPzF8hE5c=; b=fYGdM/Tg8Tza7nWYNx1gvE5AjwWtFIuP2aMr7NSPrgUEcKXetw2efj4K9ltVVjew/O hfXJ6HTPJXObLs10g0NdIXaQf1I9XXduYXsuLGv+V9dxSo0TvDryLnn2dlG70bCeTkio Mvw0wCqrgxfpNUxlYb3257rRnrsy7wsaQJrD0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=cHlujkwLHQA1OWRlitXKA2okTr4nOrBSjZdPzF8hE5c=; b=dsRmLGlPerxVZT5mbDzeVJvOdGyok970hQs4mOfIHtqXqGUBD4kYtADjFT8IQ37w8n vcc1tE6V1eMj74k4FC9xiT4fWdyePsdyuEbf23gsYJA06Onip12PO6NIevroBgmq15p/ CLWgdAdlwoPvvQsZk7DRyUdaeuEruvagRIgDgH9t/jsGkumALewAtbPhYJnz0d9FSE9O GwqMXQjSkX3Pp1yHHEywEOQcGKm3pW6iwwfNU+WfzDDJbVM3cJWPkvr8se42iw5GxjUI TEOmxfnG1Phfwa04udV5VXdPcnZB+HYPvgfoTO28x075Mv0qqqAFBr6Xc2VoVeBzk5pD AWow== X-Gm-Message-State: ACrzQf3/It6vGMVkjuWaZ6Ptt6S+RLwG7BvdVNNQLEbQX6hViMpm6jWm v9Ny+OTh2616XWNoehdcZ21/LA== X-Received: by 2002:a63:c65:0:b0:470:cb4:aca3 with SMTP id 37-20020a630c65000000b004700cb4aca3mr11424330pgm.389.1667586835979; Fri, 04 Nov 2022 11:33:55 -0700 (PDT) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id g8-20020a17090a640800b00205fafa6768sm1990807pjj.6.2022.11.04.11.33.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Nov 2022 11:33:55 -0700 (PDT) Date: Fri, 4 Nov 2022 11:33:54 -0700 From: Kees Cook To: Evan Green Cc: linux-kernel@vger.kernel.org, corbet@lwn.net, linux-pm@vger.kernel.org, rjw@rjwysocki.net, gwendal@chromium.org, apronin@chromium.org, Pavel Machek , Matthew Garrett , linux-integrity@vger.kernel.org, jejb@linux.ibm.com, zohar@linux.ibm.com, dlunev@google.com, Eric Biggers , Ben Boeckel , jarkko@kernel.org, David Howells , James Morris , Paul Moore , "Serge E. Hallyn" , keyrings@vger.kernel.org, linux-security-module@vger.kernel.org Subject: Re: [PATCH v4 04/11] security: keys: trusted: Include TPM2 creation data Message-ID: <202211041132.E8CB636@keescook> References: <20221103180120.752659-1-evgreen@chromium.org> <20221103105558.v4.4.Ieb1215f598bc9df56b0e29e5977eae4fcca25e15@changeid> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20221103105558.v4.4.Ieb1215f598bc9df56b0e29e5977eae4fcca25e15@changeid> X-Spam-Status: No, score=-3.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS 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 Thu, Nov 03, 2022 at 11:01:12AM -0700, Evan Green wrote: > In addition to the private key and public key, the TPM2_Create > command may also return creation data, a creation hash, and a creation > ticket. These fields allow the TPM to attest to the contents of a > specified set of PCRs at the time the trusted key was created. Encrypted > hibernation will use this to ensure that PCRs settable only by the > kernel were set properly at the time of creation, indicating this is an > authentic hibernate key. > > Encode these additional parameters into the ASN.1 created to represent > the key blob. The new fields are made optional so that they don't bloat > key blobs which don't need them, and to ensure interoperability with > old blobs. > > Signed-off-by: Evan Green There's a lot of open-coded math for the bounds checking. I didn't immediately see any problems, but it'd be nice if there was a way to hook a fuzzer up to this, or at least write some KUnit tests to check boundary conditions explicitly. Reviewed-by: Kees Cook -- Kees Cook