On Fri, Dec 17, 2021 at 12:51 PM Roberts, William C <william.c.roberts@intel.com> wrote:
I wonder if it's related to this bug, but manifesting itself differently:
  - https://github.com/tpm2-software/tpm2-tools/issues/1356

Not sure. The bug is reported on "tpm2-tools" 3.1.3 with Linux kernel 5.0.  I'm using "tpm2-tools" 5.0 now with kernel 5.10.
 
What version of the tpm2-tss libraries are you running? Do commands like tpm2_getrandom work?

There are multiple tss libs on my system (see below), but I think it is 3.0.3.  Yes commands like `tpm2_getrandom` work, including `tpm2_createprimary`. 

$ apt search tpm2 | grep tss

WARNING: apt does not have a stable CLI interface. Use with caution in scripts.

libtss2-dev/stable 3.0.3-2 armhf
libtss2-esys-3.0.2-0/stable,now 3.0.3-2 armhf [installed,automatic]
libtss2-fapi1/stable 3.0.3-2 armhf
libtss2-mu0/stable,now 3.0.3-2 armhf [installed,automatic]
libtss2-rc0/stable,now 3.0.3-2 armhf [installed,automatic]
libtss2-sys1/stable,now 3.0.3-2 armhf [installed,automatic]
libtss2-tcti-cmd0/stable,now 3.0.3-2 armhf [installed,automatic]
libtss2-tcti-device0/stable,now 3.0.3-2 armhf [installed,automatic]
libtss2-tcti-mssim0/stable,now 3.0.3-2 armhf [installed,automatic]
libtss2-tcti-swtpm0/stable,now 3.0.3-2 armhf [installed,automatic]
libtss2-tcti-tabrmd-dev/stable 2.3.3-1+b1 armhf
libtss2-tcti-tabrmd0/stable 2.3.3-1+b1 armhf
libtss2-tctildr0/stable,now 3.0.3-2 armhf [installed,automatic]

 

From: Han <keepsimple@gmail.com>
Sent: Friday, December 17, 2021 2:04 PM
To: Roberts, William C <william.c.roberts@intel.com>
Cc: tpm2@lists.01.org <tpm2@lists.01.org>
Subject: Re: [tpm2] tpm2_flushcontext stuck
 
It seems stuck in a call of `poll()` at fd 3, which is /dev/tpmrm0 based on the log (see below).  The kernel version is 5.10.63.  Yes, I am using /dev/tpm0 and /dev/tpmrm0.  

$ sudo strace tpm2_flushcontext 0x80000000

<snip>

openat(AT_FDCWD, "/etc/ld.so.cache", O_RDONLY|O_LARGEFILE|O_CLOEXEC) = 3
fstat64(3, {st_mode=S_IFREG|0644, st_size=72845, ...}) = 0
mmap2(NULL, 72845, PROT_READ, MAP_PRIVATE, 3, 0) = 0xb6f74000
close(3)                                = 0
openat(AT_FDCWD, "/lib/arm-linux-gnueabihf/libtss2-tcti-device.so.0", O_RDONLY|O_LARGEFILE|O_CLOEXEC) = 3
read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\08\n\0\0004\0\0\0"..., 512) = 512
fstat64(3, {st_mode=S_IFREG|0644, st_size=22028, ...}) = 0
mmap2(NULL, 86236, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0xb5f22000
mprotect(0xb5f27000, 61440, PROT_NONE)  = 0
mmap2(0xb5f36000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x4000) = 0xb5f36000
close(3)                                = 0
mprotect(0xb5f36000, 4096, PROT_READ)   = 0
munmap(0xb6f74000, 72845)               = 0
openat(AT_FDCWD, "/dev/tpmrm0", O_RDWR|O_NONBLOCK) = 3
write(3, "\200\1\0\0\0\f\0\0\1{\0\10", 12) = 12
poll([{fd=3, events=POLLIN}], 1, 1000)  = 1 ([{fd=3, revents=POLLIN}])
read(3, "\200\1\0\0\0\24\0\0\0\0", 10)  = 10
poll([{fd=3, events=POLLIN}], 1, 1000)  = 1 ([{fd=3, revents=POLLIN}])
read(3, "\0\10Z\314k~c`I\346", 10)      = 10
futex(0xb6e7d35c, FUTEX_WAKE_PRIVATE, 2147483647) = 0
futex(0xb6e7d360, FUTEX_WAKE_PRIVATE, 2147483647) = 0
futex(0xb6e7d364, FUTEX_WAKE_PRIVATE, 2147483647) = 0
futex(0xb6e7d380, FUTEX_WAKE_PRIVATE, 2147483647) = 0
futex(0xb6e7ac9c, FUTEX_WAKE_PRIVATE, 2147483647) = 0
futex(0xb6e7d280, FUTEX_WAKE_PRIVATE, 2147483647) = 0
futex(0xb6e7b224, FUTEX_WAKE_PRIVATE, 2147483647) = 0
futex(0xb6e7ad20, FUTEX_WAKE_PRIVATE, 2147483647) = 0
brk(0xda2000)                           = 0xda2000
futex(0xb6e7d368, FUTEX_WAKE_PRIVATE, 2147483647) = 0
futex(0xb6e7d384, FUTEX_WAKE_PRIVATE, 2147483647) = 0
futex(0xb6e7d3f8, FUTEX_WAKE_PRIVATE, 2147483647) = 0
futex(0xb6e7d36c, FUTEX_WAKE_PRIVATE, 2147483647) = 0
futex(0xb6e7d370, FUTEX_WAKE_PRIVATE, 2147483647) = 0
write(3, "\200\1\0\0\0\16\0\0\1s\200\0\0\0", 14) = 14
poll([{fd=3, events=POLLIN}], 1, -1



On Fri, Dec 17, 2021 at 10:29 AM Roberts, William C <william.c.roberts@intel.com> wrote:
That's weird, could you strace it and see where it's hanging?

What kernel version is that? I'm assuming your using the /dev/tpm0 or /dev/tpmrm0 device directly since I see the sudo.

From: Han <keepsimple@gmail.com>
Sent: Wednesday, December 15, 2021 5:56 PM
To: tpm2@lists.01.org <tpm2@lists.01.org>
Subject: [tpm2] tpm2_flushcontext stuck
 
Hi,

I'm using tpm2-tools 5.0 in Debian 11 Bullseye based Raspberry Pi OS.  I'm trying to run tpm2_flushcontext but the command got stuck and it's not showing anything. Is the data in TPM corrupted?  How can I check? 

$ sudo tpm2_flushcontext 0x80000000
< no output at all and stuck here >

(note: the handle 0x80000000 was obtained from previous command output when I was running previous version tpm2-tools 3.1.3 on Debian 10 Buster based OS: 

$ sudo tpm2_createprimary -H o -g sha256 -G ecc -C context.out
ObjectAttribute: 0x00030072

CreatePrimary Succeed ! Handle: 0x80000000)