git: 36df8f540fa3 - main - imgact_elf: check that the alignment of PT_LOAD segment is power of two
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Sun, 12 Dec 2021 14:30:36 UTC
The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=36df8f540fa3802e3d7ccf9d71a13750a72b33ff commit 36df8f540fa3802e3d7ccf9d71a13750a72b33ff Author: Konstantin Belousov <kib@FreeBSD.org> AuthorDate: 2021-12-09 15:27:24 +0000 Commit: Konstantin Belousov <kib@FreeBSD.org> CommitDate: 2021-12-12 14:28:38 +0000 imgact_elf: check that the alignment of PT_LOAD segment is power of two and stop recalculating alignment for PIE base, which was off by one power of two. Suggested and reviewed by: markj Tested by: pho Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D33359 --- sys/kern/imgact_elf.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/sys/kern/imgact_elf.c b/sys/kern/imgact_elf.c index 3b05b38f3ed1..d4c5a6341ee6 100644 --- a/sys/kern/imgact_elf.c +++ b/sys/kern/imgact_elf.c @@ -1174,7 +1174,8 @@ __CONCAT(exec_, __elfN(imgact))(struct image_params *imgp) case PT_LOAD: if (n == 0) baddr = phdr[i].p_vaddr; - if (phdr[i].p_align > maxsalign) { + if (!powerof2(phdr[i].p_align) || + phdr[i].p_align > maxsalign) { uprintf("Invalid segment alignment\n"); error = ENOEXEC; goto ret; @@ -1316,7 +1317,7 @@ __CONCAT(exec_, __elfN(imgact))(struct image_params *imgp) error = __CONCAT(rnd_, __elfN(base))(map, vm_map_min(map) + mapsz + lim_max(td, RLIMIT_DATA), /* reserve half of the address space to interpreter */ - maxv / 2, 1UL << flsl(maxalign), &et_dyn_addr); + maxv / 2, maxalign, &et_dyn_addr); } vn_lock(imgp->vp, LK_SHARED | LK_RETRY);