Fix divide-by-zero panic when ASLR is enabled and superpages disabled
When locating the anonymous memory region for a vm_map with ASLR enabled, we try to keep the slid base address aligned on a superpage boundary to minimize pagetable fragmentation and maximize the potential usage of superpage mappings. We can't (portably) do this if superpages have been disabled by loader tunable and pagesizes[1] is 0, and it would be less beneficial in that case anyway. PR: 253511 Reported by: johannes@jo-t.de MFC after: 1 week Reviewed by: kib Differential Revision: https://reviews.freebsd.org/D28678
This commit is contained in:
parent
85d6747a69
commit
41032835dc
@ -1287,7 +1287,8 @@ __CONCAT(exec_, __elfN(imgact))(struct image_params *imgp)
|
|||||||
maxv1 = maxv / 2 + addr / 2;
|
maxv1 = maxv / 2 + addr / 2;
|
||||||
MPASS(maxv1 >= addr); /* No overflow */
|
MPASS(maxv1 >= addr); /* No overflow */
|
||||||
map->anon_loc = __CONCAT(rnd_, __elfN(base))(map, addr, maxv1,
|
map->anon_loc = __CONCAT(rnd_, __elfN(base))(map, addr, maxv1,
|
||||||
MAXPAGESIZES > 1 ? pagesizes[1] : pagesizes[0]);
|
(MAXPAGESIZES > 1 && pagesizes[1] != 0) ?
|
||||||
|
pagesizes[1] : pagesizes[0]);
|
||||||
} else {
|
} else {
|
||||||
map->anon_loc = addr;
|
map->anon_loc = addr;
|
||||||
}
|
}
|
||||||
@ -1297,7 +1298,7 @@ __CONCAT(exec_, __elfN(imgact))(struct image_params *imgp)
|
|||||||
if (interp != NULL) {
|
if (interp != NULL) {
|
||||||
VOP_UNLOCK(imgp->vp);
|
VOP_UNLOCK(imgp->vp);
|
||||||
if ((map->flags & MAP_ASLR) != 0) {
|
if ((map->flags & MAP_ASLR) != 0) {
|
||||||
/* Assume that interpeter fits into 1/4 of AS */
|
/* Assume that interpreter fits into 1/4 of AS */
|
||||||
maxv1 = maxv / 2 + addr / 2;
|
maxv1 = maxv / 2 + addr / 2;
|
||||||
MPASS(maxv1 >= addr); /* No overflow */
|
MPASS(maxv1 >= addr); /* No overflow */
|
||||||
addr = __CONCAT(rnd_, __elfN(base))(map, addr,
|
addr = __CONCAT(rnd_, __elfN(base))(map, addr,
|
||||||
|
Loading…
Reference in New Issue
Block a user