Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 19 May 2004 13:50:45 +0200 (CEST)
From:      Tomas Pluskal <plusik@pohoda.cz>
To:        <hackers@freebsd.org>
Subject:   copyin() EFAULT
Message-ID:  <Pine.LNX.4.30L2.0405191350210.2702-100000@pohoda.cz>

next in thread | raw e-mail | index | archive | help

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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.LNX.4.30L2.0405191350210.2702-100000>