Skip to content

pcr commands: Fix session leaks#3534

Merged
JuergenReppSIT merged 1 commit intotpm2-software:masterfrom
gzr-lgtm:zg/fix-pcr-session-leaks
Dec 16, 2025
Merged

pcr commands: Fix session leaks#3534
JuergenReppSIT merged 1 commit intotpm2-software:masterfrom
gzr-lgtm:zg/fix-pcr-session-leaks

Conversation

@gzr-lgtm
Copy link
Copy Markdown

tpm2_pcrextend, tpm2_pcrevent, and tpm2_pcrread had session leaks in tpm2_tool_onstop().
This commit adds proper session cleanup to all three tools.
This solves #3533

All three PCR tools had session leaks in tpm2_tool_onstop():
- tpm2_pcrextend: Authorization sessions and auxiliary sessions were
  set up but never closed, leaking all sessions.
- tpm2_pcrevent: The early return prevented auxiliary session cleanup,
  leaking all auxiliary sessions.
- tpm2_pcrread: The auxiliary session cleanup section was completely
  empty, leaking all auxiliary sessions.

This commit adds proper session cleanup to all three tools:
- Close authorization sessions with error checking
- Close auxiliary sessions in a loop with path guards
- Return accumulated error status

Signed-off-by: Zhirang Guo <jonny_guo@apple.com>
@gzr-lgtm gzr-lgtm marked this pull request as ready for review December 16, 2025 16:19
@JuergenReppSIT JuergenReppSIT merged commit f2dcc6f into tpm2-software:master Dec 16, 2025
23 checks passed
@JuergenReppSIT
Copy link
Copy Markdown
Member

@gzr-lgtm Thank you for the PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants