Bug 210313 - Man page mmap(2) incorrectly states hint alignment requirement
Man page mmap(2) incorrectly states hint alignment requirement
Product: Fedora
Classification: Fedora
Component: man (Show other bugs)
All Linux
medium Severity low
: ---
: ---
Assigned To: Ivana Varekova
Ben Levenson
Depends On:
  Show dependency treegraph
Reported: 2006-10-11 10:34 EDT by William Kucharski
Modified: 2007-11-30 17:11 EST (History)
0 users

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2006-10-20 07:25:17 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)

  None (edit)
Description William Kucharski 2006-10-11 10:34:21 EDT
From Bugzilla Helper:
User-Agent: Mozilla/5.0 (X11; U; SunOS i86pc; en-US; rv: Gecko/20060915 Firefox/

Description of problem:
The man page for mmap(2) states the following concerning the address hint passed to mmap():

       The  address  start must be a multiple of the page size.


       EINVAL We  don't  like  start or length or offset.  (E.g., they are too
              large, or not aligned on a PAGESIZE boundary.)

In fact, if "start" is unaligned, it is rounded up to the next PAGESIZE boundary by mmap(2).  No error is returned unless MAP_FIXED is specified.

Instead, the man page should state that if "start" is an unaligned address hint, it will be rounded up to the next PAGESIZE boundary.

Version-Release number of selected component (if applicable):

How reproducible:

Steps to Reproduce:
1. Save the following program as m.c:

#include <sys/mman.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>

        void *ptr;
        int fd;

        if ((fd = open("m.c", O_RDWR)) < 0) {

        if ((ptr = mmap((void *)1, 0x500, PROT_READ, MAP_SHARED, fd,
            0)) == MAP_FAILED) {
                (void) close(fd);
                exit (1);

        printf("mmap #1 succeeded, ptr @ %p = 0x%x\n", ptr, *(int *)ptr);

        (void) close(fd);

2. Compile m.c (gcc m.c)

3. Run the program and notice it does not fail with EINVAL.

Actual Results:
# ./a.out
mmap #1 succeeded, ptr @ 0x1000 = 0x636e6923

Expected Results:
According to the man page, this should have failed with the same results given if MAP_FIXED is specified:

mmap: Invalid argument

Additional info:
Comment 1 Ivana Varekova 2006-10-20 07:25:17 EDT
Fixed in man-pages-2.41-2.fc7.

Note You need to log in before you can comment on or make changes to this bug.