Date: Thu, 15 Apr 2010 09:19:54 +0200 From: =?ISO-8859-1?Q?Fernando_Apestegu=EDa?= <fernando.apesteguia@gmail.com> To: Kostik Belousov <kostikbel@gmail.com> Cc: freebsd-hackers@freebsd.org Subject: Re: Understanding proc_rwmem Message-ID: <l2o1bd550a01004150019g18cf8f03jaced32d797ed3134@mail.gmail.com> In-Reply-To: <20100414213547.GY2415@deviant.kiev.zoral.com.ua> References: <x2l1bd550a01004141322m420065fbj742800c3e4a81927@mail.gmail.com> <201004141721.00254.jhb@freebsd.org> <20100414213547.GY2415@deviant.kiev.zoral.com.ua>
next in thread | previous in thread | raw e-mail | index | archive | help
On Wed, Apr 14, 2010 at 11:35 PM, Kostik Belousov <kostikbel@gmail.com> wro= te: > On Wed, Apr 14, 2010 at 05:21:00PM -0400, John Baldwin wrote: >> On Wednesday 14 April 2010 4:22:56 pm Fernando Apestegu?a wrote: >> > Hi all, >> > >> > 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: >> > >> > >> > =A0 =A0 =A0 =A0 struct iovec iov; >> > =A0 =A0 struct uio tmp_uio; >> > =A0 =A0 struct ps_strings *pss; >> > =A0 =A0 int ret_code; >> > >> > =A0 =A0 buff =3D malloc(sizeof(struct ps_strings), M_TEMP, M_WAITOK); >> > =A0 =A0 memset(buff, 0, sizeof(struct ps_strings)); >> > >> > =A0 =A0 PROC_LOCK_ASSERT(td->td_proc, MA_NOTOWNED); >> > =A0 =A0 iov.iov_base =3D (caddr_t) buff; >> > =A0 =A0 iov.iov_len =3D sizeof(struct ps_strings); >> > =A0 =A0 tmp_uio.uio_iov =3D &iov; >> > =A0 =A0 tmp_uio.uio_iovcnt =3D 1; >> > =A0 =A0 tmp_uio.uio_offset =3D (off_t)(p->p_sysent->sv_psstrings); >> > =A0 =A0 tmp_uio.uio_resid =3D sizeof(struct ps_strings); >> > =A0 =A0 tmp_uio.uio_segflg =3D UIO_USERSPACE; >> > =A0 =A0 tmp_uio.uio_rw =3D UIO_READ; >> > =A0 =A0 tmp_uio.uio_td =3D td; >> > =A0 =A0 ret_code =3D proc_rwmem(td->td_proc, &tmp_uio); >> >> I think you want to use 'p' instead of 'td->td_proc' here. =A0As it is y= ou are >> reading from the current process instead of the target process I believe= . > > And UIO_USERSPACE sound suspicious. Note that segment flag > is for the requestor address space. Ugh, sorry. Copy-paste error. Yes, that should be UIO_SYSSPACE. >
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?l2o1bd550a01004150019g18cf8f03jaced32d797ed3134>