cpg: Memory not unmapped in cpg_zcb_free
Function in cpg_zcb_alloc (from code lib/cpg.c) creates
/dev/shm/corosync_zerocopy-XXXXX and does mmap
The memory is allocated by corosync service (function zcb_alloc
in exec/cpg.c) also and both shares this memory via mmap
(uses MAP_SHARED in mmap call)
Corosync calls unlink which deletes the file from /dev/shm while
closing the file descriptor, but unmap is not happening correctly
while calling cpg_zcb_free.
So:
- still the deleted file holds the memory
- As munmap is not happening correctly, the number of mappings per process gets exceeded and corosync dies with ENOMEM
From gdb, the size passed to munmap appears to be zero and address
looks wrong. Also in the code return code of munmap is not checked.
The patch adds check for:
- munmap return code and getting correct address for munmap
Signed-off-by: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
Reviewed-by: Jan Friesse <jfriesse@redhat.com>