-/* $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 $ */
/*-
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 */
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;
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