Skip to content

tpm2: Check for non-NULL entry in ExpDCacheFind - #657

Merged
stefanberger merged 1 commit into
masterfrom
master.next
Nov 3, 2026
Merged

stefanberger merged 1 commit into
masterfrom
master.next

Conversation

@stefanberger

@stefanberger stefanberger commented Nov 3, 2026 •

Copy link
Copy Markdown
Owner

In ExpDCacheFind(), the search loop calls BN_cmp(ExpDCache[i].P, P) on every cache entry without checking if the slot is populated. In empty or cleared cache slots, ExpDCache[i].D and ExpDCache[i].P are NULL.

Check ExpDCache[i].D != NULL before comparing key parameters, matching the convention in ExpDCacheIncrementAge().

Summary by CodeRabbit

  • Bug Fixes
    • Improved reliability of cached cryptographic lookups when an entry’s stored value is unavailable. Matching and lookup behavior remain unchanged for valid entries.

In ExpDCacheFind(), the search loop calls BN_cmp(ExpDCache[i].P, P) on
every cache entry without checking if the slot is populated. In empty or
cleared cache slots, ExpDCache[i].D and ExpDCache[i].P are NULL.

Check ExpDCache[i].D != NULL before comparing key parameters, matching the
convention in ExpDCacheIncrementAge().

Co-authored-by: IBM Bob <noreply@ibm.com>
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
@coderabbitai

coderabbitai Bot commented Nov 3, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review.

Walkthrough

ExpDCacheFind now checks for a non-NULL D pointer before comparing cache entry fields. Matching and subsequent lookup behavior are otherwise unchanged.

Changes: Cache Lookup

Layer / File(s) Summary
Skip unpopulated cache entries
src/tpm2/TPMCmd/tpm/cryptolibs/Ossl/ExpDCache.c
ExpDCacheFind skips entries with a NULL D pointer before comparing P and N.

Estimated code review effort: 1 (Trivial) | ~3 minutes

Change: Bug fix

Merge Risk: Minimal · up to c00ab

The cache lookup guard is consistent with NULL-slot handling, with no actionable merge-blocking risk identified.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title names the change: a non-NULL check on a cache entry inside ExpDCacheFind. The raw summary says ExpDCacheFind now checks that the D pointer is non-NULL before comparing P, N, and E. The title…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the change: a non-NULL check on a cache entry inside ExpDCacheFind. The raw summary says ExpDCacheFind now checks that the D pointer is non-NULL before comparing P, N, and E. The title matches the main change and names the function that changed, so it is specific and accurate. It is not vague, and it does not describe anything absent from the changeset.

Full details: Docstring Coverage

Explanation

Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 1 functions across 1 files.

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

Finishing Touches
Generate docstrings
  • Commit to this branch
  • Create a new PR
Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

CodeRabbit Verify

  • Run CodeRabbit Verify to test the changes in this pull request.
Recent review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 99637868-e66a-476c-afbd-9fbe540e7f5e
Commits

Reviewing files that changed from the base of the PR and between 13cd69b and c00ab57.

Files selected for processing: 1
  • src/tpm2/TPMCmd/tpm/cryptolibs/Ossl/ExpDCache.c

Included review availability: This review used your included allowance. Your plan provides up to 2 included reviews per hour; 1 remain after this review.

@stefanberger
stefanberger merged commit 0c456c1 into master Nov 3, 2026
5 checks passed
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.

1 participant