diff options
-rw-r--r-- | sys/kern/exec_conf.c | 4 | ||||
-rw-r--r-- | sys/kern/exec_elf.c | 18 | ||||
-rw-r--r-- | sys/kern/init_main.c | 16 | ||||
-rw-r--r-- | sys/kern/kern_exec.c | 14 | ||||
-rw-r--r-- | sys/kern/kern_sig.c | 8 | ||||
-rw-r--r-- | sys/kern/kern_xxx.c | 10 | ||||
-rw-r--r-- | sys/kern/makesyscalls.sh | 6 | ||||
-rw-r--r-- | sys/kern/syscalls.c | 4 | ||||
-rw-r--r-- | sys/sys/exec_elf.h | 4 | ||||
-rw-r--r-- | sys/sys/proc.h | 9 | ||||
-rw-r--r-- | sys/sys/sysctl.h | 8 | ||||
-rw-r--r-- | usr.sbin/btrace/btrace.c | 6 | ||||
-rw-r--r-- | usr.sbin/btrace/btrace.h | 4 |
13 files changed, 35 insertions, 76 deletions
diff --git a/sys/kern/exec_conf.c b/sys/kern/exec_conf.c index e35e229e0d4..2cb0869cd13 100644 --- a/sys/kern/exec_conf.c +++ b/sys/kern/exec_conf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: exec_conf.c,v 1.37 2021/03/21 11:29:38 semarie Exp $ */ +/* $OpenBSD: exec_conf.c,v 1.38 2021/12/07 22:17:02 guenther Exp $ */ /* $NetBSD: exec_conf.c,v 1.16 1995/12/09 05:34:47 cgd Exp $ */ /* @@ -36,8 +36,6 @@ #include <sys/exec_script.h> #include <sys/exec_elf.h> -extern struct emul emul_native; - const struct execsw execsw[] = { { /* shell scripts */ .es_hdrsz = EXEC_SCRIPT_HDRSZ, diff --git a/sys/kern/exec_elf.c b/sys/kern/exec_elf.c index 40d19dfeb69..330108cd19c 100644 --- a/sys/kern/exec_elf.c +++ b/sys/kern/exec_elf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: exec_elf.c,v 1.163 2021/12/07 17:51:04 guenther Exp $ */ +/* $OpenBSD: exec_elf.c,v 1.164 2021/12/07 22:17:02 guenther Exp $ */ /* * Copyright (c) 1996 Per Fogelstrom @@ -99,15 +99,9 @@ int elf_check_header(Elf_Ehdr *); int elf_read_from(struct proc *, struct vnode *, u_long, void *, int); void elf_load_psection(struct exec_vmcmd_set *, struct vnode *, Elf_Phdr *, Elf_Addr *, Elf_Addr *, int *, int); -int coredump_elf(struct proc *, void *); -int exec_elf_fixup(struct proc *, struct exec_package *); int elf_os_pt_note_name(Elf_Note *); int elf_os_pt_note(struct proc *, struct exec_package *, Elf_Ehdr *, int *); -#ifdef SYSCALL_DEBUG -extern char *syscallnames[]; -#endif - /* round up and down to page boundaries. */ #define ELF_ROUND(a, b) (((a) + (b) - 1) & ~((b) - 1)) #define ELF_TRUNC(a, b) ((a) & ~((b) - 1)) @@ -122,19 +116,9 @@ extern char *syscallnames[]; * This is the OpenBSD ELF emul */ struct emul emul_elf = { - "native", - NULL, SYS_syscall, SYS_MAXSYSCALL, sysent, -#ifdef SYSCALL_DEBUG - syscallnames, -#else - NULL, -#endif - setregs, - exec_elf_fixup, - coredump_elf, }; #define ELF_NOTE_NAME_OPENBSD 0x01 diff --git a/sys/kern/init_main.c b/sys/kern/init_main.c index 8060a6e457a..fce15e4af6e 100644 --- a/sys/kern/init_main.c +++ b/sys/kern/init_main.c @@ -1,4 +1,4 @@ -/* $OpenBSD: init_main.c,v 1.311 2021/12/07 17:51:04 guenther Exp $ */ +/* $OpenBSD: init_main.c,v 1.312 2021/12/07 22:17:02 guenther Exp $ */ /* $NetBSD: init_main.c,v 1.84.4.1 1996/06/02 09:08:06 mrg Exp $ */ /* @@ -154,24 +154,10 @@ void timeout_proc_init(void); void pool_gc_pages(void *); void percpu_init(void); -#ifdef SYSCALL_DEBUG -extern char *syscallnames[]; -#endif - struct emul emul_native = { - "native", - NULL, SYS_syscall, SYS_MAXSYSCALL, sysent, -#ifdef SYSCALL_DEBUG - syscallnames, -#else - NULL, -#endif - setregs, - NULL, /* fixup */ - NULL, /* coredump */ }; #ifdef DIAGNOSTIC diff --git a/sys/kern/kern_exec.c b/sys/kern/kern_exec.c index c3bbc5b178e..4ec7d22d453 100644 --- a/sys/kern/kern_exec.c +++ b/sys/kern/kern_exec.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_exec.c,v 1.226 2021/12/07 17:51:04 guenther Exp $ */ +/* $OpenBSD: kern_exec.c,v 1.227 2021/12/07 22:17:02 guenther Exp $ */ /* $NetBSD: kern_exec.c,v 1.75 1996/02/09 18:59:28 christos Exp $ */ /*- @@ -676,19 +676,17 @@ sys_execve(struct proc *p, void *v, register_t *retval) */ KNOTE(&pr->ps_klist, NOTE_EXEC); - /* map the process's timekeep page, needs to be before e_fixup */ + /* map the process's timekeep page, needs to be before exec_elf_fixup */ if (exec_timekeep_map(pr)) goto free_pack_abort; /* setup new registers and do misc. setup. */ - if (pack.ep_emul->e_fixup != NULL) { - if ((*pack.ep_emul->e_fixup)(p, &pack) != 0) - goto free_pack_abort; - } + if (exec_elf_fixup(p, &pack) != 0) + goto free_pack_abort; #ifdef MACHINE_STACK_GROWS_UP - (*pack.ep_emul->e_setregs)(p, &pack, (u_long)stack + slen, retval); + setregs(p, &pack, (u_long)stack + slen, retval); #else - (*pack.ep_emul->e_setregs)(p, &pack, (u_long)stack, retval); + setregs(p, &pack, (u_long)stack, retval); #endif /* map the process's signal trampoline code */ diff --git a/sys/kern/kern_sig.c b/sys/kern/kern_sig.c index 204011407f1..27bb231b99a 100644 --- a/sys/kern/kern_sig.c +++ b/sys/kern/kern_sig.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_sig.c,v 1.290 2021/11/24 10:40:15 claudio Exp $ */ +/* $OpenBSD: kern_sig.c,v 1.291 2021/12/07 22:17:02 guenther Exp $ */ /* $NetBSD: kern_sig.c,v 1.54 1996/04/22 01:38:32 christos Exp $ */ /* @@ -64,6 +64,7 @@ #include <sys/ttycom.h> #include <sys/pledge.h> #include <sys/witness.h> +#include <sys/exec_elf.h> #include <sys/mount.h> #include <sys/syscallargs.h> @@ -1578,9 +1579,6 @@ coredump(struct proc *p) char *name; const char *dir = "/var/crash"; - if (pr->ps_emul->e_coredump == NULL) - return (EINVAL); - atomic_setbits_int(&pr->ps_flags, PS_COREDUMP); /* Don't dump if will exceed file size limit. */ @@ -1681,7 +1679,7 @@ coredump(struct proc *p) vref(vp); error = vn_close(vp, FWRITE, cred, p); if (error == 0) - error = (*pr->ps_emul->e_coredump)(p, &io); + error = coredump_elf(p, &io); vrele(vp); out: crfree(cred); diff --git a/sys/kern/kern_xxx.c b/sys/kern/kern_xxx.c index 3a8826bf3c0..a74bb06acf1 100644 --- a/sys/kern/kern_xxx.c +++ b/sys/kern/kern_xxx.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_xxx.c,v 1.36 2019/04/02 11:00:22 deraadt Exp $ */ +/* $OpenBSD: kern_xxx.c,v 1.37 2021/12/07 22:17:02 guenther Exp $ */ /* $NetBSD: kern_xxx.c,v 1.32 1996/04/22 01:38:41 christos Exp $ */ /* @@ -95,6 +95,8 @@ __stack_smash_handler(char func[], int damaged) int scdebug = SCDEBUG_CALLS|SCDEBUG_RETURNS|SCDEBUG_SHOWARGS; +extern const char *const syscallnames[]; + void scdebug_call(struct proc *p, register_t code, const register_t args[]) { @@ -113,11 +115,11 @@ scdebug_call(struct proc *p, register_t code, const register_t args[]) sy->sy_call == sys_nosys)) return; - printf("proc %d (%s): %s num ", pr->ps_pid, pr->ps_comm, em->e_name); + printf("proc %d (%s): num ", pr->ps_pid, pr->ps_comm); if (code < 0 || code >= em->e_nsysent) printf("OUT OF RANGE (%ld)", code); else { - printf("%ld call: %s", code, em->e_syscallnames[code]); + printf("%ld call: %s", code, syscallnames[code]); if (scdebug & SCDEBUG_SHOWARGS) { printf("("); for (i = 0; i < sy->sy_argsize / sizeof(register_t); @@ -147,7 +149,7 @@ scdebug_ret(struct proc *p, register_t code, int error, sy->sy_call == sys_nosys)) return; - printf("proc %d (%s): %s num ", pr->ps_pid, pr->ps_comm, em->e_name); + printf("proc %d (%s): num ", pr->ps_pid, pr->ps_comm); if (code < 0 || code >= em->e_nsysent) printf("OUT OF RANGE (%ld)", code); else diff --git a/sys/kern/makesyscalls.sh b/sys/kern/makesyscalls.sh index cedfe474731..86d35806ebe 100644 --- a/sys/kern/makesyscalls.sh +++ b/sys/kern/makesyscalls.sh @@ -1,5 +1,5 @@ #! /bin/sh - -# $OpenBSD: makesyscalls.sh,v 1.13 2016/09/26 16:42:34 jca Exp $ +# $OpenBSD: makesyscalls.sh,v 1.14 2021/12/07 22:17:02 guenther Exp $ # $NetBSD: makesyscalls.sh,v 1.26 1998/01/09 06:17:51 thorpej Exp $ # # Copyright (c) 1994,1996 Christopher G. Demetriou @@ -57,7 +57,7 @@ esac # sysarghdr the syscall argument struct definitions # compatopts those syscall types that are for 'compat' syscalls # switchname the name for the 'struct sysent' we define -# namesname the name for the 'char *[]' we define +# namesname the name for the 'const char *const[]' we define # constprefix the prefix for the system call constants # # NOTE THAT THIS makesyscalls.sh DOES NOT SUPPORT 'LIBCOMPAT'. @@ -170,7 +170,7 @@ NR == 1 { printf " * created from%s\n */\n\n", $0 > sysdcl printf " * created from%s\n */\n\n", $0 > sysnames - printf "char *%s[] = {\n",namesname > sysnames + printf "const char *const %s[] = {\n",namesname > sysnames printf " * created from%s\n */\n\n", $0 > sysnumhdr diff --git a/sys/kern/syscalls.c b/sys/kern/syscalls.c index 601e3a7e986..49793eba1c0 100644 --- a/sys/kern/syscalls.c +++ b/sys/kern/syscalls.c @@ -1,4 +1,4 @@ -/* $OpenBSD: syscalls.c,v 1.230 2021/11/29 16:31:43 mvs Exp $ */ +/* $OpenBSD: syscalls.c,v 1.231 2021/12/07 22:17:02 guenther Exp $ */ /* * System call names. @@ -7,7 +7,7 @@ * created from; OpenBSD: syscalls.master,v 1.220 2021/11/29 16:30:30 mvs Exp */ -char *syscallnames[] = { +const char *const syscallnames[] = { "syscall", /* 0 = syscall */ "exit", /* 1 = exit */ "fork", /* 2 = fork */ diff --git a/sys/sys/exec_elf.h b/sys/sys/exec_elf.h index 4bdaba284fa..9f7f397a098 100644 --- a/sys/sys/exec_elf.h +++ b/sys/sys/exec_elf.h @@ -1,4 +1,4 @@ -/* $OpenBSD: exec_elf.h,v 1.92 2021/12/07 04:19:24 guenther Exp $ */ +/* $OpenBSD: exec_elf.h,v 1.93 2021/12/07 22:17:03 guenther Exp $ */ /* * Copyright (c) 1995, 1996 Erik Theisen. All rights reserved. * @@ -799,6 +799,8 @@ extern Elf_Dyn _DYNAMIC[]; struct exec_package; int exec_elf_makecmds(struct proc *, struct exec_package *); +int exec_elf_fixup(struct proc *, struct exec_package *); +int coredump_elf(struct proc *, void *); #endif /* _KERNEL */ #define ELF_TARG_VER 1 /* The ver for which this code is intended */ diff --git a/sys/sys/proc.h b/sys/sys/proc.h index 73bd2aa5bbc..1e691b018c7 100644 --- a/sys/sys/proc.h +++ b/sys/sys/proc.h @@ -1,4 +1,4 @@ -/* $OpenBSD: proc.h,v 1.320 2021/12/07 17:51:04 guenther Exp $ */ +/* $OpenBSD: proc.h,v 1.321 2021/12/07 22:17:03 guenther Exp $ */ /* $NetBSD: proc.h,v 1.44 1996/04/22 01:23:21 christos Exp $ */ /*- @@ -95,16 +95,9 @@ struct uvm_object; union sigval; struct emul { - char e_name[8]; /* Symbolic name */ - int *e_errno; /* Errno array */ int e_nosys; /* Offset of the nosys() syscall */ int e_nsysent; /* Number of system call entries */ struct sysent *e_sysent; /* System call array */ - char **e_syscallnames; /* System call name array */ - void (*e_setregs)(struct proc *, struct exec_package *, - u_long, register_t *); - int (*e_fixup)(struct proc *, struct exec_package *); - int (*e_coredump)(struct proc *, void *cookie); }; /* diff --git a/sys/sys/sysctl.h b/sys/sys/sysctl.h index bc6d79ef6c9..5ad46445f36 100644 --- a/sys/sys/sysctl.h +++ b/sys/sys/sysctl.h @@ -1,4 +1,4 @@ -/* $OpenBSD: sysctl.h,v 1.219 2021/10/30 23:24:48 deraadt Exp $ */ +/* $OpenBSD: sysctl.h,v 1.220 2021/12/07 22:17:03 guenther Exp $ */ /* $NetBSD: sysctl.h,v 1.16 1996/04/09 20:55:36 cgd Exp $ */ /* @@ -649,11 +649,9 @@ do { \ (kp)->p_acflag = (pr)->ps_acflag; \ (kp)->p_pledge = (pr)->ps_pledge; \ \ - /* XXX depends on e_name being an array and not a pointer */ \ - copy_str((kp)->p_emul, (char *)(pr)->ps_emul + \ - offsetof(struct emul, e_name), sizeof((kp)->p_emul)); \ + strlcpy((kp)->p_emul, "native", sizeof((kp)->p_emul)); \ strlcpy((kp)->p_comm, (pr)->ps_comm, sizeof((kp)->p_comm)); \ - strlcpy((kp)->p_login, (sess)->s_login, \ + strlcpy((kp)->p_login, (sess)->s_login, \ MIN(sizeof((kp)->p_login), sizeof((sess)->s_login))); \ \ if ((sess)->s_ttyvp) \ diff --git a/usr.sbin/btrace/btrace.c b/usr.sbin/btrace/btrace.c index 87fc5c1199c..11fef8bfbc7 100644 --- a/usr.sbin/btrace/btrace.c +++ b/usr.sbin/btrace/btrace.c @@ -1,4 +1,4 @@ -/* $OpenBSD: btrace.c,v 1.60 2021/11/12 16:57:24 claudio Exp $ */ +/* $OpenBSD: btrace.c,v 1.61 2021/12/07 22:17:03 guenther Exp $ */ /* * Copyright (c) 2019 - 2021 Martin Pieuchot <mpi@openbsd.org> @@ -62,7 +62,7 @@ char *read_btfile(const char *, size_t *); */ void dtpi_cache(int); void dtpi_print_list(void); -char *dtpi_func(struct dtioc_probe_info *); +const char *dtpi_func(struct dtioc_probe_info *); int dtpi_is_unit(const char *); struct dtioc_probe_info *dtpi_get_by_value(const char *, const char *, const char *); @@ -305,7 +305,7 @@ dtpi_print_list(void) } } -char * +const char * dtpi_func(struct dtioc_probe_info *dtpi) { char *sysnb, func[DTNAMESIZE]; diff --git a/usr.sbin/btrace/btrace.h b/usr.sbin/btrace/btrace.h index ded754e3d18..d763ae5a5fc 100644 --- a/usr.sbin/btrace/btrace.h +++ b/usr.sbin/btrace/btrace.h @@ -1,4 +1,4 @@ -/* $OpenBSD: btrace.h,v 1.10 2021/10/03 22:01:48 dv Exp $ */ +/* $OpenBSD: btrace.h,v 1.11 2021/12/07 22:17:03 guenther Exp $ */ /* * Copyright (c) 2019 - 2020 Martin Pieuchot <mpi@openbsd.org> @@ -59,6 +59,6 @@ void hist_print(struct hist *, const char *); int stmt_printf(struct bt_stmt *, struct dt_evt *); /* syscalls.c */ -extern char *syscallnames[]; +extern const char *const syscallnames[]; #endif /* BTRACE_H */ |