[?] Find the address of a segfault in userland

David Mentre (David.Mentre@irisa.fr)
28 Feb 1998 11:16:24 +0100

Hi all kernel hackers,

Here is a problem I did not succeed to solve, even if I tried my best:

How can I have the faulting address of a SIGSEGV, from _userland_ ?
My config: Linux 2.0.31 i686 SMP

In fact, I try to do my own memory managment (with mmap() and
mprotect() syscalls) in user area. I have made a SIGSEGV handler which
is triggered on read/write protection faults. But how can I find the
faulting address (to take the proper action with the faulting page
number) ?

I have looked at the kernel source and found[1] that the cr2 register
(which contains my precious address ;) seems to be saved somewhere in
the user stack. Unfortunatly, I've been unable to find this value in the
segfault handler. Is it possible at all ? Should I use/calculate a
specific offset from the stack pointer ? I must admit I'm completly lost
in kernel's user process stack managment.

Related question: in the 2.1.x saga, how to do the same thing ?

Any help would be greatly appreciated,

[1] arch/i386/kernel/signal.c:setup_frame()

  Personal: http://www.irisa.fr/prive/dmentre/

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu