Module Name: src Committed By: riastradh Date: Fri Mar 3 12:53:04 UTC 2023
Modified Files: src/lib/libc/sys: mremap.2 Log Message: mremap(2): Note MAP_REMAPDUP bug. XXX pullup-10, unless we fix the bug first To generate a diff of this commit: cvs rdiff -u -r1.8 -r1.9 src/lib/libc/sys/mremap.2 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/lib/libc/sys/mremap.2 diff -u src/lib/libc/sys/mremap.2:1.8 src/lib/libc/sys/mremap.2:1.9 --- src/lib/libc/sys/mremap.2:1.8 Wed Mar 1 20:08:41 2023 +++ src/lib/libc/sys/mremap.2 Fri Mar 3 12:53:04 2023 @@ -1,4 +1,4 @@ -.\" $NetBSD: mremap.2,v 1.8 2023/03/01 20:08:41 riastradh Exp $ +.\" $NetBSD: mremap.2,v 1.9 2023/03/03 12:53:04 riastradh Exp $ .\" .\" Copyright (c) 2007 Thomas Klausner and Joerg Sonnenberger .\" All rights reserved. @@ -231,3 +231,36 @@ system call appeared in It was based on the code that supports .Fn mremap compatibility for Linux binaries. +.Sh BUGS +If a mapping is created by +.Xr mmap 2 +with +.Dv MAP_PRIVATE +and then duplicated by +.Nm +with +.Dv MAP_REMAPDUP , +calling +.Xr fork 2 +destroys the coupling between the original and duplicate mapping. +Workarounds: +.Bl -dash +.It +Create the original mapping with +.Dv MAP_SHARED . +.It +Use +.Xr minherit 2 +with +.Dv MAP_INHERIT_NONE +on the writable mapping. +.It +Don't use +.Xr fork 2 ; +use +.Xr posix_spawn 2 . +.El +.Pp +See +.%U https://gnats.NetBSD.org/55177 +for details.