LWN: Comments on "Revisiting the MAP_SHARED_VALIDATE hack" https://lwn.net/Articles/758594/ This is a special feed containing comments posted to the individual LWN article titled "Revisiting the MAP_SHARED_VALIDATE hack". en-us Sat, 18 Oct 2025 14:08:48 +0000 Sat, 18 Oct 2025 14:08:48 +0000 https://www.rssboard.org/rss-specification lwn@lwn.net POSIX https://lwn.net/Articles/759640/ https://lwn.net/Articles/759640/ Wol <div class="FormattedComment"> Too many, probably :-(<br> <p> You've only got to set the flags you want in a variable that you forgot to initialise to zero...<br> <p> And what's the betting that programmers have done that in times gone by. We tend to be rather more careful now, having been bitten once too many.<br> <p> Cheers,<br> Wol<br> </div> Thu, 12 Jul 2018 14:35:46 +0000 Revisiting the MAP_SHARED_VALIDATE hack https://lwn.net/Articles/759636/ https://lwn.net/Articles/759636/ Wol <div class="FormattedComment"> What the documentation needs is a state table. Unfortunately these can be big.<br> <p> This gives us two things. (a) if it isn't in the state table it isn't guaranteed to work. And (b) if it should be in the state table then it's undefined.<br> <p> This brings me to one of my big programming bugbears - the state table of "do you want me to ignore these problems". When a programmer add the "do you want me to remember your choice?" they usually, only define three of the four possible states. "ignore error", "ignore error now and in future", and "fail on error". The option "fail on error and remember this choice" very rarely works :-(<br> <p> Cheers,<br> Wol<br> </div> Thu, 12 Jul 2018 14:22:13 +0000 Revisiting the MAP_SHARED_VALIDATE hack https://lwn.net/Articles/759091/ https://lwn.net/Articles/759091/ mina86 <div class="FormattedComment"> That doesn't clarify anything. What does it mean for an API to be stable? In particular, for this topic, is returning an “unsupported operation” error part of the API? <br> </div> Thu, 05 Jul 2018 12:14:05 +0000 POSIX https://lwn.net/Articles/758788/ https://lwn.net/Articles/758788/ josh <div class="FormattedComment"> What programs, in practice, called mmap with unknown flags and expected them to pass silently?<br> </div> Mon, 02 Jul 2018 00:07:32 +0000 Revisiting the MAP_SHARED_VALIDATE hack https://lwn.net/Articles/758775/ https://lwn.net/Articles/758775/ tao <div class="FormattedComment"> A much better rule: any export that isn't explicitly documented to be experimental, for internal use, testing purposes, or similar, can be considered to be a stable part of the API (unless serious security concerns necessitates its removal).<br> <p> While we ideally want all APIs to be well documented, I think it's a fair assumption that it's easier to simply to "document" the non-API than to write proper documentation for the API.<br> </div> Sun, 01 Jul 2018 16:38:16 +0000 POSIX https://lwn.net/Articles/758773/ https://lwn.net/Articles/758773/ corbet Sigh, it looks like I got caught going with what I thought I knew and not actually checking it, sorry. The behavior of <tt>mmap()</tt> <i>is</i> defined by decades of actual practice, though. Sun, 01 Jul 2018 14:05:28 +0000 Revisiting the MAP_SHARED_VALIDATE hack https://lwn.net/Articles/758769/ https://lwn.net/Articles/758769/ Jandar <div class="FormattedComment"> <font class="QuotedText">&gt; mmap() is not allowed (by standards like POSIX) to return an error when given unknown flags</font><br> <p> I've reread the relevant sections of POSIX and can't find this. Where in <a href="http://pubs.opengroup.org/onlinepubs/9699919799/">http://pubs.opengroup.org/onlinepubs/9699919799/</a> is mmap() prohibited from returning an error when given unknown flags?<br> </div> Sun, 01 Jul 2018 11:58:22 +0000 Revisiting the MAP_SHARED_VALIDATE hack https://lwn.net/Articles/758765/ https://lwn.net/Articles/758765/ willy <div class="FormattedComment"> POSIX allows functions to return errors that are not documented. For example, almost any syscall may return ENOMEM (maybe not getppid ;-)<br> <p> "Implementations may support additional errors not included in this list, may generate errors included in this list under circumstances other than those described here, or may contain extensions or limitations that prevent some errors from occurring." (1003.1-2017 section 2.3 of System Interfaces)<br> </div> Sun, 01 Jul 2018 05:35:59 +0000 Revisiting the MAP_SHARED_VALIDATE hack https://lwn.net/Articles/758755/ https://lwn.net/Articles/758755/ eru <div class="FormattedComment"> To me this smells like an implementation error made when mmap() was first introduced, which was later codified as official behaviour, because some user code failed to initialize all flag bits...<br> <p> </div> Sat, 30 Jun 2018 17:33:30 +0000 Revisiting the MAP_SHARED_VALIDATE hack https://lwn.net/Articles/758753/ https://lwn.net/Articles/758753/ smurf <div class="FormattedComment"> " mmap() is not allowed (by standards like POSIX) to return an error when given unknown flags."<br> <p> So f…ing what? not the first instance where Linux basically ignores POSIX because it makes no sense.<br> <p> Are there really programs out there that do call mmap() with random flag bits, or is that an overabundance of unnecessary caution?<br> </div> Sat, 30 Jun 2018 14:43:56 +0000 Revisiting the MAP_SHARED_VALIDATE hack https://lwn.net/Articles/758741/ https://lwn.net/Articles/758741/ Paf <div class="FormattedComment"> That’s sort of the point of Hyrum’s Law:<br> With enough users, we can’t. Some of the “we” won’t listen or will never get the chance to hear it or will be unable to follow the requirement (which is what the previous poster suggests). And for a big open project we can’t just say “you’re wrong, fix it”, at least, not if you want to keep users.<br> <p> So if you follow the Linus philosophy of “don’t break real users if at all possible” (and I think that’s almost the only sane way to run a big, open low level (ie many things built atop it) project like the kernel), then you’re extra stuck.<br> </div> Sat, 30 Jun 2018 13:06:40 +0000 Revisiting the MAP_SHARED_VALIDATE hack https://lwn.net/Articles/758733/ https://lwn.net/Articles/758733/ ballombe <div class="FormattedComment"> Alas, no documentation is complete enough to allow the programmer to relie solely on documented behaviour and not on implicit behaviour.<br> </div> Sat, 30 Jun 2018 10:21:33 +0000 Revisiting the MAP_SHARED_VALIDATE hack https://lwn.net/Articles/758725/ https://lwn.net/Articles/758725/ alison <div class="FormattedComment"> Perhaps we can simply agree that features of a library or interface that are not mentioned in the official documentation are not guaranteed to appear in future versions?<br> </div> Sat, 30 Jun 2018 05:21:07 +0000