git: f1f4d58a6bf8 - stable/13 - 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, 19 Dec 2021 02:44:31 UTC
The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=f1f4d58a6bf828fc418071edfbc5d5462069c3d8 commit f1f4d58a6bf828fc418071edfbc5d5462069c3d8 Author: Konstantin Belousov <kib@FreeBSD.org> AuthorDate: 2021-12-09 15:27:24 +0000 Commit: Konstantin Belousov <kib@FreeBSD.org> CommitDate: 2021-12-19 02:42:51 +0000 imgact_elf: check that the alignment of PT_LOAD segment is power of two (cherry picked from commit 36df8f540fa3802e3d7ccf9d71a13750a72b33ff) --- 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 e0dd2b13c143..17c0752c35fa 100644 --- a/sys/kern/imgact_elf.c +++ b/sys/kern/imgact_elf.c @@ -1154,7 +1154,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; @@ -1295,7 +1296,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);