Bug 210313 - Man page mmap(2) incorrectly states hint alignment requirement
Man page mmap(2) incorrectly states hint alignment requirement
Status: CLOSED RAWHIDE
Product: Fedora
Classification: Fedora
Component: man (Show other bugs)
5
All Linux
medium Severity low
: ---
: ---
Assigned To: Ivana Varekova
Ben Levenson
:
Depends On:
Blocks:
  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:
Environment:
Last Closed: 2006-10-20 07:25:17 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
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:1.8.0.7) Gecko/20060915 Firefox/1.5.0.7

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.

and:

       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):
man-pages-2.21-1

How reproducible:
Always


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>

int
main()
{
        void *ptr;
        int fd;

        if ((fd = open("m.c", O_RDWR)) < 0) {
                perror("m.c");
                exit(1);
        }

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

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

        (void) close(fd);
        exit(0);
}

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.