[tpm2] Re: tpm2_flushcontext stuck

Han <keepsimple at gmail.com>
Newsgroups dev.linux.lists.tpm2
Message-ID <CAEjGaqeTkD1U2Ppb_F08WwG8gEfNJgYtD9tkYfw9tBHztcxu7Q@mail.gmail.com>
On Sat, Dec 18, 2021 at 6:11 AM Juergen Repp <Juergen.Repp(a)sit.fraunhofer.de>
wrote:

> I forgot to mention: If /dev/tpm0 was used instead of /dev/tpmrm0
> everything worked without problems.
>

I probably missed it,  how can I specify to make sure /dev/tpm0 is used,
and not /dev/tpmrm0 ?  Is it in some configurations?

thanks
Han


>
> Am 18.12.21 um 00:58 schrieb Han:
> >
> > On Fri, Dec 17, 2021 at 12:51 PM Roberts, William C <
> william.c.roberts(a)intel.com <mailto: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 <
> 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 <mailto:keepsimple(a)gmail.com>>
> >     *Sent:* Friday, December 17, 2021 2:04 PM
> >     *To:* Roberts, William C <william.c.roberts(a)intel.com <mailto:
> william.c.roberts(a)intel.com>>
> >     *Cc:* tpm2(a)lists.01.org <mailto:tpm2(a)lists.01.org> <
> tpm2(a)lists.01.org <mailto: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 <mailto: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 <mailto:keepsimple(a)gmail.com>>
> >         *Sent:* Wednesday, December 15, 2021 5:56 PM
> >         *To:* tpm2(a)lists.01.org <mailto:tpm2(a)lists.01.org> <
> tpm2(a)lists.01.org <mailto: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) |
> >
> >
> > _______________________________________________
> > tpm2 mailing list -- tpm2(a)lists.01.org
> > To unsubscribe send an email to tpm2-leave(a)lists.01.org
> > %(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s
> >
>
>
attachment.htm (text/html, 11.4 KB)
<div dir="ltr"><div dir="ltr"><br></div><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sat, Dec 18, 2021 at 6:11 AM Juergen Repp &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">I forgot to mention: If /dev/tpm0 was used instead of /dev/tpmrm0 everything worked without problems.<br></blockquote><div><br></div><div>I probably missed it,  how can I specify to make sure /dev/tpm0 is used, and not /dev/tpmrm0 ?  Is it in some configurations?</div><div><br></div><div>thanks</div><div>Han</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">
<br>
Am 18.12.21 um 00:58 schrieb Han:<br>
&gt; <br>
&gt; On Fri, Dec 17, 2021 at 12:51 PM Roberts, William C &lt;<a href="mailto:[email protected]" target="_blank">[email protected]</a> &lt;mailto:<a href="mailto:[email protected]" target="_blank">[email protected]</a>&gt;&gt; wrote:<br>
&gt; <br>
&gt;     I wonder if it&#39;s related to this bug, but manifesting itself differently:<br>
&gt;       - <a href="https://github.com/tpm2-software/tpm2-tools/issues/1356" rel="noreferrer" target="_blank">https://github.com/tpm2-software/tpm2-tools/issues/1356</a> &lt;<a href="https://github.com/tpm2-software/tpm2-tools/issues/1356" rel="noreferrer" target="_blank">https://github.com/tpm2-software/tpm2-tools/issues/1356</a>&gt;<br>
&gt; <br>
&gt; <br>
&gt; 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.<br>
&gt;  <br>
&gt; <br>
&gt;     What version of the tpm2-tss libraries are you running? Do commands like tpm2_getrandom work?<br>
&gt; <br>
&gt; <br>
&gt; 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`. <br>
&gt; <br>
&gt; $ apt search tpm2 | grep tss<br>
&gt; <br>
&gt; WARNING: apt does not have a stable CLI interface. Use with caution in scripts.<br>
&gt; <br>
&gt; libtss2-dev/stable 3.0.3-2 armhf<br>
&gt; libtss2-esys-3.0.2-0/stable,now 3.0.3-2 armhf [installed,automatic]<br>
&gt; libtss2-fapi1/stable 3.0.3-2 armhf<br>
&gt; libtss2-mu0/stable,now 3.0.3-2 armhf [installed,automatic]<br>
&gt; libtss2-rc0/stable,now 3.0.3-2 armhf [installed,automatic]<br>
&gt; libtss2-sys1/stable,now 3.0.3-2 armhf [installed,automatic]<br>
&gt; libtss2-tcti-cmd0/stable,now 3.0.3-2 armhf [installed,automatic]<br>
&gt; libtss2-tcti-device0/stable,now 3.0.3-2 armhf [installed,automatic]<br>
&gt; libtss2-tcti-mssim0/stable,now 3.0.3-2 armhf [installed,automatic]<br>
&gt; libtss2-tcti-swtpm0/stable,now 3.0.3-2 armhf [installed,automatic]<br>
&gt; libtss2-tcti-tabrmd-dev/stable 2.3.3-1+b1 armhf<br>
&gt; libtss2-tcti-tabrmd0/stable 2.3.3-1+b1 armhf<br>
&gt; libtss2-tctildr0/stable,now 3.0.3-2 armhf [installed,automatic]<br>
&gt; <br>
&gt;  <br>
&gt; <br>
&gt;     ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------<br>
&gt;     *From:* Han &lt;<a href="mailto:[email protected]" target="_blank">[email protected]</a> &lt;mailto:<a href="mailto:[email protected]" target="_blank">[email protected]</a>&gt;&gt;<br>
&gt;     *Sent:* Friday, December 17, 2021 2:04 PM<br>
&gt;     *To:* Roberts, William C &lt;<a href="mailto:[email protected]" target="_blank">[email protected]</a> &lt;mailto:<a href="mailto:[email protected]" target="_blank">[email protected]</a>&gt;&gt;<br>
&gt;     *Cc:* <a href="mailto:[email protected]" target="_blank">[email protected]</a> &lt;mailto:<a href="mailto:[email protected]" target="_blank">[email protected]</a>&gt; &lt;<a href="mailto:[email protected]" target="_blank">[email protected]</a> &lt;mailto:<a href="mailto:[email protected]" target="_blank">[email protected]</a>&gt;&gt;<br>
&gt;     *Subject:* Re: [tpm2] tpm2_flushcontext stuck<br>
&gt;      <br>
&gt;     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.  <br>
&gt; <br>
&gt;     $ sudo strace tpm2_flushcontext 0x80000000<br>
&gt; <br>
&gt;     &lt;snip&gt;<br>
&gt; <br>
&gt;     openat(AT_FDCWD, &quot;/etc/ld.so.cache&quot;, O_RDONLY|O_LARGEFILE|O_CLOEXEC) = 3<br>
&gt;     fstat64(3, {st_mode=S_IFREG|0644, st_size=72845, ...}) = 0<br>
&gt;     mmap2(NULL, 72845, PROT_READ, MAP_PRIVATE, 3, 0) = 0xb6f74000<br>
&gt;     close(3)                                = 0<br>
&gt;     openat(AT_FDCWD, &quot;/lib/arm-linux-gnueabihf/libtss2-tcti-device.so.0&quot;, O_RDONLY|O_LARGEFILE|O_CLOEXEC) = 3<br>
&gt;     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>
&gt;     fstat64(3, {st_mode=S_IFREG|0644, st_size=22028, ...}) = 0<br>
&gt;     mmap2(NULL, 86236, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0xb5f22000<br>
&gt;     mprotect(0xb5f27000, 61440, PROT_NONE)  = 0<br>
&gt;     mmap2(0xb5f36000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x4000) = 0xb5f36000<br>
&gt;     close(3)                                = 0<br>
&gt;     mprotect(0xb5f36000, 4096, PROT_READ)   = 0<br>
&gt;     munmap(0xb6f74000, 72845)               = 0<br>
&gt;     openat(AT_FDCWD, &quot;/dev/tpmrm0&quot;, O_RDWR|O_NONBLOCK) = 3<br>
&gt;     write(3, &quot;\200\1\0\0\0\f\0\0\1{\0\10&quot;, 12) = 12<br>
&gt;     poll([{fd=3, events=POLLIN}], 1, 1000)  = 1 ([{fd=3, revents=POLLIN}])<br>
&gt;     read(3, &quot;\200\1\0\0\0\24\0\0\0\0&quot;, 10)  = 10<br>
&gt;     poll([{fd=3, events=POLLIN}], 1, 1000)  = 1 ([{fd=3, revents=POLLIN}])<br>
&gt;     read(3, &quot;\0\10Z\314k~c`I\346&quot;, 10)      = 10<br>
&gt;     futex(0xb6e7d35c, FUTEX_WAKE_PRIVATE, 2147483647) = 0<br>
&gt;     futex(0xb6e7d360, FUTEX_WAKE_PRIVATE, 2147483647) = 0<br>
&gt;     futex(0xb6e7d364, FUTEX_WAKE_PRIVATE, 2147483647) = 0<br>
&gt;     futex(0xb6e7d380, FUTEX_WAKE_PRIVATE, 2147483647) = 0<br>
&gt;     futex(0xb6e7ac9c, FUTEX_WAKE_PRIVATE, 2147483647) = 0<br>
&gt;     futex(0xb6e7d280, FUTEX_WAKE_PRIVATE, 2147483647) = 0<br>
&gt;     futex(0xb6e7b224, FUTEX_WAKE_PRIVATE, 2147483647) = 0<br>
&gt;     futex(0xb6e7ad20, FUTEX_WAKE_PRIVATE, 2147483647) = 0<br>
&gt;     brk(0xda2000)                           = 0xda2000<br>
&gt;     futex(0xb6e7d368, FUTEX_WAKE_PRIVATE, 2147483647) = 0<br>
&gt;     futex(0xb6e7d384, FUTEX_WAKE_PRIVATE, 2147483647) = 0<br>
&gt;     futex(0xb6e7d3f8, FUTEX_WAKE_PRIVATE, 2147483647) = 0<br>
&gt;     futex(0xb6e7d36c, FUTEX_WAKE_PRIVATE, 2147483647) = 0<br>
&gt;     futex(0xb6e7d370, FUTEX_WAKE_PRIVATE, 2147483647) = 0<br>
&gt;     write(3, &quot;\200\1\0\0\0\16\0\0\1s\200\0\0\0&quot;, 14) = 14<br>
&gt;     poll([{fd=3, events=POLLIN}], 1, -1<br>
&gt; <br>
&gt; <br>
&gt; <br>
&gt;     On Fri, Dec 17, 2021 at 10:29 AM Roberts, William C &lt;<a href="mailto:[email protected]" target="_blank">[email protected]</a> &lt;mailto:<a href="mailto:[email protected]" target="_blank">[email protected]</a>&gt;&gt; wrote:<br>
&gt; <br>
&gt;         That&#39;s weird, could you strace it and see where it&#39;s hanging?<br>
&gt; <br>
&gt;         What kernel version is that? I&#39;m assuming your using the /dev/tpm0 or /dev/tpmrm0 device directly since I see the sudo.<br>
&gt;         ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------<br>
&gt;         *From:* Han &lt;<a href="mailto:[email protected]" target="_blank">[email protected]</a> &lt;mailto:<a href="mailto:[email protected]" target="_blank">[email protected]</a>&gt;&gt;<br>
&gt;         *Sent:* Wednesday, December 15, 2021 5:56 PM<br>
&gt;         *To:* <a href="mailto:[email protected]" target="_blank">[email protected]</a> &lt;mailto:<a href="mailto:[email protected]" target="_blank">[email protected]</a>&gt; &lt;<a href="mailto:[email protected]" target="_blank">[email protected]</a> &lt;mailto:<a href="mailto:[email protected]" target="_blank">[email protected]</a>&gt;&gt;<br>
&gt;         *Subject:* [tpm2] tpm2_flushcontext stuck<br>
&gt;          <br>
&gt;         Hi,<br>
&gt; <br>
&gt;         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? <br>
&gt; <br>
&gt;         $ sudo tpm2_flushcontext 0x80000000<br>
&gt;         &lt; no output at all and stuck here &gt;<br>
&gt; <br>
&gt;         (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: <br>
&gt; <br>
&gt;         |$ sudo tpm2_createprimary -H o -g sha256 -G ecc -C context.out ObjectAttribute: 0x00030072 CreatePrimary Succeed ! Handle: 0x80000000) |<br>
&gt; <br>
&gt; <br>
&gt; _______________________________________________<br>
&gt; tpm2 mailing list -- <a href="mailto:[email protected]" target="_blank">[email protected]</a><br>
&gt; To unsubscribe send an email to <a href="mailto:[email protected]" target="_blank">[email protected]</a><br>
&gt; %(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s<br>
&gt; <br>
<br>
</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.