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

Ed Maste emaste at FreeBSD.org
Wed Feb 26 20:03:45 UTC 2020


Author: emaste
Date: Wed Feb 26 20:03:43 2020
New Revision: 358355
URL: https://svnweb.freebsd.org/changeset/base/358355

Log:
  Return ENOTSUP for mmap/mprotect if prot not subset of prot_max
  
  From POSIX,
  
  [ENOTSUP]
      The implementation does not support the combination of accesses
      requested in the prot argument.
  
  This fits the case that prot contains permissions which are not a subset
  of prot_max.
  
  Reviewed by:	brooks, cem
  Relnotes:	Yes
  Sponsored by:	The FreeBSD Foundation
  Differential Revision:	https://reviews.freebsd.org/D23843

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

Modified: head/lib/libc/sys/mmap.2
==============================================================================
--- head/lib/libc/sys/mmap.2	Wed Feb 26 19:39:59 2020	(r358354)
+++ head/lib/libc/sys/mmap.2	Wed Feb 26 20:03:43 2020	(r358355)
@@ -28,7 +28,7 @@
 .\"	@(#)mmap.2	8.4 (Berkeley) 5/11/95
 .\" $FreeBSD$
 .\"
-.Dd June 20, 2019
+.Dd February 26, 2020
 .Dt MMAP 2
 .Os
 .Sh NAME
@@ -432,11 +432,6 @@ An invalid value was passed in the
 .Fa prot
 argument.
 .It Bq Er EINVAL
-The
-.Fa prot
-argument contains permissions which are not a subset of the specified
-maximum permissions.
-.It Bq Er EINVAL
 An undefined option was set in the
 .Fa flags
 argument.
@@ -530,6 +525,11 @@ was specified and the
 argument was not available.
 .Dv MAP_ANON
 was specified and insufficient memory was available.
+.It Bq Er ENOTSUP
+The
+.Fa prot
+argument contains permissions which are not a subset of the specified
+maximum permissions.
 .El
 .Sh SEE ALSO
 .Xr madvise 2 ,

Modified: head/lib/libc/sys/mprotect.2
==============================================================================
--- head/lib/libc/sys/mprotect.2	Wed Feb 26 19:39:59 2020	(r358354)
+++ head/lib/libc/sys/mprotect.2	Wed Feb 26 20:03:43 2020	(r358355)
@@ -28,7 +28,7 @@
 .\"	@(#)mprotect.2	8.1 (Berkeley) 6/9/93
 .\" $FreeBSD$
 .\"
-.Dd June 20, 2019
+.Dd February 26, 2020
 .Dt MPROTECT 2
 .Os
 .Sh NAME
@@ -104,7 +104,7 @@ arguments is not valid.
 The
 .Fa prot
 argument contains unhandled bits.
-.It Bq Er EINVAL
+.It Bq Er ENOTSUP
 The
 .Fa prot
 argument contains permissions which are not a subset of the specified

Modified: head/sys/vm/vm_mmap.c
==============================================================================
--- head/sys/vm/vm_mmap.c	Wed Feb 26 19:39:59 2020	(r358354)
+++ head/sys/vm/vm_mmap.c	Wed Feb 26 20:03:43 2020	(r358355)
@@ -225,7 +225,7 @@ kern_mmap_fpcheck(struct thread *td, uintptr_t addr0, 
 	max_prot = PROT_MAX_EXTRACT(prot);
 	prot = PROT_EXTRACT(prot);
 	if (max_prot != 0 && (max_prot & prot) != prot)
-		return (EINVAL);
+		return (ENOTSUP);
 
 	p = td->td_proc;
 
@@ -668,7 +668,7 @@ kern_mprotect(struct thread *td, uintptr_t addr0, size
 	vm_error = KERN_SUCCESS;
 	if (max_prot != 0) {
 		if ((max_prot & prot) != prot)
-			return (EINVAL);
+			return (ENOTSUP);
 		vm_error = vm_map_protect(&td->td_proc->p_vmspace->vm_map,
 		    addr, addr + size, max_prot, TRUE);
 	}


More information about the svn-src-all mailing list