Date: Thu, 30 Apr 2026 21:20:50 +0000 From: bugzilla-noreply@freebsd.org To: bugs@FreeBSD.org Subject: [Bug 294912] Linuxulator: munmap is missing EINVAL for unaligned addresses Message-ID: <bug-294912-227@https.bugs.freebsd.org/bugzilla/>
index | next in thread | raw e-mail
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=294912 Bug ID: 294912 Summary: Linuxulator: munmap is missing EINVAL for unaligned addresses Product: Base System Version: Unspecified Hardware: Any OS: Any Status: New Severity: Affects Only Me Priority: --- Component: kern Assignee: bugs@FreeBSD.org Reporter: iwtcex@gmail.com It might be acceptable for the native FreeBSD code to truncate the passed address to the nearest page boundary (I personally don't agree), but the actual Linux behavior is different and some Unity engine games inadvertently rely on it not to crash. https://store.steampowered.com/app/3605120/Trails is a good example. The reason is too stupid to be believed, but Mono apparently has a wrapper around mmap (mono_valloc_aligned) that is used to align addresses to the page boundaries. (Yes, the addresses from mmap. Yes, I'm aware they are already aligned. No, I have no idea what's wrong with those people.) To do that mono_valloc_aligned always mmaps one additional page, "aligns" the returned address and unmaps the excess memory. That kind of works for Mono because it doesn't seem to actually to invoke mono_valloc_aligned with sizes that are not divisible by 4096. The Unity game in question somehow does and by doing so unmaps the memory that it's actually using. See https://github.com/mono/mono/blob/0f53e9e151d92944cacab3e24ac359410c606df6/mono/utils/mono-mmap.c#L767 -- You are receiving this mail because: You are the assignee for the bug.home | help
Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?bug-294912-227>
