[tpm2] Re: tpm2_flushcontext stuck

Han <keepsimple at gmail.com>
Newsgroups dev.linux.lists.tpm2
Message-ID <CAEjGaqdA2sj=cBcasO_0PqKHtE5mqAN4Bdyx9LUvqVj_QPCEGg@mail.gmail.com>
On Fri, Dec 17, 2021 at 12:51 PM Roberts, William C <
william.c.roberts(a)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(a)gmail.com>
> *Sent:* Friday, December 17, 2021 2:04 PM
> *To:* Roberts, William C <william.c.roberts(a)intel.com>
> *Cc:* tpm2(a)lists.01.org <tpm2(a)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(a)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(a)gmail.com>
> *Sent:* Wednesday, December 15, 2021 5:56 PM
> *To:* tpm2(a)lists.01.org <tpm2(a)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)
>
>
attachment.htm (text/html, 8.9 KB)
<div dir="ltr"><div dir="ltr"><br></div><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Dec 17, 2021 at 12:51 PM Roberts, William C &lt;<a href="mailto:[email protected]">[email protected]</a>&gt; wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">




<div dir="ltr">
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
I wonder if it&#39;s related to this bug, but manifesting itself differently:</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
  - <a href="https://github.com/tpm2-software/tpm2-tools/issues/1356" id="gmail-m_-6165835822585680688LPNoLPOWALinkPreview" target="_blank">https://github.com/tpm2-software/tpm2-tools/issues/1356</a></div></div></blockquote><div><br></div><div>Not sure. The bug is reported on &quot;tpm2-tools&quot; 3.1.3 with Linux kernel 5.0.  I&#39;m using &quot;tpm2-tools&quot; 5.0 now with kernel 5.10.</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
