From: claudio Date: Wed, 21 Dec 2022 07:59:02 +0000 (+0000) Subject: The location of the aux info vector is now cached in ps_auxinfo of struct X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=bcc2e3d7508b5e9be73e81bd83a4cbe5e750bd95;p=openbsd The location of the aux info vector is now cached in ps_auxinfo of struct process. Use this information to access the vector. OK mpi@ mbuhl@ deraadt@ --- diff --git a/sys/kern/sys_process.c b/sys/kern/sys_process.c index 94bab785036..de054f0febc 100644 --- a/sys/kern/sys_process.c +++ b/sys/kern/sys_process.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sys_process.c,v 1.90 2022/12/05 23:18:37 deraadt Exp $ */ +/* $OpenBSD: sys_process.c,v 1.91 2022/12/21 07:59:02 claudio Exp $ */ /* $NetBSD: sys_process.c,v 1.55 1996/05/15 06:17:47 tls Exp $ */ /*- @@ -77,7 +77,6 @@ static inline struct process *process_tprfind(pid_t _tpid, struct proc **_tp); int ptrace_ctrl(struct proc *, int, pid_t, caddr_t, int); int ptrace_ustate(struct proc *, int, pid_t, void *, int, register_t *); int ptrace_kstate(struct proc *, int, pid_t, void *); -int process_auxv_offset(struct proc *, struct process *, struct uio *); int global_ptrace; /* permit tracing of not children */ @@ -688,9 +687,18 @@ ptrace_ustate(struct proc *p, int req, pid_t pid, void *addr, int data, if (uio.uio_resid > temp - uio.uio_offset) uio.uio_resid = temp - uio.uio_offset; piod->piod_len = iov.iov_len = uio.uio_resid; - error = process_auxv_offset(p, tr, &uio); - if (error) - return error; + uio.uio_offset += tr->ps_auxinfo; +#ifdef MACHINE_STACK_GROWS_UP + if (uio.uio_offset < (off_t)tr->ps_strings) + return EIO; +#else + if (uio.uio_offset > (off_t)tr->ps_strings) + return EIO; + if ((uio.uio_offset + uio.uio_resid) > + (off_t)tr->ps_strings) + uio.uio_resid = (off_t)tr->ps_strings - + uio.uio_offset; +#endif break; default: return EINVAL; @@ -868,51 +876,4 @@ process_domem(struct proc *curp, struct process *tr, struct uio *uio, int req) return error; } - -int -process_auxv_offset(struct proc *curp, struct process *tr, struct uio *uiop) -{ - struct vmspace *vm; - struct ps_strings pss; - struct iovec iov; - struct uio uio; - int error; - - iov.iov_base = &pss; - iov.iov_len = sizeof(pss); - uio.uio_iov = &iov; - uio.uio_iovcnt = 1; - uio.uio_offset = (off_t)tr->ps_strings; - uio.uio_resid = sizeof(pss); - uio.uio_segflg = UIO_SYSSPACE; - uio.uio_rw = UIO_READ; - uio.uio_procp = curp; - - vm = tr->ps_vmspace; - if ((tr->ps_flags & PS_EXITING) || (vm->vm_refcnt < 1)) - return EFAULT; - - uvmspace_addref(vm); - error = uvm_io(&vm->vm_map, &uio, 0); - uvmspace_free(vm); - - if (error != 0) - return error; - - if (pss.ps_envstr == NULL) - return EIO; - - uiop->uio_offset += (off_t)(vaddr_t)(pss.ps_envstr + pss.ps_nenvstr + 1); -#ifdef MACHINE_STACK_GROWS_UP - if (uiop->uio_offset < (off_t)tr->ps_strings) - return EIO; -#else - if (uiop->uio_offset > (off_t)tr->ps_strings) - return EIO; - if ((uiop->uio_offset + uiop->uio_resid) > (off_t)tr->ps_strings) - uiop->uio_resid = (off_t)tr->ps_strings - uiop->uio_offset; -#endif - - return 0; -} #endif