Skip to content

fix concurrent writes/reads in keyring#342

Merged
tgross merged 1 commit intomasterfrom
gh341-keyring-lock
Jan 21, 2026
Merged

fix concurrent writes/reads in keyring#342
tgross merged 1 commit intomasterfrom
gh341-keyring-lock

Conversation

@tgross
Copy link
Member

@tgross tgross commented Jan 20, 2026

The keyring has several data races between its public methods where we read from or iterate over the keyring without taking the mutex. A concurrent AddKey, RemoveKey, or UseKey call can write to the location being read.

Move some of the data read functions into private methods that expect the lock to be held, and hold that lock in the public methods.

Fixes: #341

Description

Related Issue

How Has This Been Tested?

The keyring has several data races between its public methods where we read from
or iterate over the keyring without taking the mutex. A concurrent `AddKey`,
`RemoveKey`, or `UseKey` call can write to the location being read.

Move some of the data read functions into private methods that expect the lock
to be held, and hold that lock in the public methods.

Fixes: #341
@tgross tgross force-pushed the gh341-keyring-lock branch from f435b01 to 47c31d9 Compare January 20, 2026 14:59
@tgross tgross marked this pull request as ready for review January 20, 2026 15:12
@tgross tgross requested a review from a team as a code owner January 20, 2026 15:12
@tgross tgross merged commit 313d20c into master Jan 21, 2026
13 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.

Issue: Race condition in Keyring.AddKey() - missing lock protection

3 participants