From owner-freebsd-hackers@FreeBSD.ORG Thu Apr 15 07:19:56 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 EDAB4106566B; Thu, 15 Apr 2010 07:19:56 +0000 (UTC) (envelope-from fernando.apesteguia@gmail.com) Received: from ey-out-2122.google.com (ey-out-2122.google.com [74.125.78.24]) by mx1.freebsd.org (Postfix) with ESMTP id 54F348FC1C; Thu, 15 Apr 2010 07:19:55 +0000 (UTC) Received: by ey-out-2122.google.com with SMTP id d26so81577eyd.9 for ; Thu, 15 Apr 2010 00:19:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:received:message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=99ERwOgGYP0nYASYnycgYXo50qbDab5xjtN1jveBrLw=; b=C8yMVwK8mUEDbMZeEcIvxBNIA6iRrgYDd2wd2WVh/Q+kNMijwr60TFptVysSIj/Vwo 1RZcv48piaAbJFDpKo1B+gsBMYtAQBBOfzKAqNGpNapAsS+xWafNJN4Bjm3XrKQ2XNYE m2seO8h/f53KlI/tXE1jg1eYkINNKQoqUVB4g= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; b=vdPIkSJDujHK5ddxz/rAV4/LpkJbbbiITtdd3N4Vil3fhIY0AADf4sVAh50xB6sHkc GBZS003BH+btDM71iWUKX/yicq1YZhRJTTclIjitBpMAdR0jnIvZj2A2dUVMGpps2uTh R07W2GF7NTzUiOEO4Q7on+iJo4Ixaboz1UT9s= MIME-Version: 1.0 Received: by 10.213.9.134 with HTTP; Thu, 15 Apr 2010 00:19:54 -0700 (PDT) In-Reply-To: <20100414213547.GY2415@deviant.kiev.zoral.com.ua> References: <201004141721.00254.jhb@freebsd.org> <20100414213547.GY2415@deviant.kiev.zoral.com.ua> Date: Thu, 15 Apr 2010 09:19:54 +0200 Received: by 10.213.42.73 with SMTP id r9mr4348892ebe.40.1271315994994; Thu, 15 Apr 2010 00:19:54 -0700 (PDT) Message-ID: From: =?ISO-8859-1?Q?Fernando_Apestegu=EDa?= To: Kostik Belousov Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Cc: freebsd-hackers@freebsd.org 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: Thu, 15 Apr 2010 07:19:57 -0000 On Wed, Apr 14, 2010 at 11:35 PM, Kostik Belousov 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. >