Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1pfl3L-0001QU-SQ for mharc-grub-devel@gnu.org; Fri, 24 Mar 2023 13:18:11 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pfl3J-0001QE-5t for grub-devel@gnu.org; Fri, 24 Mar 2023 13:18:09 -0400 Received: from mail-yb1-xb2f.google.com ([2607:f8b0:4864:20::b2f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pfl3F-00035E-QU for grub-devel@gnu.org; Fri, 24 Mar 2023 13:18:08 -0400 Received: by mail-yb1-xb2f.google.com with SMTP id e65so3033456ybh.10 for ; Fri, 24 Mar 2023 10:18:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=efficientek-com.20210112.gappssmtp.com; s=20210112; t=1679678283; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=YPaRUzhb+4OeOF9E64knGmQOgVZvdGWkjglPISJRYfE=; b=oGBiMkg0gF7UOIr1opaCK7tQJEBl03LsUHlaeejnyrWD7rmHyumGMBIVy94F23ZaEG P1xFX8ZEaqte6zyIr7bi5re2LiqvO+/L7IhpcdoYxFYNU2cXG5j7GTp2RqQtWRQgtj3Z adGlNm7bqEUK4LHa2evTuIR3PrEdX4vTNl3NiQ0eyAOdWPzi4lnFCh1HU/OXrfbe7Ss6 0q0yF1ZhJHALOaaT6XX7d7QhFN2CFd4Nv/jA4T6pO3tUJq1XprzTIrYnY/7CbG4UEHAN YLjyfRdaHGKMOOW+HRr9Le28pDhLxQUJNDe1/D9oXnfRzWT6OY+59qWR5fe09qiA2ODR FsBA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679678283; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=YPaRUzhb+4OeOF9E64knGmQOgVZvdGWkjglPISJRYfE=; b=z4yYqXZHuUt7FMh+UF1qq9bHCHRW2fzgKSEsjez+I7XEQzpi6af0K/VeW6Kym+tiwt jbtvK2aGEKiSdxHs4RrSpcpiNqg1c+AxhyjnX7Zlws5RZ8LMCikkGW7ZWHu5zKDbyHbU y+9aUYdrLX4yMXq49mAf7PuTiYM4R1c9Gc67bVaLL4ZrchSKNaFfb4owrrDguOH+DZzc eASgeIHbzR7g+AJfy5xHPvZ2Cxz0yfHyDf425DXGaJ88No+iuqRfTwLRUMAWnzKXWoxv qamBlgD97HZT3m4hojGgpH63LgYDZE5a1a6OCX9u+x2WKstRepOxu9VqY3MuwgYjfQJf eY3Q== X-Gm-Message-State: AAQBX9f5ndP8TefN7qZkWq1XOPF343U76s1UqS9Ko+ihbHZSvS11PJRv xYikJR9/onslVXm1MIp5PFIdKw== X-Google-Smtp-Source: AKy350bMZVqC5HO24HLDJngULKzBqEmgCrrGTeQPPNrBaAg4kYmK50kvrQfp/sDZEz4ZEc8hGytqvA== X-Received: by 2002:a25:582:0:b0:b47:1ab4:6b16 with SMTP id 124-20020a250582000000b00b471ab46b16mr2788781ybf.18.1679678281853; Fri, 24 Mar 2023 10:18:01 -0700 (PDT) Received: from [10.41.0.197] ([37.218.244.251]) by smtp.gmail.com with ESMTPSA id d205-20020a25e6d6000000b00b7767ca7463sm558354ybh.0.2023.03.24.10.17.59 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 24 Mar 2023 10:18:01 -0700 (PDT) Message-ID: <7a972a1c-bc10-6ac6-002c-4bc5378cba77@efficientek.com> Date: Fri, 24 Mar 2023 17:17:58 +0000 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.8.0 Subject: Re: [PATCH v2 00/11] Automatic Disk Unlock with TPM2 Content-Language: en-US To: Gary Lin Cc: The development of GNU GRUB , Hernan Gatta , Daniel Axtens , 'Daniel Kiper ' , shkhisti@microsoft.com, jaskaran.khurana@microsoft.com, christopher.co@microsoft.com, daniel.mihai@microsoft.com, rharwood@redhat.com, jaredz@redhat.com, jejb@linux.ibm.com, mchang@suse.com References: <20230322081016.12075-1-glin@suse.com> <4bf7657c-5a69-e08b-7abc-f4a76e8f640e@efficientek.com> <20230324090621.e7mc6x3ydo5btmvm@GaryLaptop> From: Glenn Washburn In-Reply-To: <20230324090621.e7mc6x3ydo5btmvm@GaryLaptop> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Received-SPF: pass client-ip=2607:f8b0:4864:20::b2f; envelope-from=development@efficientek.com; helo=mail-yb1-xb2f.google.com X-Spam_score_int: 14 X-Spam_score: 1.4 X-Spam_bar: + X-Spam_report: (1.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, NICE_REPLY_A=-0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_SBL_CSS=3.335, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 24 Mar 2023 17:18:09 -0000 On 3/24/23 09:06, Gary Lin wrote: > On Fri, Mar 24, 2023 at 03:22:43AM +0000, Glenn Washburn wrote: >> Hi Gary, >> > Hi Glenn, > >> Usually a v2 series will also include what changed from v1 -> v2 and >> subsequent versions will keep the changelog. Also, for such a large series, >> using --range-diff with git format-patch can be helpful for reviewers (it >> will include here the exact changes to each patch from the last version of >> the series). >> > The difference between v1 and v2 is a bit huge. libtasn1 was added, > several follow-up patches in v1 are merged into Hernan's patches. Not to > mention the newly implemented TPM 2.0 Key. It made me feel that v2 is > more like a fresh start. > >> On 3/22/23 08:10, Gary Lin wrote: >>> This patch series is based on "Automatic TPM Disk Unlock"(*1) posted by >>> Hernan Gatta to introduce the key protector framework and TPM2 stack >>> to GRUB2, and this could be a useful feature for the systems to >>> implement full disk encryption. >>> >>> To support TPM 2.0 Key File format(*2), patch 1~6 are grabbed from >>> Daniel Axtens's "appended signature secure boot support" (*3) to import >>> libtasn1 into grub2. Besides, the libtasn1 version is upgraded to >>> 4.19.0 instead of 4.16.0 in the original patch. >> >> How was the upgrade process? Were there any gotchas? Regardless when >> including new external libraries the update process should be included in >> docs/grub-dev.texi under the section "Updating External Code". >> > I followed the steps in the comment of Patch 2 to upgrade the lib. Will > check how to write the steps into the document. > >> Similarly, I am not in favor of including this new user functionality >> without properly documenting it in docs/grub.texi. >> >> Also, and I know this is a longshot, but it would be great to add tests for >> the protector and TPM code. Probably the easiest option would be to create >> non-native (ie QEMU) make check tests. QEMU can use an emulated software >> TPM[1]. >> > Sure, I mainly tested the code with QEMU + swtpm. Great, so sounds like you have a good idea how things need to be setup, that's a large part of making the test. > >>> >>> Patch 7~11 are Hernan Gatta's patches with the follow-up fixes: >>> - Converting 8 spaces into 1 tab >> >> This is good. However, I noticed that there are places in the patch >> "cryptodisk: Support key protectors" where this did not happen. I've not >> checked other patches. I'll note a specific instance in a reply to that >> patch. >> > I probably overlooked cryptodisk.c. Will check all affect files again. > >>> - Merging the minor build fix from Michael Chang >>> - Replacing "lu" with "PRIuGRUB_SIZE" for grub_dprintf >>> - Adding "enable = efi" to the tpm2 module in grub-core/Makefile.core.def >>> - Rebasing "cryptodisk: Support key protectors" to the git master >>> - Removing the measurement on the sealed key >>> - Based ont the patch from Olaf Kirch >>> - Adjusting the input parameters of TPM2_EvictControl to match the order >>> in "TCG TPM2 Part3 Commands" >>> - Declaring the input arguments of TPM2 functions as const >>> - Resending TPM2 commands on TPM_RC_RETRY >>> - Adding checks for the parameters of TPM2 commands >>> - Packing the missing authorization command for TPM2_PCR_Read >>> - Tweaking the TPM2 command functions to allow some parameters to be >>> NULL >>> - Only enabling grub-protect for "efi" since the TPM2 stack currently >>> relies on the EFI TCG2 protocol to send TPM2 commands >>> - Using grub_cpu_to_be*() in the TPM2 stack instead grub_swap_bytes*() >>> for the marshal functions >>> - Changing the short name of "--protector" of "cryptomount" from "-k" to >>> "-P" to avoid the conflict with "--key-file" >>> - Adding the primitive support for TPM 2.0 Key File Format besides the >>> raw sealed key >>> - Adding the external libtasn1 dependency for grub-protect since >>> "asn1_write_value()" is disabled in the embedded libtasn1 >>> >>> To utilize the TPM2 key protector to unlock the encrypted partition >>> (sdb1), here are the sample steps: >>> >>> 1. Add an extra random key for LUKS (luks-key) >>> $ dd if=/dev/urandom of=luks-key bs=1 count=32 >>> $ sudo cryptsetup luksAddKey /dev/sdb1 luks-key --pbkdf=pbkdf2 >>> >>> 2. Seal the key >>> $ sudo grub-protect --action=add \ >>> --protector=tpm2 \ >>> --tpm2key \ >>> --tpm2-keyfile=luks-key \ >>> --tpm2-outfile=/boot/efi/boot/grub2/sealed.tpm >>> >>> 3. Unseal the key with the proper commands in grub.cfg: >>> tpm2_key_protector_init --tpm2key=(hd0,gpt1)/boot/grub2/sealed.tpm >>> cryptomount -u SDB1_UUID -P tpm2 >> >> This is great, but as I'm sure you know this won't appear in the commit log >> and as far as I can tell is not documented anywhere else. This would be nice >> to add to the user documentation. >> > The similar steps are also mentioned in the comment of Patch 11. Those > steps give the overview of what these patches do, so I want them in the > cover letter. Great, I hadn't checked patch 11. And its more detailed there, so even better. > Since this patchset introduces several new things, before we reach the > consensus on the implementation, arguments, etc., I'd like to defer the > user documentation work. Yep, completely agree, my comment was meant to put/keep the documentation on the radar (lest it be forgot). Glenn > > Thanks, > > Gary Lin > >> Glenn >> >> [1] https://qemu.readthedocs.io/en/latest/specs/tpm.html#the-qemu-tpm-emulator-device >> >>> >>> (*1) https://lists.gnu.org/archive/html/grub-devel/2022-02/msg00006.html >>> (*2) https://www.hansenpartnership.com/draft-bottomley-tpm2-keys.html >>> (*3) https://lists.gnu.org/archive/html/grub-devel/2021-06/msg00044.html >>> >>> Daniel Axtens (6): >>> posix_wrap: tweaks in preparation for libtasn1 >>> libtasn1: import libtasn1-4.19.0 >>> libtasn1: disable code not needed in grub >>> libtasn1: changes for grub compatibility >>> libtasn1: compile into asn1 module >>> test_asn1: test module for libtasn1 >>> >>> Hernan Gatta (5): >>> protectors: Add key protectors framework >>> tpm2: Add TPM Software Stack (TSS) >>> protectors: Add TPM2 Key Protector >>> cryptodisk: Support key protectors >>> util/grub-protect: Add new tool >>> >>> .gitignore | 2 + >>> Makefile.util.def | 29 + >>> configure.ac | 9 + >>> grub-core/Makefile.am | 1 + >>> grub-core/Makefile.core.def | 42 + >>> grub-core/disk/cryptodisk.c | 175 +- >>> grub-core/kern/protectors.c | 75 + >>> grub-core/lib/libtasn1/COPYING | 16 + >>> grub-core/lib/libtasn1/README.md | 98 + >>> grub-core/lib/libtasn1/lib/coding.c | 1433 ++++++++++ >>> grub-core/lib/libtasn1/lib/decoding.c | 2504 +++++++++++++++++ >>> grub-core/lib/libtasn1/lib/element.c | 1110 ++++++++ >>> grub-core/lib/libtasn1/lib/element.h | 42 + >>> grub-core/lib/libtasn1/lib/errors.c | 103 + >>> grub-core/lib/libtasn1/lib/gstr.c | 74 + >>> grub-core/lib/libtasn1/lib/gstr.h | 50 + >>> grub-core/lib/libtasn1/lib/int.h | 221 ++ >>> grub-core/lib/libtasn1/lib/parser_aux.c | 1179 ++++++++ >>> grub-core/lib/libtasn1/lib/parser_aux.h | 172 ++ >>> grub-core/lib/libtasn1/lib/structure.c | 1227 ++++++++ >>> grub-core/lib/libtasn1/lib/structure.h | 46 + >>> .../tests/CVE-2018-1000654-1_asn1_tab.h | 32 + >>> .../tests/CVE-2018-1000654-2_asn1_tab.h | 36 + >>> .../libtasn1_wrap/tests/CVE-2018-1000654.c | 61 + >>> .../lib/libtasn1_wrap/tests/Test_overflow.c | 138 + >>> .../lib/libtasn1_wrap/tests/Test_simple.c | 207 ++ >>> .../lib/libtasn1_wrap/tests/Test_strings.c | 150 + >>> .../libtasn1_wrap/tests/object-id-decoding.c | 116 + >>> .../libtasn1_wrap/tests/object-id-encoding.c | 120 + >>> .../lib/libtasn1_wrap/tests/octet-string.c | 211 ++ >>> .../lib/libtasn1_wrap/tests/reproducers.c | 81 + >>> grub-core/lib/libtasn1_wrap/wrap.c | 26 + >>> grub-core/lib/libtasn1_wrap/wrap_tests.c | 75 + >>> grub-core/lib/libtasn1_wrap/wrap_tests.h | 38 + >>> grub-core/lib/posix_wrap/limits.h | 1 + >>> grub-core/lib/posix_wrap/stdlib.h | 8 + >>> grub-core/lib/posix_wrap/sys/types.h | 1 + >>> grub-core/tpm2/args.c | 129 + >>> grub-core/tpm2/buffer.c | 145 + >>> grub-core/tpm2/module.c | 833 ++++++ >>> grub-core/tpm2/mu.c | 807 ++++++ >>> grub-core/tpm2/tcg2.c | 143 + >>> grub-core/tpm2/tpm2.c | 761 +++++ >>> grub-core/tpm2/tpm2key.asn | 31 + >>> grub-core/tpm2/tpm2key.c | 218 ++ >>> grub-core/tpm2/tpm2key_asn1_tab.c | 34 + >>> include/grub/cryptodisk.h | 14 + >>> include/grub/libtasn1.h | 645 +++++ >>> include/grub/protector.h | 48 + >>> include/grub/tpm2/buffer.h | 65 + >>> include/grub/tpm2/internal/args.h | 39 + >>> include/grub/tpm2/internal/functions.h | 117 + >>> include/grub/tpm2/internal/structs.h | 675 +++++ >>> include/grub/tpm2/internal/types.h | 372 +++ >>> include/grub/tpm2/mu.h | 292 ++ >>> include/grub/tpm2/tcg2.h | 34 + >>> include/grub/tpm2/tpm2.h | 38 + >>> include/grub/tpm2/tpm2key.h | 40 + >>> tests/test_asn1.in | 12 + >>> util/grub-protect.c | 1472 ++++++++++ >>> 60 files changed, 16841 insertions(+), 32 deletions(-) >>> create mode 100644 grub-core/kern/protectors.c >>> create mode 100644 grub-core/lib/libtasn1/COPYING >>> create mode 100644 grub-core/lib/libtasn1/README.md >>> create mode 100644 grub-core/lib/libtasn1/lib/coding.c >>> create mode 100644 grub-core/lib/libtasn1/lib/decoding.c >>> create mode 100644 grub-core/lib/libtasn1/lib/element.c >>> create mode 100644 grub-core/lib/libtasn1/lib/element.h >>> create mode 100644 grub-core/lib/libtasn1/lib/errors.c >>> create mode 100644 grub-core/lib/libtasn1/lib/gstr.c >>> create mode 100644 grub-core/lib/libtasn1/lib/gstr.h >>> create mode 100644 grub-core/lib/libtasn1/lib/int.h >>> create mode 100644 grub-core/lib/libtasn1/lib/parser_aux.c >>> create mode 100644 grub-core/lib/libtasn1/lib/parser_aux.h >>> create mode 100644 grub-core/lib/libtasn1/lib/structure.c >>> create mode 100644 grub-core/lib/libtasn1/lib/structure.h >>> create mode 100644 grub-core/lib/libtasn1_wrap/tests/CVE-2018-1000654-1_asn1_tab.h >>> create mode 100644 grub-core/lib/libtasn1_wrap/tests/CVE-2018-1000654-2_asn1_tab.h >>> create mode 100644 grub-core/lib/libtasn1_wrap/tests/CVE-2018-1000654.c >>> create mode 100644 grub-core/lib/libtasn1_wrap/tests/Test_overflow.c >>> create mode 100644 grub-core/lib/libtasn1_wrap/tests/Test_simple.c >>> create mode 100644 grub-core/lib/libtasn1_wrap/tests/Test_strings.c >>> create mode 100644 grub-core/lib/libtasn1_wrap/tests/object-id-decoding.c >>> create mode 100644 grub-core/lib/libtasn1_wrap/tests/object-id-encoding.c >>> create mode 100644 grub-core/lib/libtasn1_wrap/tests/octet-string.c >>> create mode 100644 grub-core/lib/libtasn1_wrap/tests/reproducers.c >>> create mode 100644 grub-core/lib/libtasn1_wrap/wrap.c >>> create mode 100644 grub-core/lib/libtasn1_wrap/wrap_tests.c >>> create mode 100644 grub-core/lib/libtasn1_wrap/wrap_tests.h >>> create mode 100644 grub-core/tpm2/args.c >>> create mode 100644 grub-core/tpm2/buffer.c >>> create mode 100644 grub-core/tpm2/module.c >>> create mode 100644 grub-core/tpm2/mu.c >>> create mode 100644 grub-core/tpm2/tcg2.c >>> create mode 100644 grub-core/tpm2/tpm2.c >>> create mode 100644 grub-core/tpm2/tpm2key.asn >>> create mode 100644 grub-core/tpm2/tpm2key.c >>> create mode 100644 grub-core/tpm2/tpm2key_asn1_tab.c >>> create mode 100644 include/grub/libtasn1.h >>> create mode 100644 include/grub/protector.h >>> create mode 100644 include/grub/tpm2/buffer.h >>> create mode 100644 include/grub/tpm2/internal/args.h >>> create mode 100644 include/grub/tpm2/internal/functions.h >>> create mode 100644 include/grub/tpm2/internal/structs.h >>> create mode 100644 include/grub/tpm2/internal/types.h >>> create mode 100644 include/grub/tpm2/mu.h >>> create mode 100644 include/grub/tpm2/tcg2.h >>> create mode 100644 include/grub/tpm2/tpm2.h >>> create mode 100644 include/grub/tpm2/tpm2key.h >>> create mode 100644 tests/test_asn1.in >>> create mode 100644 util/grub-protect.c >>> >>