Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 22 Oct 2009 10:38:29 +0100
From:      Ben Crowhurst <ben.crowhurst@beatsystems.com>
To:        alc@freebsd.org
Cc:        freebsd-hackers@freebsd.org, Alexander Best <alexbestms@math.uni-muenster.de>
Subject:   Re: mmap(2) with MAP_ANON honouring offset although it shouldn't
Message-ID:  <4AE02815.2010103@beatsystems.com>
In-Reply-To: <ca3526250910211051v2fef55e7yda262a58df200751@mail.gmail.com>
References:  <permail-200910211551041e86ffa80000182a-a_best01@message-id.uni-muenster.de> <ca3526250910211051v2fef55e7yda262a58df200751@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
Alan Cox wrote:
> On Wed, Oct 21, 2009 at 10:51 AM, Alexander Best <
> alexbestms@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,
>> 0x12345678));
>>
>> and
>>
>> 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
>> to
>> 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
> *sysconf*()<http://www.opengroup.org/onlinepubs/000095399/functions/sysconf.html>,
> 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.
>
> Regards,
> Alan
> _______________________________________________
> freebsd-hackers@freebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
> To unsubscribe, send any mail to "freebsd-hackers-unsubscribe@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.

Cheers,
Ben



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?4AE02815.2010103>