From b702d7953f41d531d27bc0c8382640e12d81ddb6 Mon Sep 17 00:00:00 2001 From: guenther Date: Tue, 7 Dec 2021 04:19:24 +0000 Subject: [PATCH] Continue to delete emulation support: since we're Just ELF, the size of the auxinfo is fixed: provide ELF_AUX_WORDS in as a replacement for emul->e_arglen ok millert@ --- sys/kern/exec_elf.c | 12 +++--------- sys/kern/init_main.c | 3 +-- sys/kern/kern_exec.c | 6 +++--- sys/kern/sys_process.c | 5 +++-- sys/sys/exec_elf.h | 8 +++++++- sys/sys/proc.h | 4 +--- 6 files changed, 18 insertions(+), 20 deletions(-) diff --git a/sys/kern/exec_elf.c b/sys/kern/exec_elf.c index e192b265d52..aa789cc7057 100644 --- a/sys/kern/exec_elf.c +++ b/sys/kern/exec_elf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: exec_elf.c,v 1.161 2021/12/06 21:21:10 guenther Exp $ */ +/* $OpenBSD: exec_elf.c,v 1.162 2021/12/07 04:19:24 guenther Exp $ */ /* * Copyright (c) 1996 Per Fogelstrom @@ -119,11 +119,6 @@ extern char *syscallnames[]; */ #define ELF_MAX_VALID_PHDR 32 -/* - * How many entries are in the AuxInfo array we pass to the process? - */ -#define ELF_AUX_ENTRIES 9 - /* * This is the OpenBSD ELF emul */ @@ -138,7 +133,6 @@ struct emul emul_elf = { #else NULL, #endif - (sizeof(AuxInfo) * ELF_AUX_ENTRIES / sizeof(char *)), setregs, exec_elf_fixup, coredump_elf, @@ -1255,7 +1249,7 @@ coredump_notes_elf(struct proc *p, void *iocookie, size_t *sizep) /* Second, write an NT_OPENBSD_AUXV note. */ notesize = sizeof(nhdr) + elfround(sizeof("OpenBSD")) + - elfround(pr->ps_emul->e_arglen * sizeof(char *)); + elfround(ELF_AUX_WORDS * sizeof(char *)); if (iocookie) { iov.iov_base = &pss; iov.iov_len = sizeof(pss); @@ -1275,7 +1269,7 @@ coredump_notes_elf(struct proc *p, void *iocookie, size_t *sizep) return (EIO); nhdr.namesz = sizeof("OpenBSD"); - nhdr.descsz = pr->ps_emul->e_arglen * sizeof(char *); + nhdr.descsz = ELF_AUX_WORDS * sizeof(char *); nhdr.type = NT_OPENBSD_AUXV; error = coredump_write(iocookie, UIO_SYSSPACE, diff --git a/sys/kern/init_main.c b/sys/kern/init_main.c index 3d686f911fb..15e4f928d30 100644 --- a/sys/kern/init_main.c +++ b/sys/kern/init_main.c @@ -1,4 +1,4 @@ -/* $OpenBSD: init_main.c,v 1.309 2021/12/06 21:21:10 guenther Exp $ */ +/* $OpenBSD: init_main.c,v 1.310 2021/12/07 04:19:24 guenther Exp $ */ /* $NetBSD: init_main.c,v 1.84.4.1 1996/06/02 09:08:06 mrg Exp $ */ /* @@ -170,7 +170,6 @@ struct emul emul_native = { #else NULL, #endif - 0, setregs, NULL, /* fixup */ NULL, /* coredump */ diff --git a/sys/kern/kern_exec.c b/sys/kern/kern_exec.c index 1a6110c4ffd..f3a8f641540 100644 --- a/sys/kern/kern_exec.c +++ b/sys/kern/kern_exec.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_exec.c,v 1.224 2021/12/06 21:21:10 guenther Exp $ */ +/* $OpenBSD: kern_exec.c,v 1.225 2021/12/07 04:19:24 guenther Exp $ */ /* $NetBSD: kern_exec.c,v 1.75 1996/02/09 18:59:28 christos Exp $ */ /*- @@ -417,7 +417,7 @@ sys_execve(struct proc *p, void *v, register_t *retval) } /* Now check if args & environ fit into new stack */ - len = ((argc + envc + 2 + pack.ep_emul->e_arglen) * sizeof(char *) + + len = ((argc + envc + 2 + ELF_AUX_WORDS) * sizeof(char *) + sizeof(long) + dp + sgap + sizeof(struct ps_strings)) - argp; len = (len + _STACKALIGNBYTES) &~ _STACKALIGNBYTES; @@ -786,7 +786,7 @@ copyargs(struct exec_package *pack, struct ps_strings *arginfo, void *stack, if (copyout(&argc, cpp++, sizeof(argc))) return (0); - dp = (char *) (cpp + argc + envc + 2 + pack->ep_emul->e_arglen); + dp = (char *) (cpp + argc + envc + 2 + ELF_AUX_WORDS); sp = argp; /* XXX don't copy them out, remap them! */ diff --git a/sys/kern/sys_process.c b/sys/kern/sys_process.c index e5056ccdcc7..be024e0f945 100644 --- a/sys/kern/sys_process.c +++ b/sys/kern/sys_process.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sys_process.c,v 1.88 2021/05/10 18:01:24 mpi Exp $ */ +/* $OpenBSD: sys_process.c,v 1.89 2021/12/07 04:19:24 guenther Exp $ */ /* $NetBSD: sys_process.c,v 1.55 1996/05/15 06:17:47 tls Exp $ */ /*- @@ -59,6 +59,7 @@ #include #include #include +#include #include #include @@ -681,7 +682,7 @@ ptrace_ustate(struct proc *p, int req, pid_t pid, void *addr, int data, case PIOD_READ_AUXV: req = PT_READ_D; uio.uio_rw = UIO_READ; - temp = tr->ps_emul->e_arglen * sizeof(char *); + temp = ELF_AUX_WORDS * sizeof(char *); if (uio.uio_offset > temp) return EIO; if (uio.uio_resid > temp - uio.uio_offset) diff --git a/sys/sys/exec_elf.h b/sys/sys/exec_elf.h index ecd8e1dcc8d..4bdaba284fa 100644 --- a/sys/sys/exec_elf.h +++ b/sys/sys/exec_elf.h @@ -1,4 +1,4 @@ -/* $OpenBSD: exec_elf.h,v 1.91 2021/11/12 22:20:57 guenther Exp $ */ +/* $OpenBSD: exec_elf.h,v 1.92 2021/12/07 04:19:24 guenther Exp $ */ /* * Copyright (c) 1995, 1996 Erik Theisen. All rights reserved. * @@ -790,6 +790,12 @@ extern Elf_Dyn _DYNAMIC[]; #endif #ifdef _KERNEL +/* + * How many entries are in the AuxInfo array we pass to the process? + */ +#define ELF_AUX_ENTRIES 9 +#define ELF_AUX_WORDS (sizeof(AuxInfo) * ELF_AUX_ENTRIES / sizeof(char *)) + struct exec_package; int exec_elf_makecmds(struct proc *, struct exec_package *); diff --git a/sys/sys/proc.h b/sys/sys/proc.h index 317b430c76d..1f6b5b780dd 100644 --- a/sys/sys/proc.h +++ b/sys/sys/proc.h @@ -1,4 +1,4 @@ -/* $OpenBSD: proc.h,v 1.318 2021/12/06 21:21:10 guenther Exp $ */ +/* $OpenBSD: proc.h,v 1.319 2021/12/07 04:19:24 guenther Exp $ */ /* $NetBSD: proc.h,v 1.44 1996/04/22 01:23:21 christos Exp $ */ /*- @@ -101,8 +101,6 @@ struct emul { int e_nsysent; /* Number of system call entries */ struct sysent *e_sysent; /* System call array */ char **e_syscallnames; /* System call name array */ - int e_arglen; /* Extra argument size in words */ - /* Copy arguments on the stack */ void (*e_setregs)(struct proc *, struct exec_package *, u_long, register_t *); int (*e_fixup)(struct proc *, struct exec_package *); -- 2.20.1