libpriv/rpm-util: Query package repo checksum under lock #4673
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In general, libsolv isn't thread-safe.[1] There are multiple functions which return pointers that can be invalidated by other threads. It's hard to follow the libsolv side of this, but I think
solvable_lookup_bin_checksum()
(called bydnf_package_get_chksum()
) is such a case. Because we do importing in bulk using multi-threading, rpm-ostree triggers this bug.This is the root cause of #4565, where during the
cosa fetch
we embed the wrong repodata chksum_repr in the cached RPM's OSTree commit. So thencosa build
considers it a cache miss when it sees the mismatch and wants to redownload it.A trivial way to reproduce #4565 more easily is with:
Fix this by locking down this critical section. As mentioned in the comment, a more correct fix would be to not call unsafe libsolv APIs in the importer, but that'd require a larger rework. The locking added here doesn't appear to affect performance.
I've checked that we don't do any other unsafe libsolv calls in the importer path that could be subject to this.
Fixes: #4565