Page MenuHomeFreeBSD

tpm: prevent hang when a thread that has not written tries to read
AcceptedPublic

Authored by chs on Sep 1 2025, 11:59 PM.
Tags
None
Referenced Files
Unknown Object (File)
Tue, Oct 21, 2:04 AM
Unknown Object (File)
Tue, Oct 21, 2:04 AM
Unknown Object (File)
Mon, Oct 20, 4:25 PM
Unknown Object (File)
Sun, Oct 12, 12:42 PM
Unknown Object (File)
Thu, Oct 2, 2:17 PM
Unknown Object (File)
Thu, Oct 2, 1:38 AM
Unknown Object (File)
Tue, Sep 30, 8:37 AM
Unknown Object (File)
Mon, Sep 29, 6:44 AM
Subscribers

Details

Reviewers
mw
imp
olivier
Summary

In tpm20_read(), do not stop the callout that implements the
timeout on reading the result buffer. If the first thread
which tries to read is not the thread which did the write,
then the callout would be stopped, and then if thread that
did do the write never does a read, then all future writes
to the tpm device will hang forever. We have seen this happen
with a go application which uses multiple threads, and when
the read from the thread that did not do the write fails,
we suspect that the whole process exits, which prevents the
thread that did do the write from ever trying to read.
Leaving the callout running limits the total time to read
the entire result buffer, preventing errant read attempts
from blocking future writes indefinitely.

Sponsored by: Netflix

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped
Build Status
Buildable 66748
Build 63631: arc lint + arc unit

Event Timeline

chs requested review of this revision.Sep 1 2025, 11:59 PM
This revision is now accepted and ready to land.Sep 2 2025, 12:04 AM
olivier added a subscriber: olivier.

we are using this patch since months now, and it works great (because it solve the problem mentionned)