Author: jhb
Date: Wed Apr 14 15:23:16 2010
New Revision: 206603
URL: http://svn.freebsd.org/changeset/base/206603

Log:
  MFC 205536:
  Reject attempts to create a MAP_ANON mapping with a non-zero offset.

Modified:
  stable/7/lib/libc/sys/mmap.2
  stable/7/sys/vm/vm_mmap.c
Directory Properties:
  stable/7/lib/libc/   (props changed)
  stable/7/lib/libc/stdtime/   (props changed)
  stable/7/sys/   (props changed)
  stable/7/sys/cddl/contrib/opensolaris/   (props changed)
  stable/7/sys/contrib/dev/acpica/   (props changed)
  stable/7/sys/contrib/pf/   (props changed)

Modified: stable/7/lib/libc/sys/mmap.2
==============================================================================
--- stable/7/lib/libc/sys/mmap.2        Wed Apr 14 15:22:58 2010        
(r206602)
+++ stable/7/lib/libc/sys/mmap.2        Wed Apr 14 15:23:16 2010        
(r206603)
@@ -105,7 +105,7 @@ The file descriptor used for creating
 must be \-1.
 The
 .Fa offset
-argument is ignored.
+argument must be 0.
 .\".It Dv MAP_FILE
 .\"Mapped from a regular file or character-special device memory.
 .It Dv MAP_FIXED
@@ -312,6 +312,11 @@ was negative.
 was specified and the
 .Fa fd
 argument was not -1.
+.It Bq Er EINVAL
+.Dv MAP_ANON
+was specified and the
+.Fa offset
+argument was not 0.
 .It Bq Er ENODEV
 .Dv MAP_ANON
 has not been specified and

Modified: stable/7/sys/vm/vm_mmap.c
==============================================================================
--- stable/7/sys/vm/vm_mmap.c   Wed Apr 14 15:22:58 2010        (r206602)
+++ stable/7/sys/vm/vm_mmap.c   Wed Apr 14 15:23:16 2010        (r206603)
@@ -232,7 +232,7 @@ mmap(td, uap)
        fp = NULL;
        /* make sure mapping fits into numeric range etc */
        if ((ssize_t) uap->len < 0 ||
-           ((flags & MAP_ANON) && uap->fd != -1))
+           ((flags & MAP_ANON) && (uap->fd != -1 || pos != 0)))
                return (EINVAL);
 
        if (flags & MAP_STACK) {
@@ -298,7 +298,6 @@ mmap(td, uap)
                handle = NULL;
                handle_type = OBJT_DEFAULT;
                maxprot = VM_PROT_ALL;
-               pos = 0;
        } else {
                /*
                 * Mapping file, get fp for validation. Obtain vnode and make
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to