-
-
Notifications
You must be signed in to change notification settings - Fork 36.1k
mmap.resize() crashes on NetBSD when growing a shared anonymous mapping #154258
Copy link
Copy link
Closed
Labels
3.13bugs and security fixesbugs and security fixes3.14bugs and security fixesbugs and security fixes3.15pre-release feature fixes, bugs and security fixespre-release feature fixes, bugs and security fixes3.16new features, bugs and security fixesnew features, bugs and security fixesOS-netbsdextension-modulesC modules in the Modules dirC modules in the Modules dirtype-crashA hard crash of the interpreter, possibly with a core dumpA hard crash of the interpreter, possibly with a core dump
Description
Activity
Metadata
Metadata
Assignees
Labels
3.13bugs and security fixesbugs and security fixes3.14bugs and security fixesbugs and security fixes3.15pre-release feature fixes, bugs and security fixespre-release feature fixes, bugs and security fixes3.16new features, bugs and security fixesnew features, bugs and security fixesOS-netbsdextension-modulesC modules in the Modules dirC modules in the Modules dirtype-crashA hard crash of the interpreter, possibly with a core dumpA hard crash of the interpreter, possibly with a core dump
Crash report
On NetBSD,
mmap.resize()crashes (SIGSEGV) when growing a shared anonymous mapping:resize()returns without error and the original page is still readable, but the grown region is not backed, so accessing it crashes.The cause is NetBSD's
mremap(): growing aMAP_SHARED | MAP_ANONmapping returns a mapping whose new region is unmapped (verified with a standalone C program — aMAP_PRIVATEanonymous mapping grows correctly, aMAP_SHAREDone does not). This is the same behaviour as the Linux kernel bug thatModules/mmapmodule.calready guards against for__linux__(https://bugzilla.kernel.org/show_bug.cgi?id=8691); Linux later mademremap()reject the grow, but NetBSD still returns the broken mapping. Because NetBSD'smremap()does not returnMAP_FAILED, the failure can't be detected from its return value.The NetBSD behaviour is undocumented (not in the
mremap(2)BUGS section) and appears unreported upstream.Fix: reject growing a shared anonymous mapping on NetBSD with
ValueError, as is already done on Linux.Linked PRs