Skip to contentSkip to conversation

Fixing TPM_RC_CONTEXT_GAP

DISCUSSION James Bottomley 3 participants 4 messages Jan 26, 2017 – Jan 30, 2017 2 messages not in the archive

lore
Share & tools
lore
#0 lore raw

TPM_RC_CONTEXT_GAP is an error the TPM is allowed to return when the counter that ensures the uniqueness of context saved sessions overflows. The solution, according to the manual, is to re-load and save the oldest session because that frees the old value causing the gap.

This leads to a problem: we have to have access to the session context to pull this trick, and that means we have to disallow TPM users from calling ContextSave on a session otherwise they could DoS us by inducing an unremediable TPM_RC_CONTEXT_GAP error (simply by keeping the saved session and never loading it). We could pull other tricks, like emulating ContextSave and ContextLoad for sessions, but I can't actually see why any legitimate application would want to save a session context at all.

Unless anyone can see a way around this particular problem, I'll go ahead and implement it in the next iteration of the session exhaustion patch.

James

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most engaging tech sites, SlashDot.org! http://sdm.link/slashdot

A message that is not in the archive (sent off-list or not yet received): 1485392679.2473.51.camel-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8@public.gmane.org

#2 lore raw
Quoted 5 lines · James Bottomley

This leads to a problem: we have to have access to the session context to pull this trick, and that means we have to disallow TPM users from calling ContextSave on a session otherwise they could DoS us by inducing an unremediable TPM_RC_CONTEXT_GAP error (simply by keeping the saved session and never loading it).

I think it's perfectly acceptable to block applications from calling context save for sessions. I don't know of any use case that would require it.

(There are definitely use cases for context save on transient objects, but they don't have the replay / gap issue.)

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most engaging tech sites, SlashDot.org! http://sdm.link/slashdot

#3 lore raw
Quoted 8 lines · Ken Goldman
Quoted 5 lines · James Bottomley

This leads to a problem: we have to have access to the session context to pull this trick, and that means we have to disallow TPM users from calling ContextSave on a session otherwise they could DoS us by inducing an unremediable TPM_RC_CONTEXT_GAP error (simply by keeping the saved session and never loading it).

Quoted 6 lines

I think it's perfectly acceptable to block applications from calling context save for sessions. I don't know of any use case that would require it.

(There are definitely use cases for context save on transient objects, but they don't have the replay / gap issue.)

We should probably block the following from /dev/tpms0 by default:

1. ContextLoad for sessions.
2. ContextSave for sessions.
3. Vendor specific commands.

/Jarkko

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most engaging tech sites, SlashDot.org! http://sdm.link/slashdot

A message that is not in the archive (sent off-list or not yet received): 20170129152518.ddeqk257prml5cna-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org

#5 lore raw
Quoted 6 lines · Jarkko Sakkinen

We should probably block the following from /dev/tpms0 by default:

1. ContextLoad for sessions.
2. ContextSave for sessions.
3. Vendor specific commands.

This is reasonable to me. The only vendor specific commands I currently know of are for low level device configuration. It's done in OEM manufacturing and then locked.

Eventually, we'll want to block extends to certain PCRs. E.g., the IMA PCR (10) should be accessibly to the kernel but not user space.

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most engaging tech sites, SlashDot.org! http://sdm.link/slashdot