Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 14 Apr 2010 15:23:16 +0000 (UTC)
From:      John Baldwin <jhb@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org
Subject:   svn commit: r206603 - in stable/7: lib/libc/sys sys/vm
Message-ID:  <201004141523.o3EFNGBY010040@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201004141523.o3EFNGBY010040>