Date: Wed, 28 Jul 2010 23:47:03 -0700 From: Garrett Cooper <yanegomi@gmail.com> To: alc@freebsd.org, Kostik Belousov <kostikbel@gmail.com> Cc: standards@freebsd.org Subject: POSIX compliance issue with mmap(2) Message-ID: <AANLkTim1Dtn4bkWBtMVWV_2JwxCr0GdxwBXeJHK=td5Z@mail.gmail.com>
next in thread | raw e-mail | index | archive | help
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?AANLkTim1Dtn4bkWBtMVWV_2JwxCr0GdxwBXeJHK=td5Z>