From owner-freebsd-arch@FreeBSD.ORG Sat Jul 12 01:16:04 2008 Return-Path: Delivered-To: freebsd-arch@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 1CFA3106564A for ; Sat, 12 Jul 2008 01:16:04 +0000 (UTC) (envelope-from sson@freebsd.org) Received: from www.son.org (son.org [199.239.233.23]) by mx1.freebsd.org (Postfix) with ESMTP id DF2538FC22 for ; Sat, 12 Jul 2008 01:16:03 +0000 (UTC) (envelope-from sson@freebsd.org) Received: from 10net.scnet.net ([63.99.110.163]) (authenticated bits=0) by www.son.org (8.13.6.20060614/8.13.6) with ESMTP id m6C1FvnL061153; Fri, 11 Jul 2008 20:16:00 -0500 (CDT) Message-ID: <48780661.5050002@freebsd.org> Date: Fri, 11 Jul 2008 20:18:25 -0500 From: Stacey Son User-Agent: Thunderbird/3.0a2pre (Macintosh; 2008070703) MIME-Version: 1.0 To: Andrew Gallatin References: <4875A5D2.8030902@freebsd.org> <20080711155232.A96384@grasshopper.cs.duke.edu> In-Reply-To: <20080711155232.A96384@grasshopper.cs.duke.edu> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: freebsd-arch@freebsd.org Subject: Re: ksyms pseudo driver X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 12 Jul 2008 01:16:04 -0000 Andrew Gallatin wrote: >> its already opened snapshot first. Of course, this requires the read() >> handler to bounce the buffer into the kernel first before it is written >> back out to userspace. (Maybe there is a simple way to do an userspace >> to userspace copy instead?) The reason I went to all this trouble is to >> keep /dev/ksyms from turning into an easy way to exhaust all the kernel >> memory (unintentionally or intentionally). >> > > Instead of doing the copy in the kernel, can you just have a simple > ioctl which returns the address and size of the snapshot? Then the > userspace side can do the copy itself. > Actually that is what the ioctls do now... You can just open /dev/ksyms to create the snapshot and then use ioctl() to get the size and address where the buffer is mapped. Or you can use mmap(). IOCTLS The ioctl(2) command codes below are defined in . The (third) argument to the ioctl(2) should be a pointer to the type indicated. KIOCGSIZE (size_t) Returns the total size of the current symbol table. KIOCGADDR (void *) Returns the address of the kernel symbol table mapped in the process memory. -stacey.