Skip to content

libartifact: take store lock in extract and mount paths code - #1085

Open
goyaladitya05 wants to merge 1 commit into
podman-container-tools:mainfrom
goyaladitya05:libartifact-extract-locking
Open

libartifact: take store lock in extract and mount paths code#1085
goyaladitya05 wants to merge 1 commit into
podman-container-tools:mainfrom
goyaladitya05:libartifact-extract-locking

Conversation

@goyaladitya05

Copy link
Copy Markdown

BlobMountPaths(), Extract() and ExtractTarStream() call getArtifactAndImageSource() without holding the store lock, even though it requires one: it reads index.json via lookupArtifactLocked() and NewImageSource(). A concurrent add or remove rewriting index.json can cause these readers to fail or see inconsistent data. The problem was marked with FIX ME / LOCKING BUG comments in #522.

Take the read lock around the getArtifactAndImageSource() call and document the locking contract on the helper. The lock is deliberately not held while blob contents are read: blobs are content addressed and immutable, so a concurrent removal can at most cause a read to fail, never return wrong data. Holding the lock for the whole operation would block all writers for the duration of a potentially large extraction (or a slow client in the tar stream case) - the same tradeoff Add() already makes by unlocking around blob copying.

The write-side race in Add() (#483) is a separate problem and not addressed here.

Ref: podman-container-tools/podman#27264

Signed-off-by: Aditya Goyal <goyaladitya2403@gmail.com>
@github-actions github-actions Bot added the common Related to "common" package label Aug 16, 2026
@goyaladitya05
goyaladitya05 marked this pull request as ready for review August 16, 2026 10:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

common Related to "common" package

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant