Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1762750AbYARQVg (ORCPT ); Fri, 18 Jan 2008 11:21:36 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1760872AbYARQV2 (ORCPT ); Fri, 18 Jan 2008 11:21:28 -0500 Received: from mx1.redhat.com ([66.187.233.31]:60153 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1760142AbYARQV0 (ORCPT ); Fri, 18 Jan 2008 11:21:26 -0500 Message-ID: <4790D1DE.8030700@redhat.com> Date: Fri, 18 Jan 2008 11:20:46 -0500 From: Masami Hiramatsu User-Agent: Thunderbird 2.0.0.9 (X11/20071115) MIME-Version: 1.0 To: tony.luck@intel.com, Shaohua Li CC: ia64 , LKML , systemtap-ml Subject: [PATCH]Fix the order of atomic operations in restore_previous_kprobes on ia64 X-Enigmail-Version: 0.95.6 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1699 Lines: 48 From: Masami Hiramatsu Fix the order of atomic operations to prevent overwriting prev_kprobe[0]. To pop values from stack, we must decrement stack index right AFTER reading values. Signed-off-by: Masami Hiramatsu --- Details of this issue was reported to http://sources.redhat.com/bugzilla/show_bug.cgi?id=2071 arch/ia64/kernel/kprobes.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) Index: 2.6.24-rc8/arch/ia64/kernel/kprobes.c =================================================================== --- 2.6.24-rc8.orig/arch/ia64/kernel/kprobes.c 2008-01-17 21:14:01.000000000 -0500 +++ 2.6.24-rc8/arch/ia64/kernel/kprobes.c 2008-01-17 21:14:01.000000000 -0500 @@ -381,9 +381,10 @@ static void __kprobes restore_previous_kprobe(struct kprobe_ctlblk *kcb) { unsigned int i; - i = atomic_sub_return(1, &kcb->prev_kprobe_index); - __get_cpu_var(current_kprobe) = kcb->prev_kprobe[i].kp; - kcb->kprobe_status = kcb->prev_kprobe[i].status; + i = atomic_read(&kcb->prev_kprobe_index); + __get_cpu_var(current_kprobe) = kcb->prev_kprobe[i-1].kp; + kcb->kprobe_status = kcb->prev_kprobe[i-1].status; + atomic_sub(1, &kcb->prev_kprobe_index); } static void __kprobes set_current_kprobe(struct kprobe *p, -- Masami Hiramatsu Software Engineer Hitachi Computer Products (America) Inc. Software Solutions Division e-mail: mhiramat@redhat.com, masami.hiramatsu.pt@hitachi.com -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/