Changeset View
Changeset View
Standalone View
Standalone View
head/sys/vm/vm_map.c
Show First 20 Lines • Show All 1,481 Lines • ▼ Show 20 Lines | |||||
} | } | ||||
static const int aslr_pages_rnd_64[2] = {0x1000, 0x10}; | static const int aslr_pages_rnd_64[2] = {0x1000, 0x10}; | ||||
static const int aslr_pages_rnd_32[2] = {0x100, 0x4}; | static const int aslr_pages_rnd_32[2] = {0x100, 0x4}; | ||||
static int cluster_anon = 1; | static int cluster_anon = 1; | ||||
SYSCTL_INT(_vm, OID_AUTO, cluster_anon, CTLFLAG_RW, | SYSCTL_INT(_vm, OID_AUTO, cluster_anon, CTLFLAG_RW, | ||||
&cluster_anon, 0, | &cluster_anon, 0, | ||||
"Cluster anonymous mappings"); | "Cluster anonymous mappings: 0 = no, 1 = yes if no hint, 2 = always"); | ||||
static bool | |||||
clustering_anon_allowed(vm_offset_t addr) | |||||
{ | |||||
switch (cluster_anon) { | |||||
case 0: | |||||
return (false); | |||||
case 1: | |||||
return (addr == 0); | |||||
case 2: | |||||
default: | |||||
return (true); | |||||
} | |||||
} | |||||
static long aslr_restarts; | static long aslr_restarts; | ||||
SYSCTL_LONG(_vm, OID_AUTO, aslr_restarts, CTLFLAG_RD, | SYSCTL_LONG(_vm, OID_AUTO, aslr_restarts, CTLFLAG_RD, | ||||
&aslr_restarts, 0, | &aslr_restarts, 0, | ||||
"Number of aslr failures"); | "Number of aslr failures"); | ||||
#define MAP_32BIT_MAX_ADDR ((vm_offset_t)1 << 31) | #define MAP_32BIT_MAX_ADDR ((vm_offset_t)1 << 31) | ||||
/* | /* | ||||
▲ Show 20 Lines • Show All 88 Lines • ▼ Show 20 Lines | if (find_space == VMFS_OPTIMAL_SPACE && (object == NULL || | ||||
(object->flags & OBJ_COLORED) == 0)) | (object->flags & OBJ_COLORED) == 0)) | ||||
find_space = VMFS_ANY_SPACE; | find_space = VMFS_ANY_SPACE; | ||||
if (find_space >> 8 != 0) { | if (find_space >> 8 != 0) { | ||||
KASSERT((find_space & 0xff) == 0, ("bad VMFS flags")); | KASSERT((find_space & 0xff) == 0, ("bad VMFS flags")); | ||||
alignment = (vm_offset_t)1 << (find_space >> 8); | alignment = (vm_offset_t)1 << (find_space >> 8); | ||||
} else | } else | ||||
alignment = 0; | alignment = 0; | ||||
en_aslr = (map->flags & MAP_ASLR) != 0; | en_aslr = (map->flags & MAP_ASLR) != 0; | ||||
update_anon = cluster = cluster_anon != 0 && | update_anon = cluster = clustering_anon_allowed(*addr) && | ||||
(map->flags & MAP_IS_SUB_MAP) == 0 && max_addr == 0 && | (map->flags & MAP_IS_SUB_MAP) == 0 && max_addr == 0 && | ||||
find_space != VMFS_NO_SPACE && object == NULL && | find_space != VMFS_NO_SPACE && object == NULL && | ||||
(cow & (MAP_INHERIT_SHARE | MAP_STACK_GROWS_UP | | (cow & (MAP_INHERIT_SHARE | MAP_STACK_GROWS_UP | | ||||
MAP_STACK_GROWS_DOWN)) == 0 && prot != PROT_NONE; | MAP_STACK_GROWS_DOWN)) == 0 && prot != PROT_NONE; | ||||
curr_min_addr = min_addr = *addr; | curr_min_addr = min_addr = *addr; | ||||
if (en_aslr && min_addr == 0 && !cluster && | if (en_aslr && min_addr == 0 && !cluster && | ||||
find_space != VMFS_NO_SPACE && | find_space != VMFS_NO_SPACE && | ||||
(map->flags & MAP_ASLR_IGNSTART) != 0) | (map->flags & MAP_ASLR_IGNSTART) != 0) | ||||
▲ Show 20 Lines • Show All 2,951 Lines • Show Last 20 Lines |