copyin() EFAULT

2004-05-19 Thread Tomas Pluskal

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 0x2808 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 0x281e err 14
copyin 0xbfbe 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


___
[EMAIL PROTECTED] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "[EMAIL PROTECTED]"


Re: copyin() EFAULT

2004-05-20 Thread David Schultz
On Wed, May 19, 2004, Tomas Pluskal wrote:
> 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
[...]
> So copying of some blocks was OK, and on some blocks it returned EFAULT.
> Why?

You will get EFAULT when you try to copy pages that are not mapped
in the user process.
___
[EMAIL PROTECTED] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "[EMAIL PROTECTED]"