Received: by 2002:a05:7412:798b:b0:fc:a2b0:25d7 with SMTP id fb11csp304352rdb; Thu, 22 Feb 2024 04:31:04 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCW3LCKKfPfMj+8tDeHRdXPENjkVrT+znkf/qAFivguXJxZ+lLQnrLU7JrfBShENf8YoUWoPOka0Y9tbkin68XMF0LTHcDB1KgEcDNtf8A== X-Google-Smtp-Source: AGHT+IGOuMHT3o6ZMnCvHLfCrpIJ+/VNgGg9lrM/WhO6DgDt36ro+YW4c0SkCqxwX2oCatYWkWq0 X-Received: by 2002:aa7:ca53:0:b0:565:cf:2566 with SMTP id j19-20020aa7ca53000000b0056500cf2566mr2081127edt.12.1708605064020; Thu, 22 Feb 2024 04:31:04 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708605064; cv=pass; d=google.com; s=arc-20160816; b=yOmpcyPe+lV/+5uipsVluElrgJTknBFN15hqNjbVL1MBugXStjvSqf5phFBLOyRQw5 Vxfs1cT4PJd1OVvj4PBbPNYe1PKI6RMG7XsOP28NlOv2vOZEzhEmRorV1xlh9yVeaRFs wyyUBskUWdddF2bhZu+W+dyQfTUzLGvw7jwkPlzdaq4sLggJRA3I4gEloaKhE72F8WrR jpMe1RfO8jM7BUWPksr56Wid7UgvpqJPwWUKV7kny9GWnAqX/SL22xBMmxTuFbMMV1tH iwpP+NOmkQ9zdXG+aujw3oFlyQCY60biaokKul4mL3c7S5VDN2gCWezAwhr2O+cCa/Yd GA6g== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:autocrypt:from:references:cc :to:content-language:subject:user-agent:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:date:message-id :dkim-signature; bh=rtMJTU0KaK69D2gKtHaxXyryfBE+awWVy+sf0VRiX1M=; fh=+sR8oYC1pB2jNmwQUroKfZzYDJFHhuaHUoudQhtyG44=; b=PVikV8QTkHseGKKk8ocXBpfealmoYUCQ2R8Mt3ShyI8j8L4et8PqgHO39hKChSX7np g+dXz6ojzCE/2SKskQNKWIz44dwHOKjUgfEvSLJsHCWi2zdcgkxWwHzwSWUg+DyQa0ar rynNZDtN1Y9WSac2b0V2ZloEbN7qUZk02GTymvvor0f7UJr46SkB6MMqYguqJth7qApK k22upiXe6f8F2VlasJjjfcVmmGC4K/p7xTqdWaV/89OG9TLBdG3m1CfGk5ULDdGbos1n Hrlre0ZmsIJTTyvpGFU4QaDfo1Flv2XDFeNsJLiU3YQT8ZOr+OXoVzgY8jKkgh3D3SyJ +9Pg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@citrix.com header.s=google header.b=nQhAYbvy; arc=pass (i=1 spf=pass spfdomain=cloud.com dkim=pass dkdomain=citrix.com dmarc=pass fromdomain=citrix.com); spf=pass (google.com: domain of linux-crypto+bounces-2252-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-crypto+bounces-2252-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=citrix.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id e4-20020a50fb84000000b005642518ae08si4698089edq.583.2024.02.22.04.31.03 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 04:31:04 -0800 (PST) Received-SPF: pass (google.com: domain of linux-crypto+bounces-2252-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@citrix.com header.s=google header.b=nQhAYbvy; arc=pass (i=1 spf=pass spfdomain=cloud.com dkim=pass dkdomain=citrix.com dmarc=pass fromdomain=citrix.com); spf=pass (google.com: domain of linux-crypto+bounces-2252-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-crypto+bounces-2252-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=citrix.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 9AA4B1F26B0C for ; Thu, 22 Feb 2024 12:31:03 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 093F564CD3; Thu, 22 Feb 2024 12:30:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=citrix.com header.i=@citrix.com header.b="nQhAYbvy" X-Original-To: linux-crypto@vger.kernel.org Received: from mail-ed1-f49.google.com (mail-ed1-f49.google.com [209.85.208.49]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D094E634E3 for ; Thu, 22 Feb 2024 12:30:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.49 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708605055; cv=none; b=OScS+48ZtZtVxwO8pXxP440YzkuJYf7+K9l0LrLunysc6ZzAY3vxOtjkMCCskzfLag2FeNkmhapUeX2hgeSaFe3vCuPZx8lO8S/eMZbxSCliwdAqzHDsXWqvMA3ba409TW7A3GCbkSlU9wNHblUVI5azHXSaqdjBT0ViRgdsW5E= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708605055; c=relaxed/simple; bh=MrBNqlbyxP3DrROkVXIP046XgIKyGSNJYrmBX+jdlDA=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=FyePn9c2qYiS89AeWSVZBNVroRA8gdpk0OW5EDYYi0NRBbrQ9M28TDIgH5UvI7jv57HnMZPgKJ+/wdBPhAirHkllyiBHTH3+MLAiG/Iquv4kkG8U/4Oaky74vbLNOswrRWYEi2kBBS4TxXpinqDk6o+bQxf4NTul6Qm8LdB3qbI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=citrix.com; spf=pass smtp.mailfrom=cloud.com; dkim=pass (1024-bit key) header.d=citrix.com header.i=@citrix.com header.b=nQhAYbvy; arc=none smtp.client-ip=209.85.208.49 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=citrix.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=cloud.com Received: by mail-ed1-f49.google.com with SMTP id 4fb4d7f45d1cf-563ed3d221aso1532527a12.0 for ; Thu, 22 Feb 2024 04:30:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.com; s=google; t=1708605052; x=1709209852; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:autocrypt:from:references:cc :to:content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=rtMJTU0KaK69D2gKtHaxXyryfBE+awWVy+sf0VRiX1M=; b=nQhAYbvyMssdQPiXRiaCoqsyDuAiAs1fFodFrXH7ciLuQDsjQSV0nv5XMpFbHhzT9K d0NRw7Z2AU0dOTm+eufwjNq9yaM1vvSHSl5WSy1RvQ9eMj/le1LMxvRd/POnEbeIOQKb lxVpeoe+AOzKxfaJNaffihJBUAHUUZ5FXrQtY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708605052; x=1709209852; h=content-transfer-encoding:in-reply-to:autocrypt: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=rtMJTU0KaK69D2gKtHaxXyryfBE+awWVy+sf0VRiX1M=; b=MU60kOc4aOxek5Hweym8ygaeFKl8PmTSTE0Hsk7MWs2sVDb6LFK9rMYGSiBr1ztt2V 5ngrhePuzlgg1p+IwBVjWqwqRqHFj+tu+J7jgi7SCfkDL4Abyif5KE5pu62aJeolWm25 K6PQz2QXjkplhNqs+hOfrzQYWOmMKBLRG4tkf+o0AMqGd867AQ1oKyY9pxTmHAJEScu3 BjuhYTQ4O1Mj4fNUmJhqhs8fIsvRZhr2QO51rbglqFvMiU0TWnpQFEMDVrGRFGnCvkUm 9g8NC9Sey/OtsupWsXyW4EQ2cHGUmUI3nctz/G/zXry477FAN1TCDN+iI94sq4sjUzdf wvKA== X-Forwarded-Encrypted: i=1; AJvYcCUq2hNRMn6smF3ju5dCACPg+x+1vDjuTjA/fnItA93xHtEqoie3bpXyARVt2U0Dwr+tkiH8lWaaQtxx1jteHrtH8jP4Mv0V1CAvfZrr X-Gm-Message-State: AOJu0YwHUn8cM1mLq1Q11kJXvHkdv+LfqBAUtwKBUyGzsQ3vg/5OdqPs 9tfGP46FiRJjoIfALZ+oogt2Z+GUjVduQ248PF3W3yaFataI9uxq+FLZ3owzMLc= X-Received: by 2002:a17:906:2b0e:b0:a3e:8bd8:b711 with SMTP id a14-20020a1709062b0e00b00a3e8bd8b711mr1842289ejg.37.1708605052106; Thu, 22 Feb 2024 04:30:52 -0800 (PST) Received: from [10.80.67.149] (default-46-102-197-194.interdsl.co.uk. [46.102.197.194]) by smtp.gmail.com with ESMTPSA id cw4-20020a170907160400b00a3e45fa1c77sm5071178ejd.55.2024.02.22.04.30.51 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 22 Feb 2024 04:30:51 -0800 (PST) Message-ID: <1a8e69a7-89eb-4d36-94d6-0da662d8b72f@citrix.com> Date: Thu, 22 Feb 2024 12:30:50 +0000 Precedence: bulk X-Mailing-List: linux-crypto@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v8 06/15] x86: Add early SHA support for Secure Launch early measurements Content-Language: en-GB To: Ard Biesheuvel , Andrew Cooper Cc: Ross Philipson , linux-kernel@vger.kernel.org, x86@kernel.org, linux-integrity@vger.kernel.org, linux-doc@vger.kernel.org, linux-crypto@vger.kernel.org, kexec@lists.infradead.org, linux-efi@vger.kernel.org, dpsmith@apertussolutions.com, tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, hpa@zytor.com, dave.hansen@linux.intel.com, mjg59@srcf.ucam.org, James.Bottomley@hansenpartnership.com, peterhuewe@gmx.de, jarkko@kernel.org, jgg@ziepe.ca, luto@amacapital.net, nivedita@alum.mit.edu, herbert@gondor.apana.org.au, davem@davemloft.net, kanth.ghatraju@oracle.com, trenchboot-devel@googlegroups.com, Eric Biggers References: <20240214221847.2066632-1-ross.philipson@oracle.com> <20240214221847.2066632-7-ross.philipson@oracle.com> <98ad92bb-ef17-4c15-88ba-252db2a2e738@citrix.com> From: Andrew Cooper Autocrypt: addr=andrew.cooper3@citrix.com; keydata= xsFNBFLhNn8BEADVhE+Hb8i0GV6mihnnr/uiQQdPF8kUoFzCOPXkf7jQ5sLYeJa0cQi6Penp VtiFYznTairnVsN5J+ujSTIb+OlMSJUWV4opS7WVNnxHbFTPYZVQ3erv7NKc2iVizCRZ2Kxn srM1oPXWRic8BIAdYOKOloF2300SL/bIpeD+x7h3w9B/qez7nOin5NzkxgFoaUeIal12pXSR Q354FKFoy6Vh96gc4VRqte3jw8mPuJQpfws+Pb+swvSf/i1q1+1I4jsRQQh2m6OTADHIqg2E ofTYAEh7R5HfPx0EXoEDMdRjOeKn8+vvkAwhviWXTHlG3R1QkbE5M/oywnZ83udJmi+lxjJ5 YhQ5IzomvJ16H0Bq+TLyVLO/VRksp1VR9HxCzItLNCS8PdpYYz5TC204ViycobYU65WMpzWe LFAGn8jSS25XIpqv0Y9k87dLbctKKA14Ifw2kq5OIVu2FuX+3i446JOa2vpCI9GcjCzi3oHV e00bz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4JzW0Bzq/WXY3XMOzUTYApGQpnUpdOmuQSfpV9MQO+/jo7r6yPbxT7CwRS5dcQPzUiuHLK9i nvjREdh84qycnx0/6dDroYhp0DFv4udxuAvt1h4wGwTPRQZerSm4xaYegEFusyhbZrI0U9tJ B8WrhBLXDiYlyJT6zOV2yZFuW47VrLsjYnHwn27hmxTC/7tvG3euCklmkn9Sl9IAKFu29RSo d5bD8kMSCYsTqtTfT6W4A3qHGvIDta3ptLYpIAOD2sY3GYq2nf3Bbzx81wZK14JdDDHUX2Rs 6+ahAA== In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On 22/02/2024 9:34 am, Ard Biesheuvel wrote: > On Thu, 22 Feb 2024 at 04:05, Andrew Cooper wrote: >> On 15/02/2024 8:17 am, Ard Biesheuvel wrote: >>> On Wed, 14 Feb 2024 at 23:31, Ross Philipson wrote: >>>> From: "Daniel P. Smith" >>>> >>>> The SHA algorithms are necessary to measure configuration information into >>>> the TPM as early as possible before using the values. This implementation >>>> uses the established approach of #including the SHA libraries directly in >>>> the code since the compressed kernel is not uncompressed at this point. >>>> >>>> The SHA code here has its origins in the code from the main kernel: >>>> >>>> commit c4d5b9ffa31f ("crypto: sha1 - implement base layer for SHA-1") >>>> >>>> A modified version of this code was introduced to the lib/crypto/sha1.c >>>> to bring it in line with the sha256 code and allow it to be pulled into the >>>> setup kernel in the same manner as sha256 is. >>>> >>>> Signed-off-by: Daniel P. Smith >>>> Signed-off-by: Ross Philipson >>> We have had some discussions about this, and you really need to >>> capture the justification in the commit log for introducing new code >>> that implements an obsolete and broken hashing algorithm. >>> >>> SHA-1 is broken and should no longer be used for anything. Introducing >>> new support for a highly complex boot security feature, and then >>> relying on SHA-1 in the implementation makes this whole effort seem >>> almost futile, *unless* you provide some rock solid reasons here why >>> this is still safe. >>> >>> If the upshot would be that some people are stuck with SHA-1 so they >>> won't be able to use this feature, then I'm not convinced we should >>> obsess over that. >> To be absolutely crystal clear here. >> >> The choice of hash algorithm(s) are determined by the OEM and the >> platform, not by Linux. >> >> Failing to (at least) cap a PCR in a bank which the OEM/platform left >> active is a security vulnerability. It permits the unsealing of secrets >> if an attacker can replay a good set of measurements into an unused bank. >> >> The only way to get rid of the requirement for SHA-1 here is to lobby >> the IHVs/OEMs, or perhaps the TCG, to produce/spec a platform where the >> SHA-1 banks can be disabled. There are no known such platforms in the >> market today, to the best of our knowledge. >> > OK, so mainline Linux does not support secure launch at all today. At > this point, we need to decide whether or not tomorrow's mainline Linux > will support secure launch with SHA1 or without, right? I'd argue that's a slightly unfair characterisation. We want tomorrow's mainline to support Secure Launch.  What that entails under the hood is largely outside of the control of the end user. > And the point you are making here is that we need SHA-1 not only to a) > support systems that are on TPM 1.2 and support nothing else, but also > to b) ensure that crypto agile TPM 2.0 with both SHA-1 and SHA-256 > enabled can be supported in a safe manner, which would involve > measuring some terminating event into the SHA-1 PCRs to ensure they > are not left in a dangling state that might allow an adversary to > trick the TPM into unsealing a secret that it shouldn't. Yes.  Also c) because if the end user wants to use SHA-1, they should be able to. > So can we support b) without a), and if so, does measuring an > arbitrary dummy event into a PCR that is only meant to keep sealed > forever really require a SHA-1 implementation, or could we just use an > arbitrary (not even random) sequence of 160 bits and use that instead? a) and b) are in principle independent, but we cannot support b) without SHA-1. To cap a PCR, the event log still needs to be kept accurate, and that's at least one SHA-1 calculation.  If you were to simply extend a dummy value, the system hopefully fails safe, but the user gets "something went wrong, you're on your own", rather than "we intentionally blocked the use of SHA-1, everything is good". And frankly, you need SHA-1 just to read the event log, if any component (including TXT itself) wrote a SHA-1 entry into it. To be blunt.  SHA-1 support is not viably optional today as far as Secure Launch is concerned.  If there's a suitable Kconfig symbol to use for people who want a completely SHA-1-less kernel, then we can make Secure Launch depend on that until such time as the hardware ecosystem has caught up. ~Andrew