Re: tpm_tis TPM2.0 not detected on cold boot

From: Michael Niewöhner
Date: Fri Jan 04 2019 - 07:02:07 EST


On Thu, 2019-01-03 at 16:47 +0100, Michael NiewÃhner wrote:
> On Thu, 2019-01-03 at 17:04 +0200, Jarkko Sakkinen wrote:
> > On Thu, Jan 03, 2019 at 02:38:11PM +0100, Michael NiewÃhner wrote:
> > > On Thu, 2019-01-03 at 15:27 +0200, Jarkko Sakkinen wrote:
> > > > On Sun, Dec 23, 2018 at 12:55:12PM +0100, Michael NiewÃhner wrote:
> > > > > There is another issue but I don't know if both are related. Maybe
> > > > > that's
> > > > > just a
> > > > > timing issue...
> > > > >
> > > > > root@debian:~# dd if=/dev/hwrng bs=1 count=1
> > > > > dd: error reading '/dev/hwrng': Operation not permitted
> > > > > 0+0 records in
> > > > > 0+0 records out
> > > > > 0 bytes copied, 0.755958 s, 0.0 kB/s
> > > > > root@debian:~# dd if=/dev/hwrng bs=1 count=1 | xxd; dd if=/dev/hwrng
> > > > > bs=1
> > > > > count=1 | xxd
> > > > > dd: error reading '/dev/hwrng': Operation not permitted
> > > > > 0+0 records in
> > > > > 0+0 records out
> > > > > 0 bytes copied, 0.755697 s, 0.0 kB/s
> > > > > 1+0 records in
> > > > > 1+0 records out
> > > > > 00000000: 52 R
> > > > > 1 byte copied, 0.0106268 s, 0.1 kB/s
> > > > >
> > > > >
> > > > > Michael
> > > >
> > > > What does /sys/devices/virtual/misc/hw_random/rng_current show?
> > > >
> > > > Did run commands as a sanity check on my laptop and seem to work.
> > > >
> > > > /Jarkko
> > >
> > > rng_current says "tpm-rng-0", which should be correct
> >
> > Is /dev/tpm0 accessible and usable?
> >
> > /Jarkko
>
> No, it does not seem to work:
>
> root@debian:~# tpm_version
> Tspi_Context_Connect failed: 0x00003011 - layer=tsp, code=0011 (17),
> Communication failure
> root@debian:~# tcsd -f
> TCSD TDDL ioctl: (25) Inappropriate ioctl for device
> TCSD TDDL Falling back to Read/Write device support.
> TCSD TDDL ERROR: write to device /dev/tpm0 failed: Operation not permitted
> TCSD TCS ERROR: TCS GetCapability failed with result = 0x1087
> root@debian:~# stat /dev/tpm0
> File: /dev/tpm0
> Size: 0 Blocks: 0 IO Block: 4096 character special
> file
> Device: 6h/6d Inode: 1114 Links: 1 Device type: a,e0
> Access: (0600/crw-------) Uid: ( 104/ tss) Gid: ( 112/ tss)
> Access: 2019-01-03 16:39:20.627635333 +0100
> Modify: 2019-01-03 16:39:20.627635333 +0100
> Change: 2019-01-03 16:39:20.627635333 +0100
> Birth: -
>
> Michael


I have done some more tests with tpm2-tests from
https://github.com/jethrogb/tpm2-utils.
These are my results:


(initramfs) ./tpm2-test /dev/tpm0 vendor_tpm_type
Error on write(fd,(char*)&tpm_cmd,sizeof(tpm_cmd)): Operation not permitted

(initramfs) ./tpm2-test /dev/tpm0 vendor_tpm_type; ./tpm2-test /dev/tpm0 vendor_
tpm_type
Error on write(fd,(char*)&tpm_cmd,sizeof(tpm_cmd)): Operation not permitted
ï
nitramfs)

-> Same symptom like with dd if=/dev/tpm....


Trying to read the firmware version:

(initramfs) (./tpm2-test /dev/tpm0 vendor_string_1; ./tpm2-test /dev/tpm0 firmwa
re_version_1;) 2>/dev/null | hexdump -C
00000000 80 01 00 00 00 1b 00 00 00 00 01 00 00 00 06 00 |................|
00000010 00 00 01 00 00 01 0b 00 01 00 03 |...........|
0000001b

(initramfs) (./tpm2-test /dev/tpm0 vendor_string_1; ./tpm2-test /dev/tpm0 firmwa
re_version_2;) 2>/dev/null | hexdump -C
00000000 80 01 00 00 00 1b 00 00 00 00 01 00 00 00 06 00 |................|
00000010 00 00 01 00 00 01 0c 00 02 00 08 |...........|
0000001b

-> This version numbers are correct, 1.3.2.8 indeed is the current flashed
firmware.


Get the vendor strings:

(initramfs) (./tpm2-test /dev/tpm0 vendor_string_1; ./tpm2-test /dev/tpm0 vendor
_string_1;) 2>/dev/null | xxd
00000000: 8001 0000 001b 0000 0000 0100 0000 0600 ................
00000010: 0000 0100 0001 0672 6c73 00 .......rls.
(initramfs) (./tpm2-test /dev/tpm0 vendor_string_1; ./tpm2-test /dev/tpm0 vendor
_string_2;) 2>/dev/null | xxd
00000000: 8001 0000 001b 0000 0000 0100 0000 0600 ................
00000010: 0000 0100 0001 074e 5043 54 .......NPCT
(initramfs) (./tpm2-test /dev/tpm0 vendor_string_1; ./tpm2-test /dev/tpm0 vendor
_string_3;) 2>/dev/null | xxd
00000000: 8001 0000 001b 0000 0000 0100 0000 0600 ................
00000010: 0000 0100 0001 0820 0000 00 ....... ...
(initramfs) (./tpm2-test /dev/tpm0 vendor_string_1; ./tpm2-test /dev/tpm0 vendor
_string_4;) 2>/dev/null | xxd
00000000: 8001 0000 001b 0000 0000 0100 0000 0600 ................
00000010: 0000 0100 0001 0920 0000 00 ....... ...

Well, NPCT is correct...



Michael