Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 14 Apr 2010 17:21:00 -0400
From:      John Baldwin <jhb@freebsd.org>
To:        freebsd-hackers@freebsd.org
Cc:        Fernando =?iso-8859-1?q?Apestegu=EDa?= <fernando.apesteguia@gmail.com>
Subject:   Re: Understanding proc_rwmem
Message-ID:  <201004141721.00254.jhb@freebsd.org>
In-Reply-To: <x2l1bd550a01004141322m420065fbj742800c3e4a81927@mail.gmail.com>
References:  <x2l1bd550a01004141322m420065fbj742800c3e4a81927@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On Wednesday 14 April 2010 4:22:56 pm Fernando Apestegu=EDa wrote:
> Hi all,
>=20
> I'm trying to read process memory other than the current process in
> kernel. I was told to use the proc_rwmem function, however I can't get
> it working properly. At first, I'm trying to read how many elements
> the environment variables vector has. To do this I tried this from a
> linprocfs filler function:
>=20
>=20
>         struct iovec iov;
> 	struct uio tmp_uio;
> 	struct ps_strings *pss;
> 	int ret_code;
>=20
> 	buff =3D malloc(sizeof(struct ps_strings), M_TEMP, M_WAITOK);
> 	memset(buff, 0, sizeof(struct ps_strings));
>=20
> 	PROC_LOCK_ASSERT(td->td_proc, MA_NOTOWNED);
> 	iov.iov_base =3D (caddr_t) buff;
> 	iov.iov_len =3D sizeof(struct ps_strings);
> 	tmp_uio.uio_iov =3D &iov;
> 	tmp_uio.uio_iovcnt =3D 1;
> 	tmp_uio.uio_offset =3D (off_t)(p->p_sysent->sv_psstrings);
> 	tmp_uio.uio_resid =3D sizeof(struct ps_strings);
> 	tmp_uio.uio_segflg =3D UIO_USERSPACE;
> 	tmp_uio.uio_rw =3D UIO_READ;
> 	tmp_uio.uio_td =3D td;
> 	ret_code =3D proc_rwmem(td->td_proc, &tmp_uio);

I think you want to use 'p' instead of 'td->td_proc' here.  As it is you ar=
e=20
reading from the current process instead of the target process I believe.

=2D-=20
John Baldwin



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