-/* $OpenBSD: exec_elf.c,v 1.182 2023/06/10 19:30:48 kettenis Exp $ */
+/* $OpenBSD: exec_elf.c,v 1.183 2023/07/12 19:34:14 jasper Exp $ */
/*
* Copyright (c) 1996 Per Fogelstrom
goto bad1;
for (i = 0; i < eh.e_phnum; i++) {
+ if ((ph[i].p_align > 1) && !powerof2(ph[i].p_align)) {
+ error = EINVAL;
+ goto bad1;
+ }
+
if (ph[i].p_type == PT_LOAD) {
if (ph[i].p_filesz > ph[i].p_memsz ||
ph[i].p_memsz == 0) {
epp->ep_dsize = ELF_NO_ADDR;
for (i = 0, pp = ph; i < eh->e_phnum; i++, pp++) {
+ if ((pp->p_align > 1) && !powerof2(pp->p_align)) {
+ error = EINVAL;
+ goto bad;
+ }
+
if (pp->p_type == PT_INTERP && !interp) {
if (pp->p_filesz < 2 || pp->p_filesz > MAXPATHLEN)
goto bad;
if (eh->e_type == ET_DYN) {
/* need phdr and load sections for PIE */
- if (!has_phdr || base_ph == NULL) {
+ if (!has_phdr || base_ph == NULL || base_ph->p_vaddr != 0) {
error = EINVAL;
goto bad;
}