From owner-freebsd-hackers@FreeBSD.ORG Wed Apr 14 21:35:52 2010 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id CC485106566B; Wed, 14 Apr 2010 21:35:52 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from mail.zoral.com.ua (mx0.zoral.com.ua [91.193.166.200]) by mx1.freebsd.org (Postfix) with ESMTP id 42E308FC14; Wed, 14 Apr 2010 21:35:51 +0000 (UTC) Received: from deviant.kiev.zoral.com.ua (root@deviant.kiev.zoral.com.ua [10.1.1.148]) by mail.zoral.com.ua (8.14.2/8.14.2) with ESMTP id o3ELZlMp069372 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Thu, 15 Apr 2010 00:35:47 +0300 (EEST) (envelope-from kostikbel@gmail.com) Received: from deviant.kiev.zoral.com.ua (kostik@localhost [127.0.0.1]) by deviant.kiev.zoral.com.ua (8.14.4/8.14.4) with ESMTP id o3ELZlQt004109; Thu, 15 Apr 2010 00:35:47 +0300 (EEST) (envelope-from kostikbel@gmail.com) Received: (from kostik@localhost) by deviant.kiev.zoral.com.ua (8.14.4/8.14.4/Submit) id o3ELZlvn004108; Thu, 15 Apr 2010 00:35:47 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: deviant.kiev.zoral.com.ua: kostik set sender to kostikbel@gmail.com using -f Date: Thu, 15 Apr 2010 00:35:47 +0300 From: Kostik Belousov To: John Baldwin Message-ID: <20100414213547.GY2415@deviant.kiev.zoral.com.ua> References: <201004141721.00254.jhb@freebsd.org> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="yU7+DNvIsw2sWoF2" Content-Disposition: inline In-Reply-To: <201004141721.00254.jhb@freebsd.org> User-Agent: Mutt/1.4.2.3i X-Virus-Scanned: clamav-milter 0.95.2 at skuns.kiev.zoral.com.ua X-Virus-Status: Clean X-Spam-Status: No, score=-3.8 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00, DNS_FROM_OPENWHOIS autolearn=no version=3.2.5 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on skuns.kiev.zoral.com.ua Cc: freebsd-hackers@freebsd.org, Fernando Apestegu?a Subject: Re: Understanding proc_rwmem X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 14 Apr 2010 21:35:52 -0000 --yU7+DNvIsw2sWoF2 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable 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, > >=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); >=20 > I think you want to use 'p' instead of 'td->td_proc' here. As it is you = are=20 > 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. --yU7+DNvIsw2sWoF2 Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.10 (FreeBSD) iEYEARECAAYFAkvGNTMACgkQC3+MBN1Mb4gxEACgq+kVWS7GxrzbgLDlTNgPl00K veAAn3/GlFs+mwAcrx1JQXs/2qKoeRSK =bUSc -----END PGP SIGNATURE----- --yU7+DNvIsw2sWoF2--