Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 9 Feb 2010 11:57:22 +0200
From:      Kostik Belousov <kostikbel@gmail.com>
To:        Marcel Moolenaar <marcel@freebsd.org>
Cc:        svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org
Subject:   Re: svn commit: r203696 - in head: lib/libc/sys sys/kern sys/sys
Message-ID:  <20100209095722.GQ9991@deviant.kiev.zoral.com.ua>
In-Reply-To: <201002090552.o195qZcD074581@svn.freebsd.org>
References:  <201002090552.o195qZcD074581@svn.freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help

--SvyA5ywaG/v2A5dH
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

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
>=20
> 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.
>  =20
>   MFC after:	1 month
>=20
=2E..
> +static int
> +ptrace_vm_entry(struct thread *td, struct proc *p, struct ptrace_vm_entr=
y *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 =3D &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 =3D map->header.next;
> +	if (pve->pve_cookie !=3D NULL) {
> +		while (entry !=3D &map->header && entry !=3D pve->pve_cookie)
> +			entry =3D 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.


--SvyA5ywaG/v2A5dH
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (FreeBSD)

iEYEARECAAYFAktxMYIACgkQC3+MBN1Mb4g9HwCdFsQObkursJJXS765f2p7ATI8
xCUAnjGm+G1dpuXNQy2PoSfeYyPxCzDd
=3LyT
-----END PGP SIGNATURE-----

--SvyA5ywaG/v2A5dH--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20100209095722.GQ9991>