svn commit: r205536 - in head: lib/libc/sys sys/vm

John Baldwin jhb at FreeBSD.org
Tue Mar 23 21:08:07 UTC 2010


Author: jhb
Date: Tue Mar 23 21:08:07 2010
New Revision: 205536
URL: http://svn.freebsd.org/changeset/base/205536

Log:
  Reject attempts to create a MAP_ANON mapping with a non-zero offset.
  
  PR:		kern/71258
  Submitted by:	Alexander Best
  MFC after:	2 weeks

Modified:
  head/lib/libc/sys/mmap.2
  head/sys/vm/vm_mmap.c

Modified: head/lib/libc/sys/mmap.2
==============================================================================
--- head/lib/libc/sys/mmap.2	Tue Mar 23 20:12:53 2010	(r205535)
+++ head/lib/libc/sys/mmap.2	Tue Mar 23 21:08:07 2010	(r205536)
@@ -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_ANONYMOUS
@@ -316,6 +316,11 @@ was equal to zero.
 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: head/sys/vm/vm_mmap.c
==============================================================================
--- head/sys/vm/vm_mmap.c	Tue Mar 23 20:12:53 2010	(r205535)
+++ head/sys/vm/vm_mmap.c	Tue Mar 23 21:08:07 2010	(r205536)
@@ -233,7 +233,7 @@ mmap(td, uap)
 	/* Make sure mapping fits into numeric range, etc. */
 	if ((uap->len == 0 && !SV_CURPROC_FLAG(SV_AOUT) &&
 	     curproc->p_osrel >= 800104) ||
-	    ((flags & MAP_ANON) && uap->fd != -1))
+	    ((flags & MAP_ANON) && (uap->fd != -1 || pos != 0)))
 		return (EINVAL);
 
 	if (flags & MAP_STACK) {
@@ -300,7 +300,6 @@ mmap(td, uap)
 		handle = NULL;
 		handle_type = OBJT_DEFAULT;
 		maxprot = VM_PROT_ALL;
-		pos = 0;
 	} else {
 		/*
 		 * Mapping file, get fp for validation and


More information about the svn-src-all mailing list