Messages in this thread | | | Date | Sat, 28 Feb 1998 13:19:05 -0500 (EST) | From | Jason Duerstock <> | Subject | Re: [?] Find the address of a segfault in userland |
| |
On 28 Feb 1998, David Mentre wrote:
> 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, > Regards, > d. > > [1] arch/i386/kernel/signal.c:setup_frame()
#include <signal.h> #include <sigcontext.h>
signal(SIGSEGV, sigsegv_handler);
void sigsegv_handler(int num, struct sigcontext info) /* ignore the compiler whinings :D */ { printf("EIP: %x\n", info.eip); }
Not the world's greatest example, but hopefully enough to get the point across. :)
Let me know if you need more info.
Jason
- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu
| |