[edk2-devel] [PATCH 4/4] OvmfPkg: add TPM2_SHA1_ENABLE build option

James Bottomley jejb at linux.ibm.com
Fri Oct 22 12:40:15 UTC 2021


On Fri, 2021-10-22 at 07:57 -0400, Stefan Berger wrote:
> On 10/22/21 7:49 AM, James Bottomley wrote:
> > On Fri, 2021-10-22 at 06:50 -0400, Stefan Berger wrote:
> > [...]
> > > I see this also but when I get into Linux and run tpm2_pcrread I
> > > see the SHA1 bank active but not having received any PCR
> > > extensions from the firmware, which is not supposed to happen.
> > That's not entirely correct: the TCG firmware profile just requires
> > us to log through at least one bank; it doesn't require that all
> > active banks be logged.  I've got several physical systems with
> > three active banks but only one or two measured through.
>  
> The problem with this is that you can then fake measured boot on
> that system using it's unused SHA1 bank and extend into it whatever
> you want and create a fake log along with it and the quote is going
> to look alright.

I don't think you can.  The measured boot PCRs in unused banks should
always be their default values and the measurement software should
check for this.  So on a system that only uses the sha256 bank, the
sha1 bank PCR0-7 should be all zeros ... if they aren't this should be
a measurement failure.

That means that if you try to replace the sha256 agile log with one
containing fake sha1 entries, the attestation still fails because the
sha256 bank doesn't have default entries.

> > The knock on problem the linux kernel is going to have is that we
> > do tend to expect the sha1 bank to be extended into if any others
> > are, so someone is going to have to update expectations ... we
> > should have this in hand already as sha1 is deprecated.
> > 
> > >   So I think you should drop this patch and I'll change the set
> > > of active PCR banks on the swtpm_setup level.
> >  
> > Even if the firmware deactivated the sha1 bank, the kernel
> > expectation problem is still going to exist.
> 
> Is that older Linux kernels or which part still requires sha1? A
> pointer would be good. I would have to revert the change to not
> activat ethe SHA1 bank from swtpm_setup if that's going to create
> headaches. I thought some hardware TPM 2's today are only providing a
> SHA256 bank and so it shouldn't be a problem.

The problem is IMA: it's hash is a kernel config parameter which
defaults to sha1.  It then tries to calculate the boot aggregate over
the configured hash bank and doesn't check if it's unused.

What IMA should probably be doing is working out which bank the bios is
logging through and using that as the hash instead of having it as a
Kconfig parameter.

James




-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#82520): https://edk2.groups.io/g/devel/message/82520
Mute This Topic: https://groups.io/mt/86487987/1813853
Group Owner: devel+owner at edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [edk2-devel-archive at redhat.com]
-=-=-=-=-=-=-=-=-=-=-=-





More information about the edk2-devel-archive mailing list