Skip to contentSkip to conversation

Fix the order of atomic operations in restore_previous_kprobes on ia64

PATCH In review Masami Hiramatsu 2 participants 2 messages Jan 18, 2008 – Jan 22, 2008

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Fix the order of atomic operations in restore_previous_kprobes on ia64

From: Masami Hiramatsu <[email protected]>

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.

---
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,

Signature · 7 lines
Masami Hiramatsu

Software Engineer
Hitachi Computer Products (America) Inc.
Software Solutions Division

e-mail: [email protected], [email protected]
#1 lore raw
Quoted 34 lines · Masami Hiramatsu

From: Masami Hiramatsu <[email protected]>

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.

---
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

(quoted diff) +4 -3
@@ -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);
   }
 
Quoted 1 line

static void __kprobes set_current_kprobe(struct kprobe *p,

Acked. Thanks for the patch.

Thanks,
Shaohua