On Tue, Feb 09, 2010 at 05:52:35AM +0000, Marcel Moolenaar wrote: > Author: marcel > Date: Tue Feb 9 05:52:35 2010 > New Revision: 203696 > URL: http://svn.freebsd.org/changeset/base/203696 > > Log: > Add PT_VM_TIMESTAMP and PT_VM_ENTRY so that the tracing process can > obtain the memory map of the traced process. PT_VM_TIMESTAMP can be > used to check if the memory map changed since the last time to avoid > iterating over all the VM entries unnecesarily. > > MFC after: 1 month > ... > +static int > +ptrace_vm_entry(struct thread *td, struct proc *p, struct ptrace_vm_entry > *pve) > +{ > + vm_map_t map; > + vm_map_entry_t entry; > + vm_object_t obj, tobj, lobj; > + struct vnode *vp; > + char *freepath, *fullpath; > + u_int pathlen; > + int error, vfslocked; > + > + map = &p->p_vmspace->vm_map; I think this place lacks two safety measures: - vmspace should be referenced by vmspace_acquire_ref() - vm_map should be read-locked before iterating the map entries.
Vmspace may be shared between stopped debugee and other process using rfork(2), thus modified despite the fact that traced process is stopped. > + entry = map->header.next; > + if (pve->pve_cookie != NULL) { > + while (entry != &map->header && entry != pve->pve_cookie) > + entry = entry->next; Could the entry pointed by pve_cookie be reused between ptrace(PT_VM_ENTRY) invocations ? I think the debugger should be informed about this situation, otherwise interface is too unreliable.
pgp6qLTjqdlGM.pgp
Description: PGP signature