Author: kib
Date: Wed Sep 17 21:04:50 2014
New Revision: 271724
URL: http://svnweb.freebsd.org/changeset/base/271724

Log:
  The vm_mmap_cdev() explicitely converts absence of both MAP_SHARED and
  MAP_PRIVATE flags to MAP_SHARED.  Apparently, some code in tree, in
  particular, libgeom, relied on this behaviour, see r271721.  For
  regular file types, the absence of the flags is interpreted as
  MAP_PRIVATE, and libc nlist used this (fixed in r271723).
  
  Allow the implicit flags for legacy binaries.  Bump __FreeBSD_version
  to get the ABI note on new binaries to check for in mmap code.
  
  Remove the test for presence of one of the MAP_ANON, MAP_SHARED or
  MAP_PRIVATE flags before fget_mmap().  For MAP_ANON, we already verify
  that passed fd == -1.  For fd != -1, test after fget_mmap() (for newer
  binaries) covers the case.
  
  Reported by:  bdrewery, pho
  Reviewed by:  jhb
  Sponsored by: The FreeBSD Foundation

Modified:
  head/sys/sys/param.h
  head/sys/vm/vm_mmap.c

Modified: head/sys/sys/param.h
==============================================================================
--- head/sys/sys/param.h        Wed Sep 17 20:26:27 2014        (r271723)
+++ head/sys/sys/param.h        Wed Sep 17 21:04:50 2014        (r271724)
@@ -58,7 +58,7 @@
  *             in the range 5 to 9.
  */
 #undef __FreeBSD_version
-#define __FreeBSD_version 1100035      /* Master, propagated to newvers */
+#define __FreeBSD_version 1100036      /* Master, propagated to newvers */
 
 /*
  * __FreeBSD_kernel__ indicates that this system uses the kernel of FreeBSD,
@@ -80,6 +80,7 @@
 #define        P_OSREL_SIGWAIT         700000
 #define        P_OSREL_SIGSEGV         700004
 #define        P_OSREL_MAP_ANON        800104
+#define        P_OSREL_MAP_FSTRICT     1100036
 
 #define        P_OSREL_MAJOR(x)        ((x) / 100000)
 #endif

Modified: head/sys/vm/vm_mmap.c
==============================================================================
--- head/sys/vm/vm_mmap.c       Wed Sep 17 20:26:27 2014        (r271723)
+++ head/sys/vm/vm_mmap.c       Wed Sep 17 21:04:50 2014        (r271724)
@@ -254,8 +254,7 @@ sys_mmap(td, uap)
                return (EINVAL);
        if ((flags & (MAP_EXCL | MAP_FIXED)) == MAP_EXCL)
                return (EINVAL);
-       if ((flags & (MAP_ANON | MAP_SHARED | MAP_PRIVATE)) == 0 ||
-           (flags & (MAP_SHARED | MAP_PRIVATE)) == (MAP_SHARED | MAP_PRIVATE))
+       if ((flags & (MAP_SHARED | MAP_PRIVATE)) == (MAP_SHARED | MAP_PRIVATE))
                return (EINVAL);
        if (prot != PROT_NONE &&
            (prot & ~(PROT_READ | PROT_WRITE | PROT_EXEC)) != 0)
@@ -356,6 +355,11 @@ sys_mmap(td, uap)
                error = fget_mmap(td, uap->fd, &rights, &cap_maxprot, &fp);
                if (error != 0)
                        goto done;
+               if ((flags & (MAP_SHARED | MAP_PRIVATE)) == 0 &&
+                   td->td_proc->p_osrel >= P_OSREL_MAP_FSTRICT) {
+                       error = EINVAL;
+                       goto done;
+               }
                if (fp->f_type == DTYPE_SHM) {
                        handle = fp->f_data;
                        handle_type = OBJT_SWAP;
_______________________________________________
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