Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1pfY1X-0004GY-If for mharc-grub-devel@gnu.org; Thu, 23 Mar 2023 23:23:27 -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 1pfY1Q-0004GN-IG for grub-devel@gnu.org; Thu, 23 Mar 2023 23:23:20 -0400 Received: from mail-yb1-xb2e.google.com ([2607:f8b0:4864:20::b2e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pfY1C-0006Nl-5i for grub-devel@gnu.org; Thu, 23 Mar 2023 23:23:20 -0400 Received: by mail-yb1-xb2e.google.com with SMTP id p203so666708ybb.13 for ; Thu, 23 Mar 2023 20:22:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=efficientek-com.20210112.gappssmtp.com; s=20210112; t=1679628172; 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=ud4LuNHTe0AWrBPhBO4pivzRi5J5Emf+axAr6iCw0cw=; b=o2WsEbs4/86ju7AecTeVXFn3RkXjn141I/FWSGMQ1eF/b6I52eJtxZ8Cv/VtnP6VFp 8u2xLHSdd2sUbi4C0o7yfKV1NONOhkFOo1oyqltOlqQ8hHd3CpK0t+D5uAOdgah1h/H4 VKpnIacQBG1fiYX1mnFqPZpFzb2XDtUm38PJBxKJxh0hTP5Dunwx29YDrvyfeb4Gwla3 m2vy4QhSPtQnv5j5AxUZhMlIbaEKVNdi9Zuvz8o1O6zepZT1QNxQcrl9pkH33dSIu6dv a/OO0I1rETE9KwjlrGt/M1vtHHRm1OQ0wuMuXTGao9z3GEjdXNUUQXDnxAyUZbJvRN2Q Gw1w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679628172; 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=ud4LuNHTe0AWrBPhBO4pivzRi5J5Emf+axAr6iCw0cw=; b=35Pk8zIgE5kCQSQoH/ykLz886YxxUxVL+x+Q3NayBfh8avgS+IwLKtl2Aan+A5DRPz d8rWs3UI+4WWYuosTEZj/qeWthem7oOw7G8OH+gJ9NJBvRPhKK/f86DccAFA7USdXSmM MJPm4BJdhf7CaG/bnhjwUFhckVEBWfuK7W5XfS3MXCQarPwCNb5mX3RtjkQIA3fKSt6g SuPthJICXocsHxol0WVoDyyZhakpxEtA43dSpSHuH/+d+cyCglmX3SJFauerm1eYhnVS h3OgipcYqomMc6cWrYskIUTYU4Qs4GWte/J7hVgh+gIgsucG2Ygw5U2cEvOlJCQvGKeV 9m9A== X-Gm-Message-State: AAQBX9for3t3JhLUGDMXSAQfVPlHA2+EAh9MaZ3pMX7Ydj5RBk8nTCbc z43R5rK4D5OUU0vUa6mURhXlSw== X-Google-Smtp-Source: AKy350YjgJnm9DwkI1LeZAJM/HKi9tz1GI3WiyesXT1L/Jc1X1RDfKHYgGkBTGudmyL/dyf2LYIB5A== X-Received: by 2002:a25:404a:0:b0:b73:225f:6534 with SMTP id n71-20020a25404a000000b00b73225f6534mr908694yba.26.1679628167219; Thu, 23 Mar 2023 20:22:47 -0700 (PDT) Received: from [10.41.0.197] ([37.218.244.251]) by smtp.gmail.com with ESMTPSA id 194-20020a2505cb000000b00b7767ca7474sm216460ybf.17.2023.03.23.20.22.44 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 23 Mar 2023 20:22:46 -0700 (PDT) Message-ID: <4bf7657c-5a69-e08b-7abc-f4a76e8f640e@efficientek.com> Date: Fri, 24 Mar 2023 03:22:43 +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 , The development of GNU GRUB Cc: 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> From: Glenn Washburn In-Reply-To: <20230322081016.12075-1-glin@suse.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Received-SPF: pass client-ip=2607:f8b0:4864:20::b2e; envelope-from=development@efficientek.com; helo=mail-yb1-xb2e.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 03:23:20 -0000 Hi Gary, 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). 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". 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]. > > 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. > - 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. 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 >