Open dmik opened 3 years ago
Looking at https://github.com/bitwiseworks/gnupg-os2/blob/a8a4ff072648159e2f4d3c8581aa8c4c2e17201a/common/exechelp-posix.c#L838 it's pretty much obvious what's going on:
gcry_control (GCRYCTL_TERM_SECMEM)
._gcry_vcontrol
which calls __gcry_secmem_term
.wipememory2
that is a memset
implementation that attempts to securely clear some memory block at 0x21030000 which the parent allocates with mmap(MAP_PRIVATE|MAP_ANONYMOUS)
and expects the child to inherit.Since the memory is not actually inherited, it is unallocated in the child and a crash occurs.
Implementing this is not too difficult but requires some time.
DosAllocMemEx(OBJ_FORK)
in mmap.c
when allocating memory for MAP_PRIVATE to have the respective memory block be automatically "cloned" in the forked child by the LIBCn fork machinery.forkCompletion
in mmap.c
to recreate mmap structures in the forked child the same way we do it for MAP_SHARED mappings.
Currently, only MAP_SHARED mappings are preserved after
fork
but it appears that all mapping should be preserved, including MAP_PRIVATE ones (per POSIX):There is at least one program that assumes that: GnuPG. Calling
when
libgcrypt
is built with mmap support results in this crash: