summaryrefslogtreecommitdiff
path: root/lib/libc
diff options
context:
space:
mode:
authorriastradh <riastradh@NetBSD.org>2023-03-03 12:53:04 +0000
committerriastradh <riastradh@NetBSD.org>2023-03-03 12:53:04 +0000
commitca2fea71db5a7eaf4fb3089b259125dd007bf32f (patch)
tree3da7adab8941c25876742634445a45b5dd701b80 /lib/libc
parentf1f59b27f72f8ff8c2e102950a2bd343ca0f468a (diff)
mremap(2): Note MAP_REMAPDUP bug.
XXX pullup-10, unless we fix the bug first
Diffstat (limited to 'lib/libc')
-rw-r--r--lib/libc/sys/mremap.235
1 files changed, 34 insertions, 1 deletions
diff --git a/lib/libc/sys/mremap.2 b/lib/libc/sys/mremap.2
index 2908979c441..0762bb45b89 100644
--- a/lib/libc/sys/mremap.2
+++ b/lib/libc/sys/mremap.2
@@ -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.