Changeset View
Changeset View
Standalone View
Standalone View
head/sys/vm/vm_map.c
Show First 20 Lines • Show All 1,610 Lines • ▼ Show 20 Lines | vm_map_insert(vm_map_t map, vm_object_t object, vm_ooffset_t offset, | ||||
KASSERT(object == NULL || (cow & MAP_NOFAULT) == 0, | KASSERT(object == NULL || (cow & MAP_NOFAULT) == 0, | ||||
("vm_map_insert: paradoxical MAP_NOFAULT request")); | ("vm_map_insert: paradoxical MAP_NOFAULT request")); | ||||
KASSERT((prot & ~max) == 0, | KASSERT((prot & ~max) == 0, | ||||
("prot %#x is not subset of max_prot %#x", prot, max)); | ("prot %#x is not subset of max_prot %#x", prot, max)); | ||||
/* | /* | ||||
* Check that the start and end points are not bogus. | * Check that the start and end points are not bogus. | ||||
*/ | */ | ||||
if (start < vm_map_min(map) || end > vm_map_max(map) || | if (!vm_map_range_valid(map, start, end)) | ||||
start >= end) | |||||
return (KERN_INVALID_ADDRESS); | return (KERN_INVALID_ADDRESS); | ||||
/* | /* | ||||
* Find the entry prior to the proposed starting address; if it's part | * Find the entry prior to the proposed starting address; if it's part | ||||
* of an existing entry, this range is bogus. | * of an existing entry, this range is bogus. | ||||
*/ | */ | ||||
if (vm_map_lookup_entry(map, start, &prev_entry)) | if (vm_map_lookup_entry(map, start, &prev_entry)) | ||||
return (KERN_NO_SPACE); | return (KERN_NO_SPACE); | ||||
▲ Show 20 Lines • Show All 527 Lines • ▼ Show 20 Lines | if (find_space != VMFS_ANY_SPACE && | ||||
curr_min_addr = min_addr; | curr_min_addr = min_addr; | ||||
cluster = update_anon; | cluster = update_anon; | ||||
try = 0; | try = 0; | ||||
goto again; | goto again; | ||||
} | } | ||||
goto done; | goto done; | ||||
} | } | ||||
} else if ((cow & MAP_REMAP) != 0) { | } else if ((cow & MAP_REMAP) != 0) { | ||||
if (*addr < vm_map_min(map) || | if (!vm_map_range_valid(map, *addr, *addr + length)) { | ||||
*addr + length > vm_map_max(map) || | |||||
*addr + length <= length) { | |||||
rv = KERN_INVALID_ADDRESS; | rv = KERN_INVALID_ADDRESS; | ||||
goto done; | goto done; | ||||
} | } | ||||
vm_map_delete(map, *addr, *addr + length); | vm_map_delete(map, *addr, *addr + length); | ||||
} | } | ||||
if ((cow & (MAP_STACK_GROWS_DOWN | MAP_STACK_GROWS_UP)) != 0) { | if ((cow & (MAP_STACK_GROWS_DOWN | MAP_STACK_GROWS_UP)) != 0) { | ||||
rv = vm_map_stack_locked(map, *addr, length, sgrowsiz, prot, | rv = vm_map_stack_locked(map, *addr, length, sgrowsiz, prot, | ||||
max, cow); | max, cow); | ||||
▲ Show 20 Lines • Show All 2,144 Lines • ▼ Show 20 Lines | vm_map_stack_locked(vm_map_t map, vm_offset_t addrbos, vm_size_t max_ssize, | ||||
* Extract it into orient and mask the cow argument so that we | * Extract it into orient and mask the cow argument so that we | ||||
* don't pass it around further. | * don't pass it around further. | ||||
*/ | */ | ||||
orient = cow & (MAP_STACK_GROWS_DOWN | MAP_STACK_GROWS_UP); | orient = cow & (MAP_STACK_GROWS_DOWN | MAP_STACK_GROWS_UP); | ||||
KASSERT(orient != 0, ("No stack grow direction")); | KASSERT(orient != 0, ("No stack grow direction")); | ||||
KASSERT(orient != (MAP_STACK_GROWS_DOWN | MAP_STACK_GROWS_UP), | KASSERT(orient != (MAP_STACK_GROWS_DOWN | MAP_STACK_GROWS_UP), | ||||
("bi-dir stack")); | ("bi-dir stack")); | ||||
if (addrbos < vm_map_min(map) || | if (max_ssize == 0 || | ||||
addrbos + max_ssize > vm_map_max(map) || | !vm_map_range_valid(map, addrbos, addrbos + max_ssize)) | ||||
addrbos + max_ssize <= addrbos) | |||||
return (KERN_INVALID_ADDRESS); | return (KERN_INVALID_ADDRESS); | ||||
sgp = ((curproc->p_flag2 & P2_STKGAP_DISABLE) != 0 || | sgp = ((curproc->p_flag2 & P2_STKGAP_DISABLE) != 0 || | ||||
(curproc->p_fctl0 & NT_FREEBSD_FCTL_STKGAP_DISABLE) != 0) ? 0 : | (curproc->p_fctl0 & NT_FREEBSD_FCTL_STKGAP_DISABLE) != 0) ? 0 : | ||||
(vm_size_t)stack_guard_page * PAGE_SIZE; | (vm_size_t)stack_guard_page * PAGE_SIZE; | ||||
if (sgp >= max_ssize) | if (sgp >= max_ssize) | ||||
return (KERN_INVALID_ARGUMENT); | return (KERN_INVALID_ARGUMENT); | ||||
init_ssize = growsize; | init_ssize = growsize; | ||||
▲ Show 20 Lines • Show All 839 Lines • Show Last 20 Lines |