What version of the tpm2-tss libraries are you running? Do commands like tpm2_getrandom work?</div></div></blockquote><div><br></div><div>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`. </div><div><br></div><div>$ apt search tpm2 | grep tss<br><br>WARNING: apt does not have a stable CLI interface. Use with caution in scripts.<br><br>libtss2-dev/stable 3.0.3-2 armhf<br>libtss2-esys-3.0.2-0/stable,now 3.0.3-2 armhf [installed,automatic]<br>libtss2-fapi1/stable 3.0.3-2 armhf<br>libtss2-mu0/stable,now 3.0.3-2 armhf [installed,automatic]<br>libtss2-rc0/stable,now 3.0.3-2 armhf [installed,automatic]<br>libtss2-sys1/stable,now 3.0.3-2 armhf [installed,automatic]<br>libtss2-tcti-cmd0/stable,now 3.0.3-2 armhf [installed,automatic]<br>libtss2-tcti-device0/stable,now 3.0.3-2 armhf [installed,automatic]<br>libtss2-tcti-mssim0/stable,now 3.0.3-2 armhf [installed,automatic]<br>libtss2-tcti-swtpm0/stable,now 3.0.3-2 armhf [installed,automatic]<br>libtss2-tcti-tabrmd-dev/stable 2.3.3-1+b1 armhf<br>libtss2-tcti-tabrmd0/stable 2.3.3-1+b1 armhf<br>libtss2-tctildr0/stable,now 3.0.3-2 armhf [installed,automatic]<br></div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">
<div id="gmail-m_-6165835822585680688appendonsend"></div>
<hr style="display:inline-block;width:98%">
<div id="gmail-m_-6165835822585680688divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>From:</b> Han &lt;<a href="mailto:[email protected]" target="_blank">[email protected]</a>&gt;<br>
<b>Sent:</b> Friday, December 17, 2021 2:04 PM<br>
<b>To:</b> Roberts, William C &lt;<a href="mailto:[email protected]" target="_blank">[email protected]</a>&gt;<br>
<b>Cc:</b> <a href="mailto:[email protected]" target="_blank">[email protected]</a> &lt;<a href="mailto:[email protected]" target="_blank">[email protected]</a>&gt;<br>
<b>Subject:</b> Re: [tpm2] tpm2_flushcontext stuck</font>
<div> </div>
</div>
<div>
<div dir="ltr">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.  
<div><br>
</div>
<div>$ sudo strace tpm2_flushcontext 0x80000000</div>
<div><br>
</div>
<div>&lt;snip&gt;</div>
<div><br>
</div>
<div>openat(AT_FDCWD, &quot;/etc/ld.so.cache&quot;, O_RDONLY|O_LARGEFILE|O_CLOEXEC) = 3<br>
fstat64(3, {st_mode=S_IFREG|0644, st_size=72845, ...}) = 0<br>
mmap2(NULL, 72845, PROT_READ, MAP_PRIVATE, 3, 0) = 0xb6f74000<br>
close(3)                                = 0<br>
openat(AT_FDCWD, &quot;/lib/arm-linux-gnueabihf/libtss2-tcti-device.so.0&quot;, O_RDONLY|O_LARGEFILE|O_CLOEXEC) = 3<br>
read(3, &quot;\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&quot;..., 512) = 512<br>
fstat64(3, {st_mode=S_IFREG|0644, st_size=22028, ...}) = 0<br>
mmap2(NULL, 86236, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0xb5f22000<br>
mprotect(0xb5f27000, 61440, PROT_NONE)  = 0<br>
mmap2(0xb5f36000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x4000) = 0xb5f36000<br>
close(3)                                = 0<br>
mprotect(0xb5f36000, 4096, PROT_READ)   = 0<br>
munmap(0xb6f74000, 72845)               = 0<br>
openat(AT_FDCWD, &quot;/dev/tpmrm0&quot;, O_RDWR|O_NONBLOCK) = 3<br>
write(3, &quot;\200\1\0\0\0\f\0\0\1{\0\10&quot;, 12) = 12<br>
poll([{fd=3, events=POLLIN}], 1, 1000)  = 1 ([{fd=3, revents=POLLIN}])<br>
read(3, &quot;\200\1\0\0\0\24\0\0\0\0&quot;, 10)  = 10<br>
poll([{fd=3, events=POLLIN}], 1, 1000)  = 1 ([{fd=3, revents=POLLIN}])<br>
read(3, &quot;\0\10Z\314k~c`I\346&quot;, 10)      = 10<br>
futex(0xb6e7d35c, FUTEX_WAKE_PRIVATE, 2147483647) = 0<br>
futex(0xb6e7d360, FUTEX_WAKE_PRIVATE, 2147483647) = 0<br>
futex(0xb6e7d364, FUTEX_WAKE_PRIVATE, 2147483647) = 0<br>
futex(0xb6e7d380, FUTEX_WAKE_PRIVATE, 2147483647) = 0<br>
futex(0xb6e7ac9c, FUTEX_WAKE_PRIVATE, 2147483647) = 0<br>
futex(0xb6e7d280, FUTEX_WAKE_PRIVATE, 2147483647) = 0<br>
futex(0xb6e7b224, FUTEX_WAKE_PRIVATE, 2147483647) = 0<br>
futex(0xb6e7ad20, FUTEX_WAKE_PRIVATE, 2147483647) = 0<br>
brk(0xda2000)                           = 0xda2000<br>
futex(0xb6e7d368, FUTEX_WAKE_PRIVATE, 2147483647) = 0<br>
futex(0xb6e7d384, FUTEX_WAKE_PRIVATE, 2147483647) = 0<br>
futex(0xb6e7d3f8, FUTEX_WAKE_PRIVATE, 2147483647) = 0<br>
futex(0xb6e7d36c, FUTEX_WAKE_PRIVATE, 2147483647) = 0<br>
futex(0xb6e7d370, FUTEX_WAKE_PRIVATE, 2147483647) = 0<br>
write(3, &quot;\200\1\0\0\0\16\0\0\1s\200\0\0\0&quot;, 14) = 14<br>
poll([{fd=3, events=POLLIN}], 1, -1<br>
</div>
<div><br>
</div>
<div><br>
</div>
</div>
<br>
<div>
<div dir="ltr">On Fri, Dec 17, 2021 at 10:29 AM Roberts, William C &lt;<a href="mailto:[email protected]" target="_blank">[email protected]</a>&gt; wrote:<br>
</div>
<blockquote style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div dir="ltr">
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
That&#39;s weird, could you strace it and see where it&#39;s hanging?</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<br>
</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
What kernel version is that? I&#39;m assuming your using the /dev/tpm0 or /dev/tpmrm0 device directly since I see the sudo.</div>
<div id="gmail-m_-6165835822585680688x_gmail-m_-6506513492750421582appendonsend"></div>
<hr style="display:inline-block;width:98%">
<div id="gmail-m_-6165835822585680688x_gmail-m_-6506513492750421582divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" color="#000000" style="font-size:11pt"><b>From:</b> Han &lt;<a href="mailto:[email protected]" target="_blank">[email protected]</a>&gt;<br>
<b>Sent:</b> Wednesday, December 15, 2021 5:56 PM<br>
<b>To:</b> <a href="mailto:[email protected]" target="_blank">[email protected]</a> &lt;<a href="mailto:[email protected]" target="_blank">[email protected]</a>&gt;<br>
<b>Subject:</b> [tpm2] tpm2_flushcontext stuck</font>
<div> </div>
</div>
<div>
<div dir="ltr">Hi,
<div><br>
</div>
<div>I&#39;m using tpm2-tools 5.0 in Debian 11 Bullseye based Raspberry Pi OS.  I&#39;m trying to run tpm2_flushcontext but the command got stuck and it&#39;s not showing anything. Is the data in TPM corrupted?  How can I check? </div>
<div><br>
</div>
<div>$ sudo tpm2_flushcontext 0x80000000<br>
</div>
<div>&lt; no output at all and stuck here &gt;</div>
<div><br>
</div>
<div>(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: </div>
<div><br>
</div>
<div>
<pre style="box-sizing:border-box;font-family:ui-monospace,SFMono-Regular,&quot;SF Mono&quot;,Menlo,Consolas,&quot;Liberation Mono&quot;,monospace;font-size:11.9px;margin-top:0px;margin-bottom:16px;padding:16px;overflow:auto;line-height:1.45;border-radius:6px;color:rgb(36,41,47)"><code style="box-sizing:border-box;font-family:ui-monospace,SFMono-Regular,&quot;SF Mono&quot;,Menlo,Consolas,&quot;Liberation Mono&quot;,monospace;font-size:11.9px;padding:0px;margin:0px;background:transparent;border-radius:6px;word-break:normal;border:0px;display:inline;overflow:visible;line-height:inherit">$ sudo tpm2_createprimary -H o -g sha256 -G ecc -C context.out
ObjectAttribute: 0x00030072

CreatePrimary Succeed ! Handle: 0x80000000) </code></pre>
</div>
</div>
</div>
</div>
</blockquote>
</div>
</div>
</div>

</blockquote></div></div>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.