Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F153306043
D698.id1599.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
D698.id1599.diff
View Options
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
@@ -203,17 +203,17 @@
struct vnode *vp;
vm_offset_t addr;
vm_size_t size, pageoff;
- vm_prot_t cap_maxprot, prot, maxprot;
+ vm_prot_t cap_maxprot, maxprot;
void *handle;
objtype_t handle_type;
- int align, error, flags;
+ int align, error, flags, prot;
off_t pos;
struct vmspace *vms = td->td_proc->p_vmspace;
cap_rights_t rights;
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 +246,12 @@
}
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);
+ if (prot != PROT_NONE &&
+ (prot & ~(PROT_READ | PROT_WRITE | PROT_EXEC)) != 0)
+ return (EINVAL);
/*
* Align the file position to a page boundary,
@@ -415,6 +421,8 @@
map:
td->td_fpop = fp;
maxprot &= cap_maxprot;
+
+ /* This relies on VM_PROT_* matching PROT_*. */
error = vm_mmap(&vms->vm_map, &addr, size, prot, maxprot,
flags, handle_type, handle, pos);
td->td_fpop = NULL;
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Tue, Apr 21, 9:12 AM (14 h, 56 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
31901566
Default Alt Text
D698.id1599.diff (1 KB)
Attached To
Mode
D698: Add stricter checking of mmap() arguments.
Attached
Detach File
Event Timeline
Log In to Comment