summaryrefslogtreecommitdiff
path: root/sys/kern
diff options
context:
space:
mode:
Diffstat (limited to 'sys/kern')
-rw-r--r--sys/kern/exec_elf.c24
-rw-r--r--sys/kern/exec_subr.c8
-rw-r--r--sys/kern/init_main.c4
-rw-r--r--sys/kern/kern_exec.c4
4 files changed, 17 insertions, 23 deletions
diff --git a/sys/kern/exec_elf.c b/sys/kern/exec_elf.c
index 33e5cadb76a..0cb3b15968f 100644
--- a/sys/kern/exec_elf.c
+++ b/sys/kern/exec_elf.c
@@ -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.
diff --git a/sys/kern/exec_subr.c b/sys/kern/exec_subr.c
index a02566bf797..4ebca1b981d 100644
--- a/sys/kern/exec_subr.c
+++ b/sys/kern/exec_subr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: exec_subr.c,v 1.66 2023/03/19 20:32:13 kettenis Exp $ */
+/* $OpenBSD: exec_subr.c,v 1.67 2024/04/02 08:39:16 deraadt Exp $ */
/* $NetBSD: exec_subr.c,v 1.9 1994/12/04 03:10:42 mycroft Exp $ */
/*
@@ -194,9 +194,6 @@ vmcmd_map_pagedvn(struct proc *p, struct exec_vmcmd *cmd)
/*
* do the map
*/
- if ((cmd->ev_flags & VMCMD_SYSCALL) && (cmd->ev_prot & PROT_EXEC))
- flags |= UVM_FLAG_SYSCALL;
-
error = uvm_map(&p->p_vmspace->vm_map, &cmd->ev_addr, cmd->ev_len,
uobj, cmd->ev_offset, 0,
UVM_MAPFLAG(cmd->ev_prot, PROT_MASK, MAP_INHERIT_COPY,
@@ -217,8 +214,7 @@ vmcmd_map_pagedvn(struct proc *p, struct exec_vmcmd *cmd)
round_page(cmd->ev_addr + cmd->ev_len), 1);
#ifdef PMAP_CHECK_COPYIN
if (PMAP_CHECK_COPYIN &&
- ((flags & UVM_FLAG_SYSCALL) ||
- ((cmd->ev_flags & VMCMD_IMMUTABLE) && (cmd->ev_prot & PROT_EXEC))))
+ ((cmd->ev_flags & VMCMD_IMMUTABLE) && (cmd->ev_prot & PROT_EXEC)))
uvm_map_check_copyin_add(&p->p_vmspace->vm_map,
cmd->ev_addr, round_page(cmd->ev_addr + cmd->ev_len));
#endif
diff --git a/sys/kern/init_main.c b/sys/kern/init_main.c
index b4816b2e9a0..d571b0855cf 100644
--- a/sys/kern/init_main.c
+++ b/sys/kern/init_main.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: init_main.c,v 1.325 2024/02/14 06:17:51 miod Exp $ */
+/* $OpenBSD: init_main.c,v 1.326 2024/04/02 08:39:16 deraadt Exp $ */
/* $NetBSD: init_main.c,v 1.84.4.1 1996/06/02 09:08:06 mrg Exp $ */
/*
@@ -626,7 +626,7 @@ start_init(void *arg)
NULL, UVM_UNKNOWN_OFFSET, 0,
UVM_MAPFLAG(PROT_READ | PROT_WRITE, PROT_MASK, MAP_INHERIT_COPY,
MADV_NORMAL,
- UVM_FLAG_FIXED|UVM_FLAG_OVERLAY|UVM_FLAG_COPYONW|UVM_FLAG_STACK|UVM_FLAG_SYSCALL)))
+ UVM_FLAG_FIXED|UVM_FLAG_OVERLAY|UVM_FLAG_COPYONW|UVM_FLAG_STACK)))
panic("init: couldn't allocate argument space");
for (pathp = &initpaths[0]; (path = *pathp) != NULL; pathp++) {
diff --git a/sys/kern/kern_exec.c b/sys/kern/kern_exec.c
index a00e2372145..7d87a4cbcb9 100644
--- a/sys/kern/kern_exec.c
+++ b/sys/kern/kern_exec.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kern_exec.c,v 1.254 2024/01/17 18:56:13 deraadt Exp $ */
+/* $OpenBSD: kern_exec.c,v 1.255 2024/04/02 08:39:16 deraadt Exp $ */
/* $NetBSD: kern_exec.c,v 1.75 1996/02/09 18:59:28 christos Exp $ */
/*-
@@ -905,7 +905,7 @@ exec_sigcode_map(struct process *pr)
if (uvm_map(&pr->ps_vmspace->vm_map, &pr->ps_sigcode, round_page(sz),
sigobject, 0, 0, UVM_MAPFLAG(PROT_EXEC,
PROT_READ | PROT_WRITE | PROT_EXEC, MAP_INHERIT_COPY,
- MADV_RANDOM, UVM_FLAG_COPYONW | UVM_FLAG_SYSCALL))) {
+ MADV_RANDOM, UVM_FLAG_COPYONW))) {
uao_detach(sigobject);
return (ENOMEM);
}