1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-18 10:35:55 +00:00

Reject attempts to create a MAP_ANON mapping with a non-zero offset.

PR:		kern/71258
Submitted by:	Alexander Best
MFC after:	2 weeks
This commit is contained in:
John Baldwin 2010-03-23 21:08:07 +00:00
parent e4ee16b41e
commit 5711bf30da
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=205536
2 changed files with 7 additions and 3 deletions

View File

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

View File

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