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
This commit is contained in:
Ed Maste 2020-02-26 20:03:43 +00:00
parent 2a12053589
commit acb8858f05
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=358355
3 changed files with 10 additions and 10 deletions

View File

@ -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 ,

View File

@ -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

View File

@ -225,7 +225,7 @@ kern_mmap_fpcheck(struct thread *td, uintptr_t addr0, size_t len, int prot,
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_t size, int prot)
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);
}