[PATCH 1/1]: Fix Memory-map and Double-free Errors in Statistics Handling (was Re: Connman-0.67 Crashes and/or Hangs on Start-up)

Daniel Wagner wagi at monom.org
Mon Jan 31 01:47:03 PST 2011


Hi Grant,

On Fri, Jan 28, 2011 at 08:13:28PM -0800, Grant Erickson wrote:
> As far as I can see, the stats mapping is not published or shared outside of
> connman. If so, there's no reason to map it SHARED versus PRIVATE.

>From the mmap man pages:

MAP_SHARED 

	   Share this mapping.  Updates to the mapping are visible to
           other processes that map this file, and are carried through
           to the underlying file.  The file may not actually be
           updated until msync(2) or munmap() is called.

MAP_PRIVATE

           Create a private copy-on-write mapping.  Updates to the
           mapping are not visible to other processes mapping the same
           file, and are not carried through to the underlying file.
           It is unspecified whether changes made to the file after
           the mmap() call are visible in the mapped region.

The reason for picking MAP_SHARED was to be sure the changes in buffer
really hits the file. I read that MAP_PRIVATE does not garantee this.
This is reason I was picking MAP_SHARED together with msync.

cheers,
daniel



More information about the connman mailing list