mirror of
https://github.com/freebsd/freebsd-src.git
synced 2024-12-03 23:28:57 +00:00
Add checks to vm_map_findspace() to test for address wrap. The conditions
where this could occur are very rare, but possible. Submitted by: Mark W. Krentel MFC after: 2 weeks
This commit is contained in:
parent
c4dc6d1307
commit
986b43f845
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=140439
@ -1009,10 +1009,13 @@ vm_map_findspace(vm_map_t map, vm_offset_t start, vm_size_t length,
|
||||
vm_map_entry_t entry;
|
||||
vm_offset_t end, st;
|
||||
|
||||
/* Request must fit within min/max VM address. */
|
||||
/*
|
||||
* Request must fit within min/max VM address and must avoid
|
||||
* address wrap.
|
||||
*/
|
||||
if (start < map->min_offset)
|
||||
start = map->min_offset;
|
||||
if (start + length > map->max_offset)
|
||||
if (start + length > map->max_offset || start + length < start)
|
||||
return (1);
|
||||
|
||||
/* Empty tree means wide open address space. */
|
||||
@ -1033,10 +1036,11 @@ vm_map_findspace(vm_map_t map, vm_offset_t start, vm_size_t length,
|
||||
|
||||
/*
|
||||
* Root is the last node that might begin its gap before
|
||||
* start.
|
||||
* start, and this is the last comparison where address
|
||||
* wrap might be a problem.
|
||||
*/
|
||||
st = (start > map->root->end) ? start : map->root->end;
|
||||
if (st + length <= map->root->end + map->root->adj_free) {
|
||||
if (length <= map->root->end + map->root->adj_free - st) {
|
||||
*addr = st;
|
||||
goto found;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user