Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F165144786
D55888.id173826.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
D55888.id173826.diff
View Options
diff --git a/sys/vm/vm_mmap.c b/sys/vm/vm_mmap.c
--- a/sys/vm/vm_mmap.c
+++ b/sys/vm/vm_mmap.c
@@ -236,10 +236,13 @@
*/
if (!SV_CURPROC_FLAG(SV_AOUT)) {
if ((len == 0 && p->p_osrel >= P_OSREL_MAP_ANON) ||
- ((flags & MAP_ANON) != 0 && (fd != -1 || pos != 0))) {
- return (EXTERROR(EINVAL,
- "offset %#jd not zero/fd %#jd not -1 for MAP_ANON",
- fd, pos));
+ ((flags & MAP_ANON) != 0)) {
+ if (fd != -1)
+ return (EXTERROR(EINVAL,
+ "fd %#jd not -1 for MAP_ANON", fd));
+ else if (pos != 0)
+ return (EXTERROR(EINVAL,
+ "offset %#jd not zero for MAP_ANON", pos));
}
} else {
if ((flags & MAP_ANON) != 0)
@@ -271,10 +274,6 @@
return (EXTERROR(EINVAL,
"both SHARED and PRIVATE set (flags %#jx)", flags));
}
- if (prot != PROT_NONE &&
- (prot & ~(PROT_READ | PROT_WRITE | PROT_EXEC)) != 0) {
- return (EXTERROR(EINVAL, "invalid prot %#jx", prot));
- }
if ((flags & MAP_GUARD) != 0 && (prot != PROT_NONE || fd != -1 ||
pos != 0 || (flags & ~(MAP_FIXED | MAP_GUARD | MAP_EXCL |
MAP_32BIT | MAP_ALIGNMENT_MASK)) != 0)) {
@@ -297,10 +296,14 @@
/* Ensure alignment is at least a page and fits in a pointer. */
align = flags & MAP_ALIGNMENT_MASK;
- if (align != 0 && align != MAP_ALIGNED_SUPER &&
- (align >> MAP_ALIGNMENT_SHIFT >= sizeof(void *) * NBBY ||
- align >> MAP_ALIGNMENT_SHIFT < PAGE_SHIFT)) {
- return (EXTERROR(EINVAL, "bad alignment %#jx", align));
+ if (align != 0 && align != MAP_ALIGNED_SUPER) {
+ if (align >> MAP_ALIGNMENT_SHIFT >= sizeof(void *) * NBBY)
+ return (EXTERROR(EINVAL, "bad alignment %#jx >= %#jx",
+ align >> MAP_ALIGNMENT_SHIFT,
+ sizeof(void *) * NBBY));
+ else if (align >> MAP_ALIGNMENT_SHIFT < PAGE_SHIFT)
+ return (EXTERROR(EINVAL, "bad alignment %#jx < %#jx",
+ align >> MAP_ALIGNMENT_SHIFT, PAGE_SHIFT));
}
/*
@@ -316,15 +319,17 @@
addr -= pageoff;
if ((addr & PAGE_MASK) != 0) {
return (EXTERROR(EINVAL,
- "fixed mapping at %#jx not aligned", addr));
+ "fixed mapping at %#jx not page aligned %#jx", addr,
+ PAGE_SIZE));
}
/* Address range must be all in user VM space. */
if (!vm_map_range_valid(&vms->vm_map, addr, addr + size)) {
- EXTERROR(EINVAL, "mapping outside vm_map");
- return (EINVAL);
+ return (EXTERROR(EINVAL,
+ "mapping %#jx-%#jx outside vm_map", addr,
+ addr + size));
}
- if (flags & MAP_32BIT && addr + size > MAP_32BIT_MAX_ADDR) {
+ if ((flags & MAP_32BIT) && addr + size > MAP_32BIT_MAX_ADDR) {
return (EXTERROR(EINVAL,
"fixed 32bit mapping of [%#jx %#jx] does not fit into 4G",
addr, addr + size));
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Aug 7, 9:34 AM (5 h, 52 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
36160968
Default Alt Text
D55888.id173826.diff (2 KB)
Attached To
Mode
D55888: Refinement of extended errors for mmap(2)
Attached
Detach File
Event Timeline
Log In to Comment