Page MenuHomeFreeBSD

tpm20: Move user copies outside the lifecycle lock
ClosedPublic

Authored by kbowling on Fri, Aug 28, 1:41 AM.
Tags
None
Referenced Files
F172824457: D59245.id185302.diff
Mon, Sep 21, 8:10 AM
F172805402: D59245.diff
Mon, Sep 21, 3:19 AM
Unknown Object (File)
Sun, Sep 20, 8:03 AM
Unknown Object (File)
Thu, Sep 17, 1:04 PM
Unknown Object (File)
Tue, Sep 15, 6:27 AM
Unknown Object (File)
Tue, Sep 15, 2:40 AM
Unknown Object (File)
Mon, Sep 14, 11:28 PM
Unknown Object (File)
Mon, Sep 14, 9:46 PM
Subscribers

Details

Summary
tpm20: Move user copies outside the lifecycle lock

The TPM 2.0 character-device methods held the global device lock
while uiomove() accessed user memory.  User page faults could therefore
delay suspend or detach even though the read response was already
buffered.

Add a per-open sleepable lock to serialize operations on each response
buffer.  Stage commands under that lock before acquiring the device
lock, and copy them into the response buffer only after the lifecycle
checks succeed.  This preserves an unread response when suspend or
detach rejects a write.  Release the device lock before copying buffered
responses out.  Also advance the response offset by the bytes actually
copied when uiomove() returns after a partial transfer.

Validated on an Intel TPM 2.0 TIS device.  PCR reads and GetRandom
passed under 16-process mixed command load.  A response was consumed
correctly in 5-byte, 7-byte, and remainder reads.  Module unload/reload
recreated the device and entropy source without lock diagnostics.

MFC after:      2 weeks

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable