All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jerry Snitselaar <jsnitsel@redhat.com>
To: Mimi Zohar <zohar@linux.ibm.com>
Cc: Bruno Meneguele <bmeneg@redhat.com>, Petr Vorel <pvorel@suse.cz>,
	ltp@lists.linux.it, Mimi Zohar <zohar@linux.vnet.ibm.com>,
	Petr Cervinka <pcervinka@suse.com>,
	Cyril Hrubis <chrubis@suse.cz>,
	linux-integrity@vger.kernel.org,
	Vitaly Chikunov <vt@altlinux.org>,
	Maurizio Drocco <maurizio.drocco@ibm.com>
Subject: Re: [LTP v2 1/1] ima_tpm.sh: Fix for calculating boot aggregate
Date: Tue, 16 Jun 2020 18:21:48 -0700	[thread overview]
Message-ID: <20200617012148.hhpvxqov2py7fvvc@cantor> (raw)
In-Reply-To: <1592252491.11061.181.camel@linux.ibm.com>

On Mon Jun 15 20, Mimi Zohar wrote:
>On Mon, 2020-06-15 at 16:41 -0300, Bruno Meneguele wrote:
>> On Thu, May 28, 2020 at 06:05:27PM +0200, Petr Vorel wrote:
>> > Hi Mimi,
>> > ...
>> > > > > With just this change, the ima_tpm.sh test is failing.  I assume it is
>> > > > > failing because it is reading the SHA1 TPM bank, not the SHA256 bank
>> > > > > to calculate the boot_aggregate hash.
>> > > > First question: is it correct to take sha256? Because on my test below it's
>> > > > reading sha1, because that's the content of /sys/kernel/security/ima/ascii_runtime_measurements
>> >
>> > > > I thought just kernel commit: 6f1a1d103b48 ima: ("Switch to ima_hash_algo for
>> > > > boot aggregate") from current linux-integrity tree is needed, but I tested it on
>> > > > b59fda449cf0 ("ima: Set again build_ima_appraise variable") (i.e. having all
>> > > > Robeto's ima patches,  missing just last 2 commits from next-integrity head).
>> > > > What is needed to get your setup?
>> >
>> > > This isn't a configuration problem, but an issue of reading PCRs and
>> > > calculating the TPM bank appropriate boot_aggregate.  If you're
>> > > calculating a sha256 boot_aggregate, then the test needs to read and
>> > > calculate the boot_aggregate by reading the SHA256 TPM bank.
>> > OK, I tested it on TPM 1.2 (no TPM 2.0 available atm).
>> > I guess you have TPM 2.0, that's why I didn't spot this issue.
>> >
>> > To sum that: my patch is required for any system without physical TPM with with
>> > kernel with b59fda449cf0 + it also works for TPM 1.2 (regardless kernel
>> > version), because TPM 1.2 supports sha1 only boot aggregate.
>> >
>> > But testing on kernel with b59fda449cf0 with TPM 2.0 is not only broken with
>> > this patch, but also on current version in master, right? As you have
>> > sha256:3fd5dc717f886ff7182526efc5edc3abb179a5aac1ab589c8ec888398233ae5 anyway.
>> > So this patch would help at least testing on VM without vTPM.
>> >
>>
>> If we consider to delay this change until we have the ima-evm-utils
>> released with the ima_boot_aggregate + make this test dependent on
>> both ima-evm-utils and tsspcrread, would it be worth to SKIP the test in
>> case a TPM2.0 sha256 bank is detected instead of FAIL? Thus we could
>> have the test fixed for TPM1.2 && no-TPM cases until we get the full
>> support for multiple banks?
>
>As long as we're dealing with the "boot_aggregate", Maurizio just
>posted a kernel patch for including PCR 8 & 9 in the boot_aggregate.
> The existing IMA LTP "boot_aggregate" test is going to need to
>support this change.
>
>I'd appreciate if someone could send me a TPM event log, the PCRs, and
>the associated IMA ascii_runtime_measurements "boot_aggregate" from a
>system with a discrete TPM 2.0 with PCRs 8 & 9 events.
>
>>
>> > ...
>> > > > > The ima-evm-utils next-testing branch has code to calculate the
>> > > > > boot_aggregate based on multiple banks.
>> > > > I see, 696bf0b ("ima-evm-utils: calculate the digests for multiple TPM banks")
>> > > > I wonder whether it's reasonable trying to port that to ima_boot_aggregate.c or
>> > > > just depend on evmctl. External dependencies are sometimes complicated, but for
>> > > > IMA I incline to just require evmctl.
>> >
>> > > Unlike TPM 1.2, the TPM 2.0 device driver doesn't export the TPM PCRs.
>> > >  Not only would you have a dependency on ima-evm-utils, but also on a
>> > > userspace application(s) for reading the TPM PCRs.  That dependency
>> > > exists whether you're using evmctl to calculate the boot_aggregate or
>> > > doing it yourself.
>> > Hm, things get complicated.
>> > Yep I remember your patch to skip verifying TPM 2.0 PCR values
>> > https://patchwork.ozlabs.org/project/ltp/patch/1558041162.3971.2.camel@linux.ibm.com/
>> > At least thanks to Jerry Snitselaar since v5.6 we have
>> > /sys/class/tpm/tpm*/tpm_version_major. We could check this (+ try also
>> > /sys/class/tpm/tpm0/device/description for older kernels).
>> >
>> > BTW on my system there is also /sys/class/tpm/tpm0/ppi/version, which has 1.2,
>> > not sure if it indicate TPM 1.2, but I wouldn't rely on that.
>> >
>>
>> IIUC 'tpm_version_major' should be the only safe reference of the actual
>> TCG spec version being implemented by the hw TPM, in a sysfs standard
>> output.
>
>That was only upstreamed in linux-v5.6.  Has it been backported?
>

Not that I know of. Since it isn't using chip->ops and only
looks at chip->flags it could probably be backported, but I'd
have to take a look at it.

>The PCRs are not exported for TPM 2.0, unfortunately, making
>regression tests dependent on a userspace app.  The existing LTP
>ima_tpm.sh test looks for the PCRs in either
>/sys/class/tpm/tpm0/device/pcrs or /sys/class/misc/tpm0/device/pcrs.
> Perhaps piggyback on the pseudo PCR file to test for TPM 1.2.
>
>>
>> > ...
>> > > > > There's also a new test to verify the boot_aggregate.
>> >
>> > > > > $ VERBOSE=1 make check TESTS=boog_aggregate.test
>> > > > BTW I got some errors
>> > > > ...
>> > > > make  check-TESTS
>> > > > make[2]: Entering directory '/home/foo/ima-evm-utils/tests'
>> > > > make[3]: Entering directory '/home/foo/ima-evm-utils/tests'
>> > > > make[4]: Entering directory '/home/foo/ima-evm-utils/tests'
>> > > > make[4]: Nothing to be done for 'boog_aggregate.log'.
>> > > > make[4]: Leaving directory '/home/foo/ima-evm-utils/tests'
>> > > > fatal: making test-suite.log: failed to create boog_aggregate.trs
>> > > > fatal: making test-suite.log: failed to create boog_aggregate.log
>> > > > make[3]: *** [Makefile:516: test-suite.log] Error 1
>> > > > make[3]: Leaving directory '/home/foo/ima-evm-utils/tests'
>> > > > make[2]: *** [Makefile:625: check-TESTS] Error 2
>> > > > make[2]: Leaving directory '/home/foo/ima-evm-utils/tests'
>> > > > make[1]: *** [Makefile:692: check-am] Error 2
>> > > > make[1]: Leaving directory '/home/foo/ima-evm-utils/tests'
>> > > > make: *** [Makefile:514: check-recursive] Error 1
>> >
>> > > [Cc'ing Vitaly]
>> >
>> > > The boot_aggregate.trs and boot_aggregate.log files are being created
>> > > in the tests/ directory.  Is that directory read-only?
>> > Yes, drwxr-xr-x. Testing on fresh clone and issue persists.
>> >
>>
>> Yes, same thing here.. but didn't really check the reason for that. Will
>> take a time later to see what's happening.
>
>Thanks, much appreciated.  I'm not seeing that here.
>
>Mimi
>


WARNING: multiple messages have this Message-ID (diff)
From: Jerry Snitselaar <jsnitsel@redhat.com>
To: ltp@lists.linux.it
Subject: [LTP] [LTP v2 1/1] ima_tpm.sh: Fix for calculating boot aggregate
Date: Tue, 16 Jun 2020 18:21:48 -0700	[thread overview]
Message-ID: <20200617012148.hhpvxqov2py7fvvc@cantor> (raw)
In-Reply-To: <1592252491.11061.181.camel@linux.ibm.com>

On Mon Jun 15 20, Mimi Zohar wrote:
>On Mon, 2020-06-15 at 16:41 -0300, Bruno Meneguele wrote:
>> On Thu, May 28, 2020 at 06:05:27PM +0200, Petr Vorel wrote:
>> > Hi Mimi,
>> > ...
>> > > > > With just this change, the ima_tpm.sh test is failing. ?I assume it is
>> > > > > failing because it is reading the SHA1 TPM bank, not the SHA256 bank
>> > > > > to calculate the boot_aggregate hash.
>> > > > First question: is it correct to take sha256? Because on my test below it's
>> > > > reading sha1, because that's the content of /sys/kernel/security/ima/ascii_runtime_measurements
>> >
>> > > > I thought just kernel commit: 6f1a1d103b48 ima: ("Switch to ima_hash_algo for
>> > > > boot aggregate") from current linux-integrity tree is needed, but I tested it on
>> > > > b59fda449cf0 ("ima: Set again build_ima_appraise variable") (i.e. having all
>> > > > Robeto's ima patches,  missing just last 2 commits from next-integrity head).
>> > > > What is needed to get your setup?
>> >
>> > > This isn't a configuration problem, but an issue of reading PCRs and
>> > > calculating the TPM bank appropriate boot_aggregate. ?If you're
>> > > calculating a sha256 boot_aggregate, then the test needs to read and
>> > > calculate the boot_aggregate by reading the SHA256 TPM bank.
>> > OK, I tested it on TPM 1.2 (no TPM 2.0 available atm).
>> > I guess you have TPM 2.0, that's why I didn't spot this issue.
>> >
>> > To sum that: my patch is required for any system without physical TPM with with
>> > kernel with b59fda449cf0 + it also works for TPM 1.2 (regardless kernel
>> > version), because TPM 1.2 supports sha1 only boot aggregate.
>> >
>> > But testing on kernel with b59fda449cf0 with TPM 2.0 is not only broken with
>> > this patch, but also on current version in master, right? As you have
>> > sha256:3fd5dc717f886ff7182526efc5edc3abb179a5aac1ab589c8ec888398233ae5 anyway.
>> > So this patch would help at least testing on VM without vTPM.
>> >
>>
>> If we consider to delay this change until we have the ima-evm-utils
>> released with the ima_boot_aggregate + make this test dependent on
>> both ima-evm-utils and tsspcrread, would it be worth to SKIP the test in
>> case a TPM2.0 sha256 bank is detected instead of FAIL? Thus we could
>> have the test fixed for TPM1.2 && no-TPM cases until we get the full
>> support for multiple banks?
>
>As long as we're dealing with the "boot_aggregate", Maurizio just
>posted a kernel patch for including PCR 8 & 9 in the boot_aggregate.
>?The existing IMA LTP "boot_aggregate" test is going to need to
>support this change.
>
>I'd appreciate if someone could send me a TPM event log, the PCRs, and
>the associated IMA ascii_runtime_measurements "boot_aggregate" from a
>system with a discrete TPM 2.0 with PCRs 8 & 9 events.
>
>>
>> > ...
>> > > > > The ima-evm-utils next-testing branch has code to calculate the
>> > > > > boot_aggregate based on multiple banks.
>> > > > I see, 696bf0b ("ima-evm-utils: calculate the digests for multiple TPM banks")
>> > > > I wonder whether it's reasonable trying to port that to ima_boot_aggregate.c or
>> > > > just depend on evmctl. External dependencies are sometimes complicated, but for
>> > > > IMA I incline to just require evmctl.
>> >
>> > > Unlike TPM 1.2, the TPM 2.0 device driver doesn't export the TPM PCRs.
>> > > ?Not only would you have a dependency on ima-evm-utils, but also on a
>> > > userspace application(s) for reading the TPM PCRs. ?That dependency
>> > > exists whether you're using evmctl to calculate the boot_aggregate or
>> > > doing it yourself.
>> > Hm, things get complicated.
>> > Yep I remember your patch to skip verifying TPM 2.0 PCR values
>> > https://patchwork.ozlabs.org/project/ltp/patch/1558041162.3971.2.camel@linux.ibm.com/
>> > At least thanks to Jerry Snitselaar since v5.6 we have
>> > /sys/class/tpm/tpm*/tpm_version_major. We could check this (+ try also
>> > /sys/class/tpm/tpm0/device/description for older kernels).
>> >
>> > BTW on my system there is also /sys/class/tpm/tpm0/ppi/version, which has 1.2,
>> > not sure if it indicate TPM 1.2, but I wouldn't rely on that.
>> >
>>
>> IIUC 'tpm_version_major' should be the only safe reference of the actual
>> TCG spec version being implemented by the hw TPM, in a sysfs standard
>> output.
>
>That was only upstreamed in linux-v5.6. ?Has it been backported?
>

Not that I know of. Since it isn't using chip->ops and only
looks at chip->flags it could probably be backported, but I'd
have to take a look at it.

>The PCRs are not exported for TPM 2.0, unfortunately, making
>regression tests dependent on a userspace app. ?The existing LTP
>ima_tpm.sh test looks for the PCRs in either
>/sys/class/tpm/tpm0/device/pcrs or /sys/class/misc/tpm0/device/pcrs.
>?Perhaps piggyback on the pseudo PCR file to test for TPM 1.2.
>
>>
>> > ...
>> > > > > There's also a new test to verify the boot_aggregate.
>> >
>> > > > > $ VERBOSE=1 make check TESTS=boog_aggregate.test
>> > > > BTW I got some errors
>> > > > ...
>> > > > make  check-TESTS
>> > > > make[2]: Entering directory '/home/foo/ima-evm-utils/tests'
>> > > > make[3]: Entering directory '/home/foo/ima-evm-utils/tests'
>> > > > make[4]: Entering directory '/home/foo/ima-evm-utils/tests'
>> > > > make[4]: Nothing to be done for 'boog_aggregate.log'.
>> > > > make[4]: Leaving directory '/home/foo/ima-evm-utils/tests'
>> > > > fatal: making test-suite.log: failed to create boog_aggregate.trs
>> > > > fatal: making test-suite.log: failed to create boog_aggregate.log
>> > > > make[3]: *** [Makefile:516: test-suite.log] Error 1
>> > > > make[3]: Leaving directory '/home/foo/ima-evm-utils/tests'
>> > > > make[2]: *** [Makefile:625: check-TESTS] Error 2
>> > > > make[2]: Leaving directory '/home/foo/ima-evm-utils/tests'
>> > > > make[1]: *** [Makefile:692: check-am] Error 2
>> > > > make[1]: Leaving directory '/home/foo/ima-evm-utils/tests'
>> > > > make: *** [Makefile:514: check-recursive] Error 1
>> >
>> > > [Cc'ing Vitaly]
>> >
>> > > The boot_aggregate.trs and boot_aggregate.log files are being created
>> > > in the tests/ directory. ?Is that directory read-only?
>> > Yes, drwxr-xr-x. Testing on fresh clone and issue persists.
>> >
>>
>> Yes, same thing here.. but didn't really check the reason for that. Will
>> take a time later to see what's happening.
>
>Thanks, much appreciated. ?I'm not seeing that here.
>
>Mimi
>


  reply	other threads:[~2020-06-17  1:22 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-27  7:14 [LTP v2 1/1] ima_tpm.sh: Fix for calculating boot aggregate Petr Vorel
2020-05-27  7:14 ` [LTP] " Petr Vorel
2020-05-27 17:41 ` Mimi Zohar
2020-05-27 17:41   ` [LTP] " Mimi Zohar
2020-05-28 14:07   ` Petr Vorel
2020-05-28 14:07     ` [LTP] " Petr Vorel
2020-05-28 15:19     ` Mimi Zohar
2020-05-28 15:19       ` [LTP] " Mimi Zohar
2020-05-28 16:05       ` Petr Vorel
2020-05-28 16:05         ` [LTP] " Petr Vorel
2020-06-15 19:41         ` Bruno Meneguele
2020-06-15 19:41           ` [LTP] " Bruno Meneguele
2020-06-15 20:01           ` Bruno Meneguele
2020-06-15 20:01             ` [LTP] " Bruno Meneguele
2020-06-16 22:40             ` Mimi Zohar
2020-06-16 22:40               ` [LTP] " Mimi Zohar
2020-06-17 19:52               ` Bruno Meneguele
2020-06-17 19:52                 ` [LTP] " Bruno Meneguele
2020-06-19  7:46             ` Petr Vorel
2020-06-19  7:46               ` [LTP] " Petr Vorel
2020-06-15 20:21           ` Mimi Zohar
2020-06-15 20:21             ` [LTP] " Mimi Zohar
2020-06-17  1:21             ` Jerry Snitselaar [this message]
2020-06-17  1:21               ` Jerry Snitselaar
2020-06-17 20:45               ` Bruno Meneguele
2020-06-17 20:45                 ` [LTP] " Bruno Meneguele
2020-06-17 22:19                 ` Maurizio Drocco
2020-06-17 22:19                   ` [LTP] " Maurizio Drocco
2020-06-19  8:21                 ` Petr Vorel
2020-06-19  8:21                   ` [LTP] " Petr Vorel
2020-06-19 12:43                   ` Mimi Zohar
2020-06-19 12:43                     ` [LTP] " Mimi Zohar
2020-06-19 13:01                     ` Petr Vorel
2020-06-19 13:01                       ` [LTP] " Petr Vorel
2020-06-19 10:07             ` Petr Vorel
2020-06-19 10:07               ` [LTP] " Petr Vorel
2020-06-19 13:01               ` Mimi Zohar
2020-06-19 13:01                 ` [LTP] " Mimi Zohar

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200617012148.hhpvxqov2py7fvvc@cantor \
    --to=jsnitsel@redhat.com \
    --cc=bmeneg@redhat.com \
    --cc=chrubis@suse.cz \
    --cc=linux-integrity@vger.kernel.org \
    --cc=ltp@lists.linux.it \
    --cc=maurizio.drocco@ibm.com \
    --cc=pcervinka@suse.com \
    --cc=pvorel@suse.cz \
    --cc=vt@altlinux.org \
    --cc=zohar@linux.ibm.com \
    --cc=zohar@linux.vnet.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.