From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 12647 invoked by alias); 27 Feb 2006 09:25:35 -0000 Received: (qmail 12640 invoked by uid 22791); 27 Feb 2006 09:25:35 -0000 X-Spam-Status: No, hits=-0.8 required=5.0 tests=AWL,BAYES_00,DNS_FROM_RFC_ABUSE,SPF_SOFTFAIL X-Spam-Check-By: sourceware.org Received: from e35.co.us.ibm.com (HELO e35.co.us.ibm.com) (32.97.110.153) by sourceware.org (qpsmtpd/0.31) with ESMTP; Mon, 27 Feb 2006 09:25:31 +0000 Received: from westrelay02.boulder.ibm.com (westrelay02.boulder.ibm.com [9.17.195.11]) by e35.co.us.ibm.com (8.12.11/8.12.11) with ESMTP id k1R9PUlR021381 for ; Mon, 27 Feb 2006 04:25:30 -0500 Received: from d03av02.boulder.ibm.com (d03av02.boulder.ibm.com [9.17.195.168]) by westrelay02.boulder.ibm.com (8.12.10/NCO/VER6.8) with ESMTP id k1R9Mxb0106832 for ; Mon, 27 Feb 2006 02:22:59 -0700 Received: from d03av02.boulder.ibm.com (loopback [127.0.0.1]) by d03av02.boulder.ibm.com (8.12.11/8.13.3) with ESMTP id k1R9PT0B027173 for ; Mon, 27 Feb 2006 02:25:29 -0700 Received: from newton.in.ibm.com ([9.124.35.47]) by d03av02.boulder.ibm.com (8.12.11/8.12.11) with ESMTP id k1R9PSGJ027127; Mon, 27 Feb 2006 02:25:29 -0700 Received: by newton.in.ibm.com (Postfix, from userid 500) id 9CED6CE3; Mon, 27 Feb 2006 14:57:05 +0530 (IST) Date: Mon, 27 Feb 2006 09:25:00 -0000 From: Prasanna S Panchamukhi To: "Keshavamurthy, Anil S" Cc: systemtap@sources.redhat.com Subject: Re: [PATCH] Kprobes- robust fault handling for i386 post_handler changes Message-ID: <20060227092705.GD6586@in.ibm.com> Reply-To: prasanna@in.ibm.com References: <44BDAFB888F59F408FAE3CC35AB470410313D68D@orsmsx409> <20060227092535.GC6586@in.ibm.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20060227092535.GC6586@in.ibm.com> User-Agent: Mutt/1.4.1i X-IsSubscribed: yes Mailing-List: contact systemtap-help@sourceware.org; run by ezmlm Precedence: bulk List-Subscribe: List-Post: List-Help: , Sender: systemtap-owner@sourceware.org X-SW-Source: 2006-q1/txt/msg00635.txt.bz2 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 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