mmap(2) with MAP_ANON honouring offset although it shouldn't
ben.crowhurst at beatsystems.com
Thu Oct 22 09:52:39 UTC 2009
Alan Cox wrote:
> On Wed, Oct 21, 2009 at 10:51 AM, Alexander Best <
> alexbestms at math.uni-muenster.de> wrote:
>> although the mmap(2) manual states in section MAP_ANON:
>> "The offset argument is ignored."
>> this doesn't seem to be true. running
>> printf("%p\n", mmap((void*)0x1000, 0x1000, PROT_NONE, MAP_ANON, -1,
>> printf("%p\n", mmap((void*)0x1000, 0x1000, PROT_NONE, MAP_ANON, -1, 0));
>> produces different outputs. i've attached a patch to solve the problem. the
>> patch is similar to the one proposed in this PR, but should apply cleanly
>> CURRENT: http://www.freebsd.org/cgi/query-pr.cgi?pr=kern/71258
> The standards for mmap(2) actually disallow values of "off" that are not a
> multiple of the page size.
> See http://www.opengroup.org/onlinepubs/000095399/functions/mmap.html for
> the following:
> [EINVAL]The *addr* argument (if MAP_FIXED was specified) or *off* is not a
> multiple of the page size as returned by
> or is considered invalid by the implementation.Both Solaris and Linux
> enforce this restriction.
> I'm not convinced that the ability to specify a value for "off" that is not
> a multiple of the page size is a useful differentiating feature of FreeBSD
> versus Solaris or Linux. Does anyone have a compelling argument (or use
> case) to motivate us being different in this respect?
> If you disallow values for "off" that are not a multiple of the page size,
> then you are effectively ignoring "off" for MAP_ANON.
> freebsd-hackers at freebsd.org mailing list
> To unsubscribe, send any mail to "freebsd-hackers-unsubscribe at freebsd.org"
would it be such a bad idea as to round up the addr/off arguments to the
next page size? This was most likely the intention of the caller anyway.
More information about the freebsd-hackers