From: guenther Date: Fri, 10 Dec 2021 05:34:42 +0000 (+0000) Subject: Revert "kbind(2): disable system call if not initialized before X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=6ac18ccb9b6851970e60b23060d3f6908d265ecd;p=openbsd Revert "kbind(2): disable system call if not initialized before first __tfork(2)" The immediate issue is that a process linked with -znow will still perform lazy relocation on objects loaded with dlopen(), but there are possibly other dark corners to plumb to find a better invariant. Problem reported by thfr@ --- diff --git a/sys/kern/kern_fork.c b/sys/kern/kern_fork.c index 89bd3a7e5a1..6f400f4e457 100644 --- a/sys/kern/kern_fork.c +++ b/sys/kern/kern_fork.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_fork.c,v 1.237 2021/12/05 22:00:42 cheloha Exp $ */ +/* $OpenBSD: kern_fork.c,v 1.238 2021/12/10 05:34:42 guenther Exp $ */ /* $NetBSD: kern_fork.c,v 1.29 1996/02/09 18:59:34 christos Exp $ */ /* @@ -137,13 +137,6 @@ sys___tfork(struct proc *p, void *v, register_t *retval) return EINVAL; #endif /* TCB_INVALID */ - /* - * kbind(2) can only be used if it is initialized before the - * process goes multithreaded. - */ - if (p->p_p->ps_kbind_addr == 0) - p->p_p->ps_kbind_addr = BOGO_PC; - return thread_fork(p, param.tf_stack, param.tf_tcb, param.tf_tid, retval); } diff --git a/sys/sys/proc.h b/sys/sys/proc.h index 7b4b8db6ee4..112b3c6647f 100644 --- a/sys/sys/proc.h +++ b/sys/sys/proc.h @@ -1,4 +1,4 @@ -/* $OpenBSD: proc.h,v 1.322 2021/12/09 00:26:10 guenther Exp $ */ +/* $OpenBSD: proc.h,v 1.323 2021/12/10 05:34:42 guenther Exp $ */ /* $NetBSD: proc.h,v 1.44 1996/04/22 01:23:21 christos Exp $ */ /*- @@ -234,10 +234,8 @@ struct process { uint64_t ps_pledge; uint64_t ps_execpledge; - int64_t ps_kbind_cookie; /* [K] */ - u_long ps_kbind_addr; /* [K] */ -/* an address that can't be in userspace or kernelspace */ -#define BOGO_PC (u_long)-1 + int64_t ps_kbind_cookie; + u_long ps_kbind_addr; /* End area that is copied on creation. */ #define ps_endcopy ps_refcnt diff --git a/sys/uvm/uvm_mmap.c b/sys/uvm/uvm_mmap.c index e499a573a9a..5d8570c2c12 100644 --- a/sys/uvm/uvm_mmap.c +++ b/sys/uvm/uvm_mmap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uvm_mmap.c,v 1.165 2021/12/05 22:00:42 cheloha Exp $ */ +/* $OpenBSD: uvm_mmap.c,v 1.166 2021/12/10 05:34:42 guenther Exp $ */ /* $NetBSD: uvm_mmap.c,v 1.49 2001/02/18 21:19:08 chs Exp $ */ /* @@ -1073,6 +1073,8 @@ uvm_mmapfile(vm_map_t map, vaddr_t *addr, vsize_t size, vm_prot_t prot, return error; } +/* an address that can't be in userspace or kernelspace */ +#define BOGO_PC (u_long)-1 int sys_kbind(struct proc *p, void *v, register_t *retval) {