* TPM resource manager returns -1 for TPM2_RC_CONTEXT_GAP @ 2023-10-19 14:05 Juergen Repp 2023-10-19 15:13 ` James Bottomley 0 siblings, 1 reply; 6+ messages in thread From: Juergen Repp @ 2023-10-19 14:05 UTC (permalink / raw) To: linux-integrity; +Cc: Andreas Fuchs, Plappert, Christian There is an issue related to this problem on github for tpm2-tss: https://github.com/tpm2-software/tpm2-tss/issues/2691 (/dev/tpmrm0 was used) The error did occur after abbout 200 signing operations when a second session was opened by a second process at the same time. Kernel log: [ 401.923826] tpm tpm0: tpm2_save_context: failed with a TPM error 0x0901 [ 401.925049] tpm tpm0: A TPM error (459) occurred flushing context Juergen ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: TPM resource manager returns -1 for TPM2_RC_CONTEXT_GAP 2023-10-19 14:05 TPM resource manager returns -1 for TPM2_RC_CONTEXT_GAP Juergen Repp @ 2023-10-19 15:13 ` James Bottomley 2023-10-19 16:16 ` Andreas.Fuchs 0 siblings, 1 reply; 6+ messages in thread From: James Bottomley @ 2023-10-19 15:13 UTC (permalink / raw) To: Juergen Repp, linux-integrity; +Cc: Andreas Fuchs, Plappert, Christian On Thu, 2023-10-19 at 16:05 +0200, Juergen Repp wrote: > There is an issue related to this problem on github for tpm2-tss: > https://github.com/tpm2-software/tpm2-tss/issues/2691 (/dev/tpmrm0 > was used) > The error did occur after abbout 200 signing operations when a second > session was opened by a second process at the same time. > Kernel log: > [ 401.923826] tpm tpm0: tpm2_save_context: failed with a TPM error > 0x0901 > [ 401.925049] tpm tpm0: A TPM error (459) occurred flushing context I'm afraid that's a known problem with the Intel TSS: it saves the context, which will cause a gapping error if you keep it saved while doing other context requiring operations. The solutions are either to implement degapping in the kernel or persuade the Intel TSS not to save contexts unnecessarily. James ^ permalink raw reply [flat|nested] 6+ messages in thread
* RE: TPM resource manager returns -1 for TPM2_RC_CONTEXT_GAP 2023-10-19 15:13 ` James Bottomley @ 2023-10-19 16:16 ` Andreas.Fuchs 2023-10-19 17:13 ` Juergen Repp 2023-10-20 13:05 ` James Bottomley 0 siblings, 2 replies; 6+ messages in thread From: Andreas.Fuchs @ 2023-10-19 16:16 UTC (permalink / raw) To: James.Bottomley, juergen_repp, linux-integrity; +Cc: christian.plappert > From: James Bottomley <James.Bottomley@HansenPartnership.com> > On Thu, 2023-10-19 at 16:05 +0200, Juergen Repp wrote: > > There is an issue related to this problem on github for tpm2-tss: > > https://github.com/tpm2-software/tpm2-tss/issues/2691 (/dev/tpmrm0 was > > used) The error did occur after abbout 200 signing operations when a > > second session was opened by a second process at the same time. > > Kernel log: > > [ 401.923826] tpm tpm0: tpm2_save_context: failed with a TPM error > > 0x0901 > > [ 401.925049] tpm tpm0: A TPM error (459) occurred flushing context > > I'm afraid that's a known problem with the Intel TSS: it saves the context, which will cause a gapping error if you keep it saved while doing other context requiring operations. The solutions are either to implement degapping in the kernel or persuade the Intel TSS not to save contexts unnecessarily. This is independent of the TSS used. When you have one long lasting session being used seldomly (i.e. in Application A) and another session or multiple sessions being used frequently (i.e. in Application B), then you will hit this problem at some point. As such ANY resource manager (in kernel or outside) needs to implement session ungaping, otherwise it will fail such scenarios. James; on a different note: Any contextSaves by an application or middleware will just make this problem appear earlier but the Kernel's RM will do the contextSave of A's sessions anyways. You can easily make the same problem appear in ANY TSS and you know this very well. So, please stop bad mouthing "not your TSS"es. ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: TPM resource manager returns -1 for TPM2_RC_CONTEXT_GAP 2023-10-19 16:16 ` Andreas.Fuchs @ 2023-10-19 17:13 ` Juergen Repp 2023-10-20 13:05 ` James Bottomley 1 sibling, 0 replies; 6+ messages in thread From: Juergen Repp @ 2023-10-19 17:13 UTC (permalink / raw) To: Andreas.Fuchs, James.Bottomley, linux-integrity; +Cc: christian.plappert Am 19.10.23 um 18:16 schrieb Andreas.Fuchs@infineon.com: >> From: James Bottomley <James.Bottomley@HansenPartnership.com> >> On Thu, 2023-10-19 at 16:05 +0200, Juergen Repp wrote: >>> There is an issue related to this problem on github for tpm2-tss: >>> https://github.com/tpm2-software/tpm2-tss/issues/2691 (/dev/tpmrm0 was >>> used) The error did occur after abbout 200 signing operations when a >>> second session was opened by a second process at the same time. >>> Kernel log: >>> [ 401.923826] tpm tpm0: tpm2_save_context: failed with a TPM error >>> 0x0901 >>> [ 401.925049] tpm tpm0: A TPM error (459) occurred flushing context >> >> I'm afraid that's a known problem with the Intel TSS: it saves the context, which will cause a gapping error if you keep it saved while doing other context requiring operations. The solutions are either to implement degapping in the kernel or persuade the Intel TSS not to save contexts unnecessarily. > > This is independent of the TSS used. > When you have one long lasting session being used seldomly (i.e. in Application A) and another session or multiple sessions being used frequently (i.e. in Application B), then you will hit this problem at some point. > As such ANY resource manager (in kernel or outside) needs to implement session ungaping, otherwise it will fail such scenarios. > yes we were able to work around the problem by using the resource mangager from https://github.com/tpm2-software/tpm2-abrmd which implements the ungapping. ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: TPM resource manager returns -1 for TPM2_RC_CONTEXT_GAP 2023-10-19 16:16 ` Andreas.Fuchs 2023-10-19 17:13 ` Juergen Repp @ 2023-10-20 13:05 ` James Bottomley 2023-10-20 13:09 ` Andreas.Fuchs 1 sibling, 1 reply; 6+ messages in thread From: James Bottomley @ 2023-10-20 13:05 UTC (permalink / raw) To: Andreas.Fuchs, juergen_repp, linux-integrity; +Cc: christian.plappert On Thu, 2023-10-19 at 16:16 +0000, Andreas.Fuchs@infineon.com wrote: > > From: James Bottomley <James.Bottomley@HansenPartnership.com> > > On Thu, 2023-10-19 at 16:05 +0200, Juergen Repp wrote: > > > There is an issue related to this problem on github for tpm2-tss: > > > https://github.com/tpm2-software/tpm2-tss/issues/2691 (/dev/tpmrm > > > 0 was > > > used) The error did occur after abbout 200 signing operations > > > when a second session was opened by a second process at the same > > > time. > > > Kernel log: > > > [ 401.923826] tpm tpm0: tpm2_save_context: failed with a TPM > > > error 0x0901 > > > [ 401.925049] tpm tpm0: A TPM error (459) occurred flushing > > > context > > > > I'm afraid that's a known problem with the Intel TSS: it saves the > > context, which will cause a gapping error if you keep it saved > > while doing other context requiring operations. The solutions are > > either to implement degapping in the kernel or persuade the Intel > > TSS not to save contexts unnecessarily. > > This is independent of the TSS used. > When you have one long lasting session being used seldomly (i.e. in > Application A) and another session or multiple sessions being used > frequently (i.e. in Application B), then you will hit this problem at > some point. > As such ANY resource manager (in kernel or outside) needs to > implement session ungaping, otherwise it will fail such scenarios. That's true, but in real life the use of sessions tends to be short lived and not context saved (usually short enough that this doesn't even cause a context save inside the kernel rm). You can see this in the TPM code in gnupg, or any of the engines/providers. That's not to say we shouldn't do degapping but, because most common uses in the field don't need it, there's been little pressure on anyone to actually write the code. > James; on a different note: > Any contextSaves by an application or middleware will just make this > problem appear earlier but the Kernel's RM will do the contextSave of > A's sessions anyways. > You can easily make the same problem appear in ANY TSS and you know > this very well. > So, please stop bad mouthing "not your TSS"es. Well, OK, how about this: there is a unique feature of the tpm tools allied with the Intel TSS in that they any use of sessions always seem to induce a session context save which can lead to a gapping problem. James ^ permalink raw reply [flat|nested] 6+ messages in thread
* RE: TPM resource manager returns -1 for TPM2_RC_CONTEXT_GAP 2023-10-20 13:05 ` James Bottomley @ 2023-10-20 13:09 ` Andreas.Fuchs 0 siblings, 0 replies; 6+ messages in thread From: Andreas.Fuchs @ 2023-10-20 13:09 UTC (permalink / raw) To: James.Bottomley, juergen_repp, linux-integrity; +Cc: christian.plappert From: James Bottomley <James.Bottomley@HansenPartnership.com> > On Thu, 2023-10-19 at 16:16 +0000, Andreas.Fuchs@infineon.com wrote: > > > From: James Bottomley <James.Bottomley@HansenPartnership.com> > > > On Thu, 2023-10-19 at 16:05 +0200, Juergen Repp wrote: > > > > There is an issue related to this problem on github for tpm2-tss: > > > > https://github.com/tpm2-software/tpm2-tss/issues/2691 (/dev/tpmrm > > > > 0 was > > > > used) The error did occur after abbout 200 signing operations when > > > > a second session was opened by a second process at the same time. > > > > Kernel log: > > > > [ 401.923826] tpm tpm0: tpm2_save_context: failed with a TPM error > > > > 0x0901 [ 401.925049] tpm tpm0: A TPM error (459) occurred > > > > flushing context > > > > > > I'm afraid that's a known problem with the Intel TSS: it saves the > > > context, which will cause a gapping error if you keep it saved while > > > doing other context requiring operations. The solutions are either > > > to implement degapping in the kernel or persuade the Intel TSS not > > > to save contexts unnecessarily. > > > > This is independent of the TSS used. > > When you have one long lasting session being used seldomly (i.e. in > > Application A) and another session or multiple sessions being used > > frequently (i.e. in Application B), then you will hit this problem at > > some point. > > As such ANY resource manager (in kernel or outside) needs to implement > > session ungaping, otherwise it will fail such scenarios. > > That's true, but in real life the use of sessions tends to be short lived and not context saved (usually short enough that this doesn't even cause a context save inside the kernel rm). You can see this in the TPM code in gnupg, or any of the engines/providers. That's not to say we shouldn't do degapping but, because most common uses in the field don't need it, there's been little pressure on anyone to actually write the code. > > > James; on a different note: > > Any contextSaves by an application or middleware will just make this > > problem appear earlier but the Kernel's RM will do the contextSave of > > A's sessions anyways. > > You can easily make the same problem appear in ANY TSS and you know > > this very well. > > So, please stop bad mouthing "not your TSS"es. > > Well, OK, how about this: there is a unique feature of the tpm tools allied with the Intel TSS in that they any use of sessions always seem to induce a session context save which can lead to a gapping problem. So in the issue linked above, the tpm2-tools are not used at all. And the tpm2-tss libraries do not do any ContextSaves on their own. So here we are hitting the issue from pure application workload. So I am glad that we agree that the kernel needs to learn how to ungap sessions. ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2023-10-20 13:10 UTC | newest] Thread overview: 6+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2023-10-19 14:05 TPM resource manager returns -1 for TPM2_RC_CONTEXT_GAP Juergen Repp 2023-10-19 15:13 ` James Bottomley 2023-10-19 16:16 ` Andreas.Fuchs 2023-10-19 17:13 ` Juergen Repp 2023-10-20 13:05 ` James Bottomley 2023-10-20 13:09 ` Andreas.Fuchs
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox