Home GnuPG
Diffusion GnuPG 456a3a8e93ea

gpg: Fix trustdb updates without lock held.

Description

gpg: Fix trustdb updates without lock held.

* g10/tdbio.c (is_locked): Turn into a counter.
(take_write_lock, release_write_lock): Implement recursive locks.

On trustdb creation we have this call sequence:

init_trustdb                 -> takes lock
  tdbio_set_dbname
    create_version_record
     tdbio_write_record
       put_record_into_cache -> takes lock
       put_record_into_cache -> releases lock
init_trustdb                 -> releases lock

The second take lock does noting but the first release lock has
already released the lock and the second release lock is a thus a NOP.
This is likely the cause for the corrupted trustdb as reported in

  • GnuPG-bug-id: T3839
  • Signed-off-by: Werner Koch <wk@gnupg.org>

Details

Provenance
wernerAuthored on Mar 26 2018, 4:57 PM
Parents
rG5f00531463eb: gpg: Disable unused code parts in tdbio.c
Branches
Unknown
Tags
Unknown
Tasks
T3839: Trustdb corrupted after fresh install of Gpg4win