All of lore.kernel.org
 help / color / mirror / Atom feed
* [tpm2] Re: tpm2_flushcontext stuck
@ 2021-12-18 19:34 Han
  0 siblings, 0 replies; 19+ messages in thread
From: Han @ 2021-12-18 19:34 UTC (permalink / raw)
  To: tpm2

[-- Attachment #1: Type: text/plain, Size: 8849 bytes --]

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 #2: attachment.htm --]
[-- Type: text/html, Size: 11659 bytes --]

^ permalink raw reply	[flat|nested] 19+ messages in thread

* [tpm2] Re: tpm2_flushcontext stuck
@ 2022-03-29 21:31 Han
  0 siblings, 0 replies; 19+ messages in thread
From: Han @ 2022-03-29 21:31 UTC (permalink / raw)
  To: tpm2

[-- Attachment #1: Type: text/plain, Size: 617 bytes --]

Thank you for the fix!

On Tue, Mar 29, 2022 at 2:05 PM Tadeusz Struk <tstruk(a)gmail.com> wrote:

> On 3/29/22 13:01, Roberts, William C wrote:
> > Do you have a link to the patch so it's archived in this thread for
> > those searching for a fix?
>
> Yes, here it is:
>
> https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=2e8e4c8f6673247e22efc7985ce5497accd16f88
> _______________________________________________
> 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 #2: attachment.htm --]
[-- Type: text/html, Size: 1221 bytes --]

^ permalink raw reply	[flat|nested] 19+ messages in thread

* [tpm2] Re: tpm2_flushcontext stuck
@ 2022-03-29 21:04 Tadeusz Struk
  0 siblings, 0 replies; 19+ messages in thread
From: Tadeusz Struk @ 2022-03-29 21:04 UTC (permalink / raw)
  To: tpm2

[-- Attachment #1: Type: text/plain, Size: 282 bytes --]

On 3/29/22 13:01, Roberts, William C wrote:
> Do you have a link to the patch so it's archived in this thread for
> those searching for a fix?

Yes, here it is:
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=2e8e4c8f6673247e22efc7985ce5497accd16f88

^ permalink raw reply	[flat|nested] 19+ messages in thread

* [tpm2] Re: tpm2_flushcontext stuck
@ 2022-03-29 20:01 Roberts, William C
  0 siblings, 0 replies; 19+ messages in thread
From: Roberts, William C @ 2022-03-29 20:01 UTC (permalink / raw)
  To: tpm2

[-- Attachment #1: Type: text/plain, Size: 826 bytes --]

On Thu, 2022-03-24 at 12:08 -0700, Tadeusz Struk wrote:
> On 12/20/21 14:06, Juergen Repp wrote:
> > When /dev/tpmrm0 was used with kernel 5.10.
> > After sending the command read public:
> > 0x80 0x01 0x00 0x00 0x00 0x0e 0x00 0x00 0x01 0x73 0x80 0x00 0x00
> > 0x00
> > the write worked but the poll call in  tcti_device_receive did
> > stuck.
> > With kernel 4.19 write for this command did return -1
> 
> It took awhile, but the fix is now queued for 5.10.109 and above.

Do you have a link to the patch so it's archived in this thread for
those searching for a fix?

> --
> Thanks,
> Tadeusz
> _______________________________________________
> 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

^ permalink raw reply	[flat|nested] 19+ messages in thread

* [tpm2] Re: tpm2_flushcontext stuck
@ 2022-03-24 19:08 Tadeusz Struk
  0 siblings, 0 replies; 19+ messages in thread
From: Tadeusz Struk @ 2022-03-24 19:08 UTC (permalink / raw)
  To: tpm2

[-- Attachment #1: Type: text/plain, Size: 421 bytes --]

On 12/20/21 14:06, Juergen Repp wrote:
> When /dev/tpmrm0 was used with kernel 5.10.
> After sending the command read public:
> 0x80 0x01 0x00 0x00 0x00 0x0e 0x00 0x00 0x01 0x73 0x80 0x00 0x00 0x00
> the write worked but the poll call in  tcti_device_receive did stuck.
> With kernel 4.19 write for this command did return -1

It took awhile, but the fix is now queued for 5.10.109 and above.
--
Thanks,
Tadeusz

^ permalink raw reply	[flat|nested] 19+ messages in thread

* [tpm2] Re: tpm2_flushcontext stuck
@ 2021-12-21 14:40 Roberts, William C
  0 siblings, 0 replies; 19+ messages in thread
From: Roberts, William C @ 2021-12-21 14:40 UTC (permalink / raw)
  To: tpm2

[-- Attachment #1: Type: text/plain, Size: 2017 bytes --]

FYI I reported this bug to the linux integrity mailing list:
  - https://marc.info/?l=linux-integrity&m=164009679300941&w=2
________________________________
From: Juergen Repp <Juergen.Repp(a)sit.fraunhofer.de>
Sent: Monday, December 20, 2021 4:06 PM
To: Kenneth Goldman <kgoldman(a)us.ibm.com>
Cc: tpm2(a)lists.01.org <tpm2(a)lists.01.org>
Subject: [tpm2] Re: tpm2_flushcontext stuck

When /dev/tpmrm0 was used with kernel 5.10.
After sending the command read public:
0x80 0x01 0x00 0x00 0x00 0x0e 0x00 0x00 0x01 0x73 0x80 0x00 0x00 0x00
the write worked but the poll call in  tcti_device_receive did stuck.
With kernel 4.19 write for this command did return -1



Am 20.12.21 um 21:04 schrieb Kenneth Goldman:
> They way I use it:
>
>
>
> /dev/tpm0 is locking, one user at a time.  I use it for debug only.  IMHO, production applications should not use it.
>
>
>
> /dev/tpmrm0 is the multi-user interface.  Use it for production applications, where the TPM is shared.
>
>
>
> I suspect (not sure) that /dev/tpm0 will have unexpected effects when the kernel is also trying to use the TPM.
>
>
>
>
>
> And as a newbie, I felt that the fact TPM exposes two devices (/dev/tpm0 and /dev/tpmrm0) under Linux is confusing and is making things more complicated.  The architecture diagram (https://github.com/tpm2-software/tpm2-tss <https://github.com/tpm2-software/tpm2-tss>) shows all calls go through the Resource Manager but that is not the case in reality.  I was wondering what is the benefit to have 2 devices instead of just one device in linux?
>
>
>
>
> _______________________________________________
> 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
>
_______________________________________________
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 #2: attachment.htm --]
[-- Type: text/html, Size: 3308 bytes --]

^ permalink raw reply	[flat|nested] 19+ messages in thread

* [tpm2] Re: tpm2_flushcontext stuck
@ 2021-12-20 22:06 Juergen Repp
  0 siblings, 0 replies; 19+ messages in thread
From: Juergen Repp @ 2021-12-20 22:06 UTC (permalink / raw)
  To: tpm2

[-- Attachment #1: Type: text/plain, Size: 1457 bytes --]

When /dev/tpmrm0 was used with kernel 5.10.
After sending the command read public:
0x80 0x01 0x00 0x00 0x00 0x0e 0x00 0x00 0x01 0x73 0x80 0x00 0x00 0x00
the write worked but the poll call in  tcti_device_receive did stuck.
With kernel 4.19 write for this command did return -1



Am 20.12.21 um 21:04 schrieb Kenneth Goldman:
> They way I use it:
> 
>  
> 
> /dev/tpm0 is locking, one user at a time.  I use it for debug only.  IMHO, production applications should not use it.
> 
>  
> 
> /dev/tpmrm0 is the multi-user interface.  Use it for production applications, where the TPM is shared.
> 
>  
> 
> I suspect (not sure) that /dev/tpm0 will have unexpected effects when the kernel is also trying to use the TPM.
> 
>  
> 
>  
> 
> And as a newbie, I felt that the fact TPM exposes two devices (/dev/tpm0 and /dev/tpmrm0) under Linux is confusing and is making things more complicated.  The architecture diagram (https://github.com/tpm2-software/tpm2-tss <https://github.com/tpm2-software/tpm2-tss>) shows all calls go through the Resource Manager but that is not the case in reality.  I was wondering what is the benefit to have 2 devices instead of just one device in linux? 
> 
>  
> 
> 
> _______________________________________________
> 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
> 

^ permalink raw reply	[flat|nested] 19+ messages in thread

* [tpm2] Re: tpm2_flushcontext stuck
@ 2021-12-20 20:04 Kenneth Goldman
  0 siblings, 0 replies; 19+ messages in thread
From: Kenneth Goldman @ 2021-12-20 20:04 UTC (permalink / raw)
  To: tpm2

[-- Attachment #1: Type: text/plain, Size: 813 bytes --]

They way I use it:

/dev/tpm0 is locking, one user at a time.  I use it for debug only.  IMHO, production applications should not use it.

/dev/tpmrm0 is the multi-user interface.  Use it for production applications, where the TPM is shared.

I suspect (not sure) that /dev/tpm0 will have unexpected effects when the kernel is also trying to use the TPM.


And as a newbie, I felt that the fact TPM exposes two devices (/dev/tpm0 and /dev/tpmrm0) under Linux is confusing and is making things more complicated.  The architecture diagram (https://github.com/tpm2-software/tpm2-tss<https://github.com/tpm2-software/tpm2-tss>) shows all calls go through the Resource Manager but that is not the case in reality.  I was wondering what is the benefit to have 2 devices instead of just one device in linux?


[-- Attachment #2: attachment.htm --]
[-- Type: text/html, Size: 2930 bytes --]

^ permalink raw reply	[flat|nested] 19+ messages in thread

* [tpm2] Re: tpm2_flushcontext stuck
@ 2021-12-20 19:13 Han
  0 siblings, 0 replies; 19+ messages in thread
From: Han @ 2021-12-20 19:13 UTC (permalink / raw)
  To: tpm2

[-- Attachment #1: Type: text/plain, Size: 1651 bytes --]

Thanks for your responses. They are really helpful to me. Such a fix will
also help me understand how TPM works.

And as a newbie, I felt that the fact TPM exposes two devices (/dev/tpm0
and /dev/tpmrm0) under Linux is confusing and is making
things more complicated.  The architecture diagram (
https://github.com/tpm2-software/tpm2-tss) shows all calls go through the
Resource Manager but that is not the case in reality.  I was wondering what
is the benefit to have 2 devices instead of just one device in linux?

Thanks.


On Mon, Dec 20, 2021 at 10:57 AM Tadeusz Struk <tstruk(a)gmail.com> wrote:

> On 12/19/21 04:17, Juergen Repp wrote:
> > Am 18.12.21 um 20:34 schrieb Han:
> >> I probably missed it,  how can I specify to make sure /dev/tpm0 is
> used, and not /dev/tpmrm0 ?  Is it in some configurations?
> >>
> > You can use the TPM without resource manager with:
> >
> > tpm2_createprimary  -Tdevice:/dev/tpm0 -C o -g sha256 -G ecc -c
> primary.ctx
> > tpm2_getcap handles-transient -Tdevice:/dev/tpm0
> > tpm2_flushcontext -Tdevice:/dev/tpm0 0x80000000
>
> The problem is that when /dev/tpm0 is used it just sends a request
> straight to
> the tpm and the tpm responds with a valid error message, which it then
> passed
> back to tcti. In case of /dev/tpmrm0 the RM tries to first load the none
> existing object 0x80000000 from its cash, but since it cannot find it just
> returns an error code -22 (EINVAL) and nothing gets send to the tpm.
> The tpm_dev_async_work() handler needs to be modified to handle such error
> cases
> as well. I will send a fix for this.
>
> Thanks,
> --
> Tadeusz
>

[-- Attachment #2: attachment.htm --]
[-- Type: text/html, Size: 2077 bytes --]

^ permalink raw reply	[flat|nested] 19+ messages in thread

* [tpm2] Re: tpm2_flushcontext stuck
@ 2021-12-20 18:57 Tadeusz Struk
  0 siblings, 0 replies; 19+ messages in thread
From: Tadeusz Struk @ 2021-12-20 18:57 UTC (permalink / raw)
  To: tpm2

[-- Attachment #1: Type: text/plain, Size: 979 bytes --]

On 12/19/21 04:17, Juergen Repp wrote:
> Am 18.12.21 um 20:34 schrieb Han:
>> I probably missed it,  how can I specify to make sure /dev/tpm0 is used, and not /dev/tpmrm0 ?  Is it in some configurations?
>>
> You can use the TPM without resource manager with:
> 
> tpm2_createprimary  -Tdevice:/dev/tpm0 -C o -g sha256 -G ecc -c primary.ctx
> tpm2_getcap handles-transient -Tdevice:/dev/tpm0
> tpm2_flushcontext -Tdevice:/dev/tpm0 0x80000000

The problem is that when /dev/tpm0 is used it just sends a request straight to
the tpm and the tpm responds with a valid error message, which it then passed 
back to tcti. In case of /dev/tpmrm0 the RM tries to first load the none 
existing object 0x80000000 from its cash, but since it cannot find it just
returns an error code -22 (EINVAL) and nothing gets send to the tpm.
The tpm_dev_async_work() handler needs to be modified to handle such error cases
as well. I will send a fix for this.

Thanks,
--
Tadeusz

^ permalink raw reply	[flat|nested] 19+ messages in thread

* [tpm2] Re: tpm2_flushcontext stuck
@ 2021-12-19 12:17 Juergen Repp
  0 siblings, 0 replies; 19+ messages in thread
From: Juergen Repp @ 2021-12-19 12:17 UTC (permalink / raw)
  To: tpm2

[-- Attachment #1: Type: text/plain, Size: 405 bytes --]

Am 18.12.21 um 20:34 schrieb Han:
> I probably missed it,  how can I specify to make sure /dev/tpm0 is used, and not /dev/tpmrm0 ?  Is it in some configurations?
> 
You can use the TPM without resource manager with:

tpm2_createprimary  -Tdevice:/dev/tpm0 -C o -g sha256 -G ecc -c primary.ctx
tpm2_getcap handles-transient -Tdevice:/dev/tpm0
tpm2_flushcontext -Tdevice:/dev/tpm0 0x80000000



^ permalink raw reply	[flat|nested] 19+ messages in thread

* [tpm2] Re: tpm2_flushcontext stuck
@ 2021-12-18 19:33 Han
  0 siblings, 0 replies; 19+ messages in thread
From: Han @ 2021-12-18 19:33 UTC (permalink / raw)
  To: tpm2

[-- Attachment #1: Type: text/plain, Size: 9591 bytes --]

On Sat, Dec 18, 2021 at 5:54 AM Juergen Repp <Juergen.Repp(a)sit.fraunhofer.de>
wrote:

> I did check your commands on Raspian (also /dev/tpmrm0 was used):
>
> tpm2_createprimary  -C o -g sha256 -G ecc -c primary.ctx
> tpm2_getcap handles-transient (No handle is displayed, primary.ctx can be
> used)
> tpm2_flushcontext 0x80000000
> ERROR:tcti:src/util/io.c:108:write_all() failed to write to fd 3: Invalid
> argument
> ERROR:tcti:src/tss2-tcti/tcti-device.c:126:tcti_device_transmit() wrong
> number of bytes written. Expected 14, wrote 0.
>
> So it seems to be a Problem with tcti_device_transmit. The write did
> return -1 if the handle does not exist.
> If the TPM handle used for tpm2_flushcontext exists this error did not
> occur.
>
> Do you also get no handle when executing getcap?:
> tpm2_getcap handles-transient


You're right.  No handles displayed when running "tpm2_getcap
handles-transient".  I can understand if tpm2_flushcontext returns
error messages when no handle. But I didn't understand why it got stuck in
my case.

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 #2: attachment.htm --]
[-- Type: text/html, Size: 12418 bytes --]

^ permalink raw reply	[flat|nested] 19+ messages in thread

* [tpm2] Re: tpm2_flushcontext stuck
@ 2021-12-18 14:11 Juergen Repp
  0 siblings, 0 replies; 19+ messages in thread
From: Juergen Repp @ 2021-12-18 14:11 UTC (permalink / raw)
  To: tpm2

[-- Attachment #1: Type: text/plain, Size: 8411 bytes --]

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

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
> 


^ permalink raw reply	[flat|nested] 19+ messages in thread

* [tpm2] Re: tpm2_flushcontext stuck
@ 2021-12-18 13:54 Juergen Repp
  0 siblings, 0 replies; 19+ messages in thread
From: Juergen Repp @ 2021-12-18 13:54 UTC (permalink / raw)
  To: tpm2

[-- Attachment #1: Type: text/plain, Size: 9029 bytes --]

I did check your commands on Raspian (also /dev/tpmrm0 was used):

tpm2_createprimary  -C o -g sha256 -G ecc -c primary.ctx
tpm2_getcap handles-transient (No handle is displayed, primary.ctx can be used)
tpm2_flushcontext 0x80000000
ERROR:tcti:src/util/io.c:108:write_all() failed to write to fd 3: Invalid argument 
ERROR:tcti:src/tss2-tcti/tcti-device.c:126:tcti_device_transmit() wrong number of bytes written. Expected 14, wrote 0.

So it seems to be a Problem with tcti_device_transmit. The write did return -1 if the handle does not exist.
If the TPM handle used for tpm2_flushcontext exists this error did not occur.

Do you also get no handle when executing getcap?:
tpm2_getcap handles-transient 


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
> 


^ permalink raw reply	[flat|nested] 19+ messages in thread

* [tpm2] Re: tpm2_flushcontext stuck
@ 2021-12-17 23:58 Han
  0 siblings, 0 replies; 19+ messages in thread
From: Han @ 2021-12-17 23:58 UTC (permalink / raw)
  To: tpm2

[-- Attachment #1: Type: text/plain, Size: 5353 bytes --]

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 #2: attachment.htm --]
[-- Type: text/html, Size: 9136 bytes --]

^ permalink raw reply	[flat|nested] 19+ messages in thread

* [tpm2] Re: tpm2_flushcontext stuck
@ 2021-12-17 20:51 Roberts, William C
  0 siblings, 0 replies; 19+ messages in thread
From: Roberts, William C @ 2021-12-17 20:51 UTC (permalink / raw)
  To: tpm2

[-- Attachment #1: Type: text/plain, Size: 4009 bytes --]

I wonder if it's related to this bug, but manifesting itself differently:
  - https://github.com/tpm2-software/tpm2-tools/issues/1356

What version of the tpm2-tss libraries are you running? Do commands like tpm2_getrandom work?
________________________________
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<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)

[-- Attachment #2: attachment.htm --]
[-- Type: text/html, Size: 7496 bytes --]

^ permalink raw reply	[flat|nested] 19+ messages in thread

* [tpm2] Re: tpm2_flushcontext stuck
@ 2021-12-17 20:10 Kenneth Goldman
  0 siblings, 0 replies; 19+ messages in thread
From: Kenneth Goldman @ 2021-12-17 20:10 UTC (permalink / raw)
  To: tpm2

[-- Attachment #1: Type: text/plain, Size: 1051 bytes --]

In general, pick one or the other.

rm0 is the multi-user device, which is normally used
0 is the single user device and will hold a lock on the TPM, not normally used except for standalone debug

In addition, running everything as root is risky.  It's safer to put yourself in the tss group or something similar.

From: Han <keepsimple(a)gmail.com>
Sent: Friday, December 17, 2021 3:04 PM
To: Roberts, William C <william.c.roberts(a)intel.com>
Cc: tpm2(a)lists.01.org
Subject: [EXTERNAL] [tpm2] Re: 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

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 >


[-- Attachment #2: attachment.htm --]
[-- Type: text/html, Size: 3856 bytes --]

^ permalink raw reply	[flat|nested] 19+ messages in thread

* [tpm2] Re: tpm2_flushcontext stuck
@ 2021-12-17 20:04 Han
  0 siblings, 0 replies; 19+ messages in thread
From: Han @ 2021-12-17 20:04 UTC (permalink / raw)
  To: tpm2

[-- Attachment #1: Type: text/plain, Size: 3463 bytes --]

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 #2: attachment.htm --]
[-- Type: text/html, Size: 5545 bytes --]

^ permalink raw reply	[flat|nested] 19+ messages in thread

* [tpm2] Re: tpm2_flushcontext stuck
@ 2021-12-17 18:29 Roberts, William C
  0 siblings, 0 replies; 19+ messages in thread
From: Roberts, William C @ 2021-12-17 18:29 UTC (permalink / raw)
  To: tpm2

[-- Attachment #1: Type: text/plain, Size: 987 bytes --]

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 #2: attachment.htm --]
[-- Type: text/html, Size: 2571 bytes --]

^ permalink raw reply	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2022-03-29 21:31 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-18 19:34 [tpm2] Re: tpm2_flushcontext stuck Han
  -- strict thread matches above, loose matches on Subject: below --
2022-03-29 21:31 Han
2022-03-29 21:04 Tadeusz Struk
2022-03-29 20:01 Roberts, William C
2022-03-24 19:08 Tadeusz Struk
2021-12-21 14:40 Roberts, William C
2021-12-20 22:06 Juergen Repp
2021-12-20 20:04 Kenneth Goldman
2021-12-20 19:13 Han
2021-12-20 18:57 Tadeusz Struk
2021-12-19 12:17 Juergen Repp
2021-12-18 19:33 Han
2021-12-18 14:11 Juergen Repp
2021-12-18 13:54 Juergen Repp
2021-12-17 23:58 Han
2021-12-17 20:51 Roberts, William C
2021-12-17 20:10 Kenneth Goldman
2021-12-17 20:04 Han
2021-12-17 18:29 Roberts, William C

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.