Received: from list by lists.gnu.org with archive (Exim 4.71) id 1fftEZ-0005uj-1Q for mharc-grub-devel@gnu.org; Wed, 18 Jul 2018 16:39:39 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57556) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fftEW-0005lu-8m for grub-devel@gnu.org; Wed, 18 Jul 2018 16:39:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fftET-0004E9-0x for grub-devel@gnu.org; Wed, 18 Jul 2018 16:39:36 -0400 Received: from mail-qt0-x243.google.com ([2607:f8b0:400d:c0d::243]:40756) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fftES-0004Dq-Pa for grub-devel@gnu.org; Wed, 18 Jul 2018 16:39:32 -0400 Received: by mail-qt0-x243.google.com with SMTP id h4-v6so5307327qtj.7 for ; Wed, 18 Jul 2018 13:39:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=TVni54HbQJa4XSXlvy8sS0z/fgTXXZJrA+4+PtoaECo=; b=kXkKdWePV16F3KrGikF12lXCsbNw/kuGOILKgBG7/YoaZjw6ykUE7mfIBdqqo6VE3K YzFuMQtcZTfRwyHcIxG8IvoGJuK8Y0thkR5Jgqgmku95XNYdTSWUk+s+Oi0OWuWN8EKW fPaN/UpfE+fV5ufOye9QuJDP6l7eN5XV/u5CzRZQ118AVRyqtjPMze9C1eRnF8FTy+MK fdau2q6xSzbp4Av0S6kSywwosSp+96A5+VY+G7P8FLE1Mggo0H+LLQ0fMdcxajncqzyW NF5WTu7m0ipMvuQqv9C1nq/RKyng3Q+zG/l4UG+VMXIFZbU7YDh32sJtN87/910CZtwZ 5wcA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=TVni54HbQJa4XSXlvy8sS0z/fgTXXZJrA+4+PtoaECo=; b=ZgQ0F+GAEDf4gbjimMqjIue7QWjxJuvR0GIT3qiJph8MYWAOEZ4wIea1IkPftwLwN+ lyw8cdcI2xwAGTh+Haq7KrzZaTxxmk/rF8t/gubIa7NdnmC2RPn580ytYGFkth2DYmUU VfVZTAFgiiM2xtRd7j78ZS7/4gusP5WB5TQmuP8HTl2PM/cyW/HZ/Tn1qAF3kcyap2jE s5tvJzVMcjjdOuwb09N9Ze22PrIzrS+XdjUB6miZANokhLphyvgziEl05qFL5ZuVUaUl MonJVY1hcjfIUAnPaER0DRZYbckgEq86ehG12BhJRaUKtGaIu7z5Me4UzK+kkVGNUJKR 5Fqw== X-Gm-Message-State: AOUpUlF93ySGMrwzlVpJfw1PuBJIf9wUFeATOlKJ2s0RcPe81SkUduih D263v3O1dNPINHAh/aJ7wD9jpQ7G X-Google-Smtp-Source: AAOMgpdiguzuOLeueojBFxlDQF5XZQQUvOBluinxRQvt1N73OfVOAlr3D+CumfnjXaYKjxgoFgO5RA== X-Received: by 2002:ac8:6c3:: with SMTP id j3-v6mr7216005qth.138.1531946372091; Wed, 18 Jul 2018 13:39:32 -0700 (PDT) Received: from [10.10.1.4] (c-73-201-91-123.hsd1.de.comcast.net. [73.201.91.123]) by smtp.gmail.com with ESMTPSA id o124-v6sm2317415qkd.61.2018.07.18.13.39.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 18 Jul 2018 13:39:31 -0700 (PDT) Subject: Re: TPM support within Grub2 To: Javier Martinez Canillas , Philip Tricca , Daniel Kiper Cc: daniel.kiper@oracle.com, eric.snowberg@oracle.com, jonmccune@google.com, kanth.ghatraju@oracle.com, keng-yu.lin@hpe.com, konrad.wilk@oracle.com, leif.lindholm@linaro.org, mjg59@srcf.ucam.org, phcoder@gmail.com, ross.philipson@oracle.com, grub-devel@gnu.org References: <20180702163508.GC1111@router-fw-old.local.net-space.pl> <20180716120612.GA12081@router-fw-old.local.net-space.pl> <20180717165756.GA19516@intel.com> From: "Daniel P. Smith" Message-ID: <1fcb038b-7f23-0aa6-558c-947b44fc1d7c@gmail.com> Date: Wed, 18 Jul 2018 16:39:09 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400d:c0d::243 X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 18 Jul 2018 20:39:37 -0000 On 07/18/2018 12:27 PM, Javier Martinez Canillas wrote: > On 07/17/2018 06:57 PM, Philip Tricca wrote: >> On Mon, Jul 16, 2018 at 02:06:12PM +0200, Daniel Kiper wrote: >>> On Mon, Jul 02, 2018 at 06:35:08PM +0200, Daniel Kiper wrote: >>>> Hi Daniel, >>>> >>>> On Sun, Jul 01, 2018 at 07:09:30PM -0400, Daniel P. Smith wrote: >>>>> Greetings, >>>>> >>>>> I have a measured boot implementation I have been working on that >>>>> introduces a DRTM relocator that I would like to eventually upstream. >>>>> This work does rely on the ability to access a TPM 1.2 chip from within >>>>> Grub2. I am aware of Matthew Garrett's pending patch to add core TPM >>>>> support[1] but that is limited to UEFI environments. My target >>>>> environment uses Coreboot with the TCG BIOS payload to launch the >>>>> environment. For TPM support I am using code picked out of the >>>>> TrustedGRUB2 fork[2]. As a precursor to upstreaming my DRTM relocator, I >>>>> would like to see if I could find a way to generically introduce TPM >>>>> support into Grub2 that support's Matthew's UEFI backend, TrustedGrub2's >>>>> TPM 1.2 raw I/O, as well as leave a path for TPM2 raw I/O. In both >>>>> implementations TPM support is include as an x86 device when in fact >>>>> they can also be found in ARM devices, which is on my wish list of >>>>> future devices I would like to support. With all of this in mind, I >>>>> wanted to open a discussion on the best way to implement generic TPM >>>>> support. In Matthew's approach TPM is implemented under >>>>> grub-core/commands while TrustedGRUB2 is split between grub-core/kern >>>>> and grub-core/tpm. IMHO TPM functionality should be divided into HW >>>>> interfaces, TPM command processing, and higher order TPM operations. If >>>>> the logic was segmented in this manner, what are other's opinions on >>>>> where segments of logic should reside within the Grub2 source tree? >>>>> >>>>> >>>>> [1] http://lists.gnu.org/archive/html/grub-devel/2017-07/msg00005.html >>>>> [2] https://github.com/Rohde-Schwarz-Cybersecurity/TrustedGRUB2 >>> >>> In general I am not against reorganization you are mentioning above. >>> Though I think that then you should rearange Matthew code and repost >>> it. Of course if Matthew does not object. >>> >>> Another thing is the verifiers framework. It would be nice if you could >>> hook your work there. Though you have to remember about other users like >>> UEFI secure boot (https://lists.xen.org/archives/html/xen-devel/2017-07/msg00985.html; >>> I am going to revive work on this patch) or GPG signatures. So, please >>> take a look at that code at git://git.savannah.gnu.org/grub.git, >>> phcoder/verifiers branch. If it works for you I will post the patches, >>> with minor fixes and improvements which are worth doing, for review (of >>> course if Vladimir does not object). If you discover any issues with the >>> verifiers framework just drop me a line and then we will try to fix them. >>> >>> And another thing... Could not we reuse Philip TPM 2.0 work in GRUB2 somehow? >> >> It's possible to use at least one of the APIs we've been developing in >> Grub2 but I'm not sure the patches under review require this. It's been >> a year now since I've reviewed these patches but AFAIK they don't >> require any TPM2 functions beyond what the UEFI TrEE protocol exposes. >> > > That's correct. > >> I have had a few people ask about combining Grub2s support for LUKS >> volumes with the key usage policy from the TPM2 as a way to ensure the >> integrity of the firmware before releasing a key used to decrypt the >> LUKS volume. In this case using some of the APIs / libraries we've been >> developing (https://github.com/tpm2-software/tpm2-tss) would make sense >> since the TrEE protocol doesn't expose any of the interfaces we would >> require: key creation & loading, policy sessions etc. >> >> There would be a small amout of development work to implement an adapter >> to sit between the tss2-sys library and the TrEE 'SubmitCommand' >> function though. We have a standard API for this and have used it as the >> basis for our support on Linux and Windows so I don't expect a UEFI >> implementation to be much work if it becomes necessary. I do not however >> believe this is required for the work under review. >> > > I wonder if we want something like the System API in GRUB2 or just a set of > TPM2 commands implemented using the EFI_TCG2_SUBMIT_COMMAND as you said. Is > what Microsoft is doing in its lsvmload [0] to implement its Shielded VM [1]. For me the issue is that I am working in coreboot environments where UEFI is not present. Second, until OEM's stop including the kitchen sink in their UEFI builds, I hold UEFI suspect and would like to reduce the chance that it can interfere with my interactions with the TPM. So when I get to TPM2, I will likely be looking to just do the I/O operations and marshaling directly. This is getting to what I was suggesting in the initial email that layer the abstractions so efi kernel can use TrEE by default and for either override or for non-efi have the i386 kernel handle raw I/O. Then a tpm lib or command module can expose TPM operations that things like LUKS or TrenchBoot can leverage. > The lsvmload is an EFI binary that's executed before the boot-loader and it > is used just to unseal a key to unlock an encrypted partition where the real > boot-loader is stored. > > [0]: https://github.com/Microsoft/lsvmtools/blob/master/lsvmutils/tpm2.c > [1]: https://events.static.linuxfound.org/sites/events/files/slides/LinuxCon%20Mike%20Brasher.pdf > > Something like this can also be built on top of Matthew's current patch-set. > >> Regards, >> Philip >> > > Best regards, >