Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/lib/libc/sys mremap(2): Note MAP_REMAPDUP bug.



details:   https://anonhg.NetBSD.org/src/rev/88dfdb366f40
branches:  trunk
changeset: 373810:88dfdb366f40
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Fri Mar 03 12:53:04 2023 +0000

description:
mremap(2): Note MAP_REMAPDUP bug.

XXX pullup-10, unless we fix the bug first

diffstat:

 lib/libc/sys/mremap.2 |  35 ++++++++++++++++++++++++++++++++++-
 1 files changed, 34 insertions(+), 1 deletions(-)

diffs (46 lines):

diff -r 7346eb9d82d1 -r 88dfdb366f40 lib/libc/sys/mremap.2
--- a/lib/libc/sys/mremap.2     Fri Mar 03 12:52:49 2023 +0000
+++ b/lib/libc/sys/mremap.2     Fri Mar 03 12:53:04 2023 +0000
@@ -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 @@
 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.



Home | Main Index | Thread Index | Old Index