From owner-freebsd-hackers@FreeBSD.ORG Wed May 19 04:51:20 2004 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 81E5B16A4CE for ; Wed, 19 May 2004 04:51:20 -0700 (PDT) Received: from pohoda.cz (pohoda.pohoda.cz [194.228.111.151]) by mx1.FreeBSD.org (Postfix) with SMTP id 63C2443D2D for ; Wed, 19 May 2004 04:51:19 -0700 (PDT) (envelope-from plusik@pohoda.cz) Received: (qmail 2735 invoked from network); 19 May 2004 11:50:45 -0000 Received: from plusik@pohoda.cz by pohoda.cz by uid 500 with qmail-scanner-1.15 ( Clear:. Processed in 0.012689 secs); 19 kvì 2004 11:50:45 -0000 Received: from localhost (sendmail-bs@127.0.0.1) by localhost with SMTP; 19 May 2004 11:50:45 -0000 Date: Wed, 19 May 2004 13:50:45 +0200 (CEST) From: Tomas Pluskal To: Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Spam-Checker-Version: SpamAssassin 2.61 (1.212.2.1-2003-12-09-exp) on pohoda.cz X-Spam-Status: No, hits=-4.9 required=6.5 tests=BAYES_00 autolearn=ham version=2.61 X-Spam-Level: X-Mailman-Approved-At: Wed, 19 May 2004 05:02:55 -0700 Subject: copyin() EFAULT X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 19 May 2004 11:51:20 -0000 Hello, I would like to ask you for help or explanation - why do I get EFAULT when invoking copyin() or fubyte() etc. I am writing a kernel module, and I need to read all process memory (e.g. to do something like a coredump). I have copied the __elfN(coredump)(td, vp, limit) function from /sys/kern/imgact_elf.c, but it doesn't work, I get EFAULT on some memory blocks (but different blocks every time!). I have prepared a simple module, which demonstrates the situation. You can see it here: http://plusik.pohoda.cz/pokus.tgz It is using callout...() to run the perform_pokus() function every second, and this function tries to read all memory blocks of a certain process (the process PID is found in kern.pokuspid sysctl variable). When I load the module and set the kern.pokuspid to e.g. 359, I get on console: copying process 359 [sh] copyin 0x8061000 err 0 copyin 0x8064000 err 14 copyin 0x2807f000 err 0 copyin 0x28080000 err 0 copyin 0x28084000 err 14 copyin 0x280a9000 err 0 copyin 0x280c3000 err 0 copyin 0x2818a000 err 14 copyin 0x2818f000 err 14 copyin 0x281d8000 err 14 copyin 0x281e0000 err 14 copyin 0xbfbe0000 err 14 So copying of some blocks was OK, and on some blocks it returned EFAULT. Why? My system is FreeBSD 5.2-CURRENT #5: Wed Apr 28 16:03:52 CEST 2004. Thanks, Tomas Pluskal