stefanberger / swtpm

Libtpms-based TPM emulator with socket, character device, and Linux CUSE interface.
Other
564 stars 136 forks source link

swtpm: Use umask() to create/truncated state file rather than fchmod() #862

Closed stefanberger closed 3 months ago

stefanberger commented 3 months ago

Since swtpm does not use concurrency while writing state files, set the process umask to 0 when the state file is created or truncated for writing and the user requested specific mode bits. This avoids an additional syscall in the possibly timing critical path when processing a TPM command and having to write the state.