All of lore.kernel.org
 help / color / mirror / Atom feed
From: Masami Hiramatsu <mhiramat@redhat.com>
To: tony.luck@intel.com, Shaohua Li <shaohua.li@intel.com>
Cc: ia64 <linux-ia64@vger.kernel.org>,
	LKML <linux-kernel@vger.kernel.org>,
	systemtap-ml <systemtap@sources.redhat.com>
Subject: [PATCH]Fix the order of atomic operations in restore_previous_kprobes
Date: Fri, 18 Jan 2008 16:20:46 +0000	[thread overview]
Message-ID: <4790D1DE.8030700@redhat.com> (raw)

From: Masami Hiramatsu <mhiramat@redhat.com>

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 <mhiramat@redhat.com>
---
Details of this issue was reported to
http://sources.redhat.com/bugzilla/show_bug.cgi?id 71

   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



WARNING: multiple messages have this Message-ID (diff)
From: Masami Hiramatsu <mhiramat@redhat.com>
To: tony.luck@intel.com, Shaohua Li <shaohua.li@intel.com>
Cc: ia64 <linux-ia64@vger.kernel.org>,
	LKML <linux-kernel@vger.kernel.org>,
	systemtap-ml <systemtap@sources.redhat.com>
Subject: [PATCH]Fix the order of atomic operations in restore_previous_kprobes on ia64
Date: Fri, 18 Jan 2008 11:20:46 -0500	[thread overview]
Message-ID: <4790D1DE.8030700@redhat.com> (raw)

From: Masami Hiramatsu <mhiramat@redhat.com>

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 <mhiramat@redhat.com>
---
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



             reply	other threads:[~2008-01-18 16:20 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-01-18 16:20 Masami Hiramatsu [this message]
2008-01-18 16:20 ` [PATCH]Fix the order of atomic operations in restore_previous_kprobes on ia64 Masami Hiramatsu
2008-01-22  1:07 ` [PATCH]Fix the order of atomic operations in Shaohua Li
2008-01-22  1:07   ` [PATCH]Fix the order of atomic operations in restore_previous_kprobes on ia64 Shaohua Li

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4790D1DE.8030700@redhat.com \
    --to=mhiramat@redhat.com \
    --cc=linux-ia64@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=shaohua.li@intel.com \
    --cc=systemtap@sources.redhat.com \
    --cc=tony.luck@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.