This is the mail archive of the
systemtap@sourceware.org
mailing list for the systemtap project.
Re: [PATCH] Kprobes- robust fault handling for i386 post_handler changes
- From: Prasanna S Panchamukhi <prasanna at in dot ibm dot com>
- To: "Keshavamurthy, Anil S" <anil dot s dot keshavamurthy at intel dot com>
- Cc: systemtap at sources dot redhat dot com
- Date: Mon, 27 Feb 2006 14:57:05 +0530
- Subject: Re: [PATCH] Kprobes- robust fault handling for i386 post_handler changes
- References: <44BDAFB888F59F408FAE3CC35AB470410313D68D@orsmsx409> <20060227092535.GC6586@in.ibm.com>
- Reply-to: prasanna at in dot ibm dot com
This patch provides proper kprobes fault handling, if a user-specified
post handlers tries to access user address space, through
copy_from_user(), get_user() etc. The user-specified fault handler
gets called only if the fault occurs wile executing user-specified
handlers. In such a case user-specified handler is allowed to fix it
first, later if the user-specifed fault handler does not fix it, we
try to fix it by calling fix_exception().
The user-specified handler will not be called if the fault happens
when single stepping the original instruction, instead we reset the
current probe and allow the system page fault handler to fix it up.
Signed-off-by: Prasanna S Panchamukhi <prasanna@in.ibm.com>
arch/i386/kernel/kprobes.c | 5 ++++-
1 files changed, 4 insertions(+), 1 deletion(-)
diff -puN arch/i386/kernel/kprobes.c~kprobes-i386-pagefault-handling-post_handler arch/i386/kernel/kprobes.c
--- linux-2.6.16-rc4-mm2/arch/i386/kernel/kprobes.c~kprobes-i386-pagefault-handling-post_handler 2006-02-27 13:59:13.000000000 +0530
+++ linux-2.6.16-rc4-mm2-prasanna/arch/i386/kernel/kprobes.c 2006-02-27 14:01:50.000000000 +0530
@@ -526,7 +526,9 @@ static inline int post_kprobe_handler(st
if (!cur)
return 0;
- if ((kcb->kprobe_status != KPROBE_REENTER) && cur->post_handler) {
+ if ((kcb->kprobe_status != KPROBE_REENTER)
+ && (kcb->kprobe_status != KPROBE_HIT_FAULT_SS)
+ && cur->post_handler) {
kcb->kprobe_status = KPROBE_HIT_SSDONE;
cur->post_handler(cur, regs, 0);
}
@@ -585,6 +587,7 @@ static inline int kprobe_fault_handler(s
*/
kcb->kprobe_status = KPROBE_HIT_FAULT;
/*fixup the exception*/
+ case KPROBE_HIT_SSDONE:
/*
* We increment the nmissed count for accounting,
* we can also use npre/npostfault count for accouting
_
--
Prasanna S Panchamukhi
Linux Technology Center
India Software Labs, IBM Bangalore
Email: prasanna@in.ibm.com
Ph: 91-80-51776329