Index: lib/libc/sys/mmap.2 =================================================================== --- lib/libc/sys/mmap.2 +++ lib/libc/sys/mmap.2 @@ -372,6 +372,25 @@ argument is not a valid open file descriptor. .It Bq Er EINVAL +An invalid value was passed in the +.Fa prot +argument. +.It Bq Er EINVAL +Both +.Dv MAP_PRIVATE +and +.Dv MAP_SHARED +were specified. +.It Bq Er EINVAL +None of +.Dv MAP_ANON , +.Dv MAP_PRIVATE , +.Dv MAP_SHARED , +or +.Dv MAP_STACK +was specified. +At least one of these flags must be included. +.It Bq Er EINVAL .Dv MAP_FIXED was specified and the .Fa addr Index: sys/vm/vm_mmap.c =================================================================== --- sys/vm/vm_mmap.c +++ sys/vm/vm_mmap.c @@ -211,9 +211,12 @@ struct vmspace *vms = td->td_proc->p_vmspace; cap_rights_t rights; + if ((uap->prot & ~(PROT_READ | PROT_WRITE | PROT_EXEC | PROT_NONE)) != 0) + return (EINVAL); + addr = (vm_offset_t) uap->addr; size = uap->len; - prot = uap->prot & VM_PROT_ALL; + prot = uap->prot; flags = uap->flags; pos = uap->pos; @@ -246,6 +249,9 @@ } 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)) + return (EINVAL); /* * Align the file position to a page boundary,