Home GnuPG
Diffusion GnuPG dc417bf0c555

gpg: Fix TOCTTOU when updating keyblocks.
dc417bf0c555Unpublished

Unpublished Commit ยท Learn More

Not On Permanent Ref: This commit is not an ancestor of any permanent ref.

Description

gpg: Fix TOCTTOU when updating keyblocks.

* g10/keydb.c (keydb_update_keyblock): Don't replace the record at the
current offset.  After taking the lock, extract the fingerprint from
the keyblock, find it and then replace it.

Between locating the record to update and actually updating the
keyblock, it is possible that another process modifies the keyring,
which causes the update to corrupt the keyring. This is due to a time
of check to time of use bug. The fix is straightforward: both
operations must be done while holding the lock. This changes the
semantics of the function slightly, but no callers need to be
modified. Further, it now becomes impossible to replace key A with B;
this function will only ever update B.

  • Signed-off-by: Neal H. Walfield <neal@g10code.com>
  • GnuPG-bug-id: T2193

Details

Provenance
Neal H. Walfield <neal@g10code.com>Authored on Dec 15 2015, 8:05 PM
Parents
rG02eb9fc9d586: Only add the user supplied CFLAGS after running any autoconf tests.
Branches
Unknown
Tags
Unknown

Event Timeline

Neal H. Walfield <neal@g10code.com> committed rGdc417bf0c555: gpg: Fix TOCTTOU when updating keyblocks. (authored by Neal H. Walfield <neal@g10code.com>).Dec 22 2015, 3:03 PM
neal mentioned this in Unknown Object (Maniphest Task).Mar 27 2017, 5:09 PM
neal mentioned this in Unknown Object (Maniphest Task).Mar 27 2017, 5:32 PM