Skip to content

rd: fix concurrent first load of libwolfprov - #516

Open
ColtonWilley wants to merge 1 commit into
wolfSSL:masterfrom
ColtonWilley:fix/rd-dso-load-once
Open

ColtonWilley wants to merge 1 commit into
wolfSSL:masterfrom
ColtonWilley:fix/rd-dso-load-once

Conversation

@ColtonWilley

Copy link
Copy Markdown
Contributor

In replace-default mode, load_wolfprov_and_init published its static DSO before DSO_load() finished, so threads making their first provider activation in different libctxs could bind an unloaded DSO (provider init fails) or double-free it. The DSO is now loaded locally and published under a lock; failed loads still retry.

load_wolfprov_and_init published the static DSO before DSO_load()
finished, so concurrent first activations in separate libctxs bound an
unloaded DSO or freed it under each other. Load into a local DSO and
publish it under a lock.
Copilot AI balanced review requested due to automatic review settings October 26, 2026 21:16

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The locking and ownership changes address the reported race without identified blocking issues.

No open issues 🎉

What changed in this PR

Fixes concurrent first-time loading of libwolfprov in replace-default mode by publishing the shared DSO only after loading completes.

Changes:

  • Adds a once-initialized lock to protect shared DSO access.
  • Loads each candidate DSO locally, publishes it under the lock, and frees redundant candidates.
  • Keeps loading outside the lock and preserves retries after load failures.
File Description
patches/​provider_predefined.c.replace-default Synchronizes DSO publication and safely handles concurrent loaders.

Review effort: Balanced

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