Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp620592ybg; Mon, 1 Jun 2020 09:56:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxhTwke6TMOnpZL5ZwTx0yvYoMa7ujWQhEmG7yf+LrKmtmdwtdqbSFkfjATQx+SC8AhsWd4 X-Received: by 2002:a50:9b13:: with SMTP id o19mr17277971edi.143.1591030587599; Mon, 01 Jun 2020 09:56:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591030587; cv=none; d=google.com; s=arc-20160816; b=Wnr9r2UbcLu3VqWJzow+ReOFnOsn0nFf0/jQzQjm1+sFByoziqqjpOZT5E3J1xKu+i 0YdFk2Oui6kb/OMZFRkfk46A//2ZxxO0pwvQLz/msZ4HZ/YN3LoZVMaaDtusI+rjPlWV UD1YUb2AnASEPHhRnE8IvoMLsJXO/xzUR3DC9VP46KdzI55pXYD+yggntPaEgldsGhGV jU/9KnP/ByN8Pyi/+cdn83qLh3MPNgvxlK4AbaddbKUEOnXQeF1Uayc9szrMYLibv1/m 80iCLYAWved2DRNFCPM83K0BQ+VinM44DPdmd/yzwr0pIgrKvbJEMjWieSXG7kmF0veo 7fPA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=GlHZGAPv0wVvGyDcLDKyYgpH82MbQMkSjAUWTfU5rYc=; b=lqcQ7dQSlG4UdSSv1qTHE69YdLvC8QJxtxW+enyIgJ8r0blb5kR0ozuS/OpV2sBjE2 NP38a41YtuHAbIbDJT5+SSln2nSgUsjvjdde8ZWPJhSsLMtmupj52uNdAbmDg6tdlyYM +EBkUhXdXluZrcHIcjDdeUwi4oOj9siBezevDBdZp7R/sdl68RPL6X36Vo0bVh2Zf57n OJiU1P3eOsl8RtETGeL85LxD5EWXnh3XaH1ITjtAVHpe4tMdutaijyhVV6cjyCj1kypK PvM/r4hbCcLvXVxyz1LTayBao9Xja725ddtswRLtpj4cMktvEtW+9N0AD3Wg5xWrVU6v ClZg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=uXO8ySEx; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id bc15si2064732edb.281.2020.06.01.09.56.04; Mon, 01 Jun 2020 09:56:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=uXO8ySEx; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726218AbgFAQvi (ORCPT + 99 others); Mon, 1 Jun 2020 12:51:38 -0400 Received: from mail.kernel.org ([198.145.29.99]:44610 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726017AbgFAQvi (ORCPT ); Mon, 1 Jun 2020 12:51:38 -0400 Received: from mail-wm1-f43.google.com (mail-wm1-f43.google.com [209.85.128.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 7485A2086A for ; Mon, 1 Jun 2020 16:51:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1591030297; bh=ehIgjqfbBBjxDPUjD2WX+8FA7eGuKdelQD+KI1hrAg0=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=uXO8ySExjM2Fo4MQ6Xeg5b01OrE4WYgaXZuCMxO9s/SmQ1An0pmbF2nfDt3SoDuzr 3G5cpXO8S3WieWOYfhvTIAsbl0pwhQYG0qRmqfOZ2AyTyYG8jsDz7PdXwcnwfrpHWu 8ngXfjRabAdR8GZAGBzjMUEJ5D24y3vHlccwnHHs= Received: by mail-wm1-f43.google.com with SMTP id k26so202466wmi.4 for ; Mon, 01 Jun 2020 09:51:37 -0700 (PDT) X-Gm-Message-State: AOAM532sCJC8RbRUC7cPZKw+HG4UqZ7qb6smYPyo7PiNBni5oG38Hxt7 3WX7OjXpQSwIfaf/R5B+EYOEEaeBUxowv2lhl7XQGw== X-Received: by 2002:a1c:abc3:: with SMTP id u186mr206945wme.21.1591030295821; Mon, 01 Jun 2020 09:51:35 -0700 (PDT) MIME-Version: 1.0 References: <20200504232132.23570-1-daniel.kiper@oracle.com> <2dad6366d2fceb0a9e36f284a8ed5a8ed86d8756.camel@linux.intel.com> <20200507110634.2yvzirauq5md7d2q@tomti.i.net-space.pl> In-Reply-To: From: Andy Lutomirski Date: Mon, 1 Jun 2020 09:51:23 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [GRUB PATCH RFC 00/18] i386: Intel TXT secure launcher To: "Daniel P. Smith" Cc: Daniel Kiper , Lukasz Hawrylko , grub-devel@gnu.org, LKML , trenchboot-devel@googlegroups.com, X86 ML , alexander.burmashev@oracle.com, Andrew Cooper , Ard Biesheuvel , eric.snowberg@oracle.com, javierm@redhat.com, kanth.ghatraju@oracle.com, Konrad Rzeszutek Wilk , krystian.hebel@3mdeb.com, michal.zygowski@3mdeb.com, Matthew Garrett , phcoder@gmail.com, piotr.krol@3mdeb.com, Peter Jones , Ross Philipson Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jun 1, 2020 at 8:33 AM Daniel P. Smith wrote: > > On 5/7/20 7:06 AM, Daniel Kiper wrote: > > Hi =C5=81ukasz, > > > > On Tue, May 05, 2020 at 04:38:02PM +0200, Lukasz Hawrylko wrote: > >> On Tue, 2020-05-05 at 01:21 +0200, Daniel Kiper wrote: > > ... > > >> In OS-MLE table there is a buffer for TPM event log, however I see tha= t > >> you are not using it, but instead allocate space somewhere in the > > > > I think that this part requires more discussion. In my opinion we shoul= d > > have this region dynamically allocated because it gives us more flexibi= lity. > > Of course there is a question about the size of this buffer too. I am > > not sure about that because I have not checked yet how many log entries > > are created by the SINIT ACM. Though probably it should not be large... > > > >> memory. I am just wondering if, from security perspective, it will be > >> better to use memory from TXT heap for event log, like we do in TBOOT. > > > > Appendix F, TPM Event Log, has following sentence: There are no > > requirements for event log to be in DMA protected memory =E2=80=93 SINI= T will > > not enforce it. > > > > I was thinking about it and it seems to me that the TPM event log does > > not require any special protections. Any changes in it can be quickly > > detected by comparing hashes with the TPM PCRs. Does not it? > > > > I think it would be beneficial to consider the following in deciding > where the log is placed. There are two areas of attack/manipulation that > need to be considered. The first area is the log contents itself, which > as Daniel has pointed out, the log contents do not really need to be > protected from tampering as that would/should be detected during > verification by the attestor. The second area that we need to consider > is the log descriptors themselves. If these are in an area that can be > manipulated, it is an opportunity for an attacker to attempt to > influence the ACM's execution. For a little perspective, the ACM > executes from CRAM to take the most possible precaution to ensure that > it cannot be tampered with during execution. This is very important > since it runs a CPU mode (ACM Mode) that I would consider to be higher > (or lower depending on how you view it) than SMM. As a result, the txt > heap is also included in what is mapped into CRAM. If the event log is > place in the heap, this ensures that the ACM is not using memory outside > of CRAM during execution. Now as Daniel has pointed out, the down side > to this is that it greatly restricts the log size and can only be > managed by a combination of limiting the number of events and > restricting what content is carried in the event data field. Can you clarify what the actual flow of control is? If I had to guess, it'= s: GRUB (or other bootloader) writes log. GRUB transfers control to the ACM. At this point, GRUB is done running and GRUB code will not run again. ACM validates system configuration and updates TPM state using magic privileged TPM access. ACM transfers control to the shiny new Linux secure launch entry point Maybe this is right, and maybe this is wrong. But I have some questions about this whole setup. Is the ACM code going to inspect this log at all? If so, why? Who supplies the ACM code? If the ACM can be attacked by putting its inputs (e.g. this log) in the wrong place in memory, why should this be considered anything other than a bug in the ACM? If GRUB is indeed done by the time anyone consumes the log, why does GRUB care where the log ends up? And finally, the log presumably has nonzero size, and it would be nice not to pin some physical memory forever for the log. Could the kernel copy it into tmpfs during boot so it's at least swappable and then allow userspace to delete it when userspace is done with it?