Page MenuHome GnuPG

libgcrypt: Fix for lock behavior broken in 1.8.3
Closed, ResolvedPublic

Description

Originally sent to gnupg-devel@, but not sure if that's going to get through so submitting here. Apologies for potential duplication.


In commit 0da4a237661cd273303ae6baaaba2d9f6292b990 calls to "lock_rng"
and "unlock_rng" were introduced and are causing hanging on musl as
well as on Darwin.

It looks like the problem is that within this lock/unlock pair the
code calls a function that itself tries
to obtain the same rng lock-- which is where things hang.

Attached is a patch that fixes this problem in a minimally intrusive way,
but is somewhat suboptimal as the same lock will be
obtained/released/obtained/released back-to-back.

I'm unsure why this behavior is not problematic when using glibc,
haven't investigated.

Hopefully this is useful and please let me know if this is incorrect
for some reason.

Details

Version
1.8.3

Event Timeline

Investigated the "why not with glibc" question this morning, appears that the test triggering the hanging behavior (version) happens to not be linked with -pthread and so locking calls do nothing. Manually adding -pthread causes it to hang with glibc as well.

gniibe added a subscriber: gniibe.

Thanks for your report.
You are right.
Simply getting the information for "rng-type" through gcry_rndjent_get_version will hang.

And I agree that your patch is the best for a while (simple enough, even sub-optimal); I leave further change to the original author of rndjent.

gniibe changed the task status from Open to Testing.Jun 19 2018, 5:58 AM

Fixed in repo (master and 1.8 branch).

gniibe triaged this task as Normal priority.Jun 19 2018, 5:59 AM