sync with OpenBSD -current

This commit is contained in:
purplerain 2024-04-02 22:46:26 +00:00
parent 297ba4a59a
commit a339fc8c86
Signed by: purplerain
GPG key ID: F42C07F07E2E35B7
29 changed files with 192 additions and 352 deletions

View file

@ -1,4 +1,4 @@
/* $OpenBSD: exec_elf.c,v 1.185 2024/01/17 22:22:25 kurt Exp $ */
/* $OpenBSD: exec_elf.c,v 1.186 2024/04/02 08:39:16 deraadt Exp $ */
/*
* Copyright (c) 1996 Per Fogelstrom
@ -494,10 +494,15 @@ elf_load_file(struct proc *p, char *path, struct exec_package *epp,
addr = ph[i].p_vaddr - base_ph->p_vaddr;
}
elf_load_psection(&epp->ep_vmcmds, nd.ni_vp,
&ph[i], &addr, &size, &prot, flags | VMCMD_SYSCALL);
&ph[i], &addr, &size, &prot, flags);
/* If entry is within this section it must be text */
if (eh.e_entry >= ph[i].p_vaddr &&
eh.e_entry < (ph[i].p_vaddr + size)) {
/* LOAD containing e_entry may not be writable */
if (prot & PROT_WRITE) {
error = ENOEXEC;
goto bad1;
}
epp->ep_entry = addr + eh.e_entry -
ELF_TRUNC(ph[i].p_vaddr,ph[i].p_align);
if (flags == VMCMD_RELATIVE)
@ -715,7 +720,7 @@ exec_elf_makecmds(struct proc *p, struct exec_package *epp)
*/
for (i = 0, pp = ph; i < eh->e_phnum; i++, pp++) {
Elf_Addr addr, size = 0;
int prot = 0, syscall = 0;
int prot = 0;
int flags = 0;
switch (pp->p_type) {
@ -731,16 +736,9 @@ exec_elf_makecmds(struct proc *p, struct exec_package *epp)
} else
addr = ELF_NO_ADDR;
/*
* Permit system calls in main-text static binaries.
* static binaries may not call msyscall() or
* pinsyscalls()
*/
if (interp == NULL) {
syscall = VMCMD_SYSCALL;
p->p_vmspace->vm_map.flags |= VM_MAP_SYSCALL_ONCE;
/* Static binaries may not call pinsyscalls() */
if (interp == NULL)
p->p_vmspace->vm_map.flags |= VM_MAP_PINSYSCALL_ONCE;
}
/*
* Calculates size of text and data segments
@ -750,7 +748,7 @@ exec_elf_makecmds(struct proc *p, struct exec_package *epp)
* for DATA_PLT, is fine for TEXT_PLT.
*/
elf_load_psection(&epp->ep_vmcmds, epp->ep_vp,
pp, &addr, &size, &prot, flags | textrel | syscall);
pp, &addr, &size, &prot, flags | textrel);
/*
* Update exe_base in case alignment was off.