From owner-freebsd-standards@FreeBSD.ORG Thu Jul 29 06:47:04 2010 Return-Path: Delivered-To: standards@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id D2C7B106567B for ; Thu, 29 Jul 2010 06:47:04 +0000 (UTC) (envelope-from yanegomi@gmail.com) Received: from mail-iw0-f182.google.com (mail-iw0-f182.google.com [209.85.214.182]) by mx1.freebsd.org (Postfix) with ESMTP id 9EED78FC16 for ; Thu, 29 Jul 2010 06:47:04 +0000 (UTC) Received: by iwn35 with SMTP id 35so18512iwn.13 for ; Wed, 28 Jul 2010 23:47:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:received:date:message-id :subject:from:to:cc:content-type; bh=PfbrF/DLX9A744swQLmQnRVov5qiVzIoq6BsbpuAUJg=; b=lExFND2Ak8gEyonrudVGXKnDWNWk31qZkXo/CBSN0n3a5OKN8+plmyoUL3bDDKwUcx Mf7fimwVnWeWd0QNEe9l+gXTHcTMfrzB/shDVgZX+1kHvST6piLy3k+WDzFjxOQngUHD rdsTe3+GsbEPFOgnDKUZzGWj3BcyyllzncNX8= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:cc:content-type; b=Q1BvQWIR85fm3mMdZpRpFsSiTk5/NebepRBJY0UdeZe5IJc4g9x3ogoyR13dyYoSiS GVxkxftgyt24+3J/DhfrAJZYW1+OkxDy1a5ZvdsX/fD6tpIUZnsjiJB22eJ7LhDMobbr qC8JCJL2y718pEW5624YhAF7Onffye4/qSCrI= MIME-Version: 1.0 Received: by 10.231.32.69 with SMTP id b5mr13331401ibd.153.1280386023537; Wed, 28 Jul 2010 23:47:03 -0700 (PDT) Received: by 10.231.169.18 with HTTP; Wed, 28 Jul 2010 23:47:03 -0700 (PDT) Date: Wed, 28 Jul 2010 23:47:03 -0700 Message-ID: From: Garrett Cooper To: alc@freebsd.org, Kostik Belousov Content-Type: text/plain; charset=ISO-8859-1 Cc: standards@freebsd.org Subject: POSIX compliance issue with mmap(2) X-BeenThere: freebsd-standards@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Standards compliance List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 29 Jul 2010 06:47:04 -0000 According to the page noted below [1], mmap(2) should fail if the value isn't page-aligned: [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. The current code in vm/vm_mmap.c only applies the check if MAP_FIXED is specified in flags: /* * Check for illegal addresses. Watch out for address wrap... Note * that VM_*_ADDRESS are not constants due to casts (argh). */ if (flags & MAP_FIXED) { /* * The specified address must have the same remainder * as the file offset taken modulo PAGE_SIZE, so it * should be aligned after adjustment by pageoff. */ addr -= pageoff; if (addr & PAGE_MASK) return (EINVAL); Our manpage states this requirement, but doesn't conform to the POSIX requirements. I verified this claim with the failing test [2] by changing MAP_SHARED to MAP_FIXED. The former case failed, while the latter case passed. Thoughts? -Garrett [1] http://www.opengroup.org/onlinepubs/000095399/functions/mmap.html [2] http://ltp.git.sourceforge.net/git/gitweb.cgi?p=ltp/ltp-dev.git;a=blob;f=testcases/open_posix_testsuite/conformance/interfaces/mmap/11-1.c;h=ed184a17591f0dbb5611ab70218a763a8a66b2df;hb=HEAD