From owner-freebsd-hackers@FreeBSD.ORG Thu Oct 22 09:52:39 2009 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 6695A106566B; Thu, 22 Oct 2009 09:52:38 +0000 (UTC) (envelope-from ben.crowhurst@beatsystems.com) Received: from mail.beatsystems.com (mail.beatsystems.com [213.123.115.107]) by mx1.freebsd.org (Postfix) with ESMTP id C049B8FC1A; Thu, 22 Oct 2009 09:52:37 +0000 (UTC) Received: from localhost (localhost.localdomain [127.0.0.1]) by mail.beatsystems.com (Postfix) with ESMTP id 1BC8CFA6C; Thu, 22 Oct 2009 10:38:29 +0100 (BST) X-Virus-Scanned: amavisd-new at beatsystems.com Received: from mail.beatsystems.com ([127.0.0.1]) by localhost (mail.beatsystems.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 2My8UAiOyAiz; Thu, 22 Oct 2009 10:38:28 +0100 (BST) Received: from [192.168.0.116] (kohlrabi.beatsystems.com [192.168.0.116]) by mail.beatsystems.com (Postfix) with ESMTP id 9BBCBFA6B; Thu, 22 Oct 2009 10:38:27 +0100 (BST) Message-ID: <4AE02815.2010103@beatsystems.com> Date: Thu, 22 Oct 2009 10:38:29 +0100 From: Ben Crowhurst User-Agent: Thunderbird 2.0.0.23 (Windows/20090812) MIME-Version: 1.0 To: alc@freebsd.org References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: freebsd-hackers@freebsd.org, Alexander Best Subject: Re: mmap(2) with MAP_ANON honouring offset although it shouldn't X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: ben.crowhurst@beatsystems.com List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 22 Oct 2009 09:52:39 -0000 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*(), > 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