From owner-freebsd-hackers@FreeBSD.ORG Wed Oct 21 17:51:10 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 78A111065692 for ; Wed, 21 Oct 2009 17:51:10 +0000 (UTC) (envelope-from alan.l.cox@gmail.com) Received: from mail-pw0-f44.google.com (mail-pw0-f44.google.com [209.85.160.44]) by mx1.freebsd.org (Postfix) with ESMTP id 4C3558FC0C for ; Wed, 21 Oct 2009 17:51:10 +0000 (UTC) Received: by pwj1 with SMTP id 1so1257432pwj.3 for ; Wed, 21 Oct 2009 10:51:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:reply-to:in-reply-to :references:date:message-id:subject:from:to:cc:content-type; bh=B+NG30OGs+ik45l73KN8DH0bXhwGM0Z/w6YueASDgPE=; b=pSPbYtzF4UpO22e37YMb1eppce2QkjC0AuR4o/d6d2QGlaZGCMXCrFJGHVU4Z0DynQ 1w/KhUy193L7W113bQkTHPoxBEnTtVAItHk/yAeunfuJCF1VKVxxDBtBtXSx0Y933DAZ txxHWy58C5LwZKibNbbo44uy/ERBt0/yVFEs0= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:reply-to:in-reply-to:references:date:message-id :subject:from:to:cc:content-type; b=LtO2zfph/FxXrJoEiKEo8+Djmlz95H93CMpeeXdyYXCQGJBmslGs4VRTsu+Ls8xbht IRDp+9TimIz/W3tAJLToIUER2BP/vskR6Kj1ZJtnkf+yzADzxu9pmRyXpOFLhPbbQOC7 YK7CW3LOFIlPRIXvKy1gchUg9MecMNSmpjL4Y= MIME-Version: 1.0 Received: by 10.143.129.7 with SMTP id g7mr579544wfn.336.1256147469959; Wed, 21 Oct 2009 10:51:09 -0700 (PDT) In-Reply-To: References: Date: Wed, 21 Oct 2009 12:51:09 -0500 Message-ID: From: Alan Cox To: Alexander Best Content-Type: text/plain; charset=ISO-8859-1 X-Content-Filtered-By: Mailman/MimeDel 2.1.5 Cc: freebsd-hackers@freebsd.org 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: alc@freebsd.org List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 21 Oct 2009 17:51:10 -0000 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