Skip to contentSkip to conversation

kprobes: Calculate the index correctly when freeing the out-of-line execution slot.

PATCH In review Masami Hiramatsu 1 participant 2 messages Mar 9, 2010 – Mar 11, 2010 kprobes

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 kprobes: Calculate the index correctly when freeing the out-of-line execution slot.

Quoted 1 line

From : Ananth N Mavinakayanahalli <[email protected]>

When freeing the instruction slot, the arithmetic to calculate the index of the slot in the page needs to account for the total size of the instruction on the various architectures.

Calculate the index correctly when freeing the out-of-line execution slot.

---

kernel/kprobes.c +2 -1
Index: linux-8mar/kernel/kprobes.c
===================================================================
@@ -259,7 +259,8 @@
 	struct kprobe_insn_page *kip;
 
 	list_for_each_entry(kip, &c->pages, list) {
-		long idx = ((long)slot - (long)kip->insns) / c->insn_size;
+		long idx = ((long)slot - (long)kip->insns) /
+				(c->insn_size * sizeof(kprobe_opcode_t));
 		if (idx >= 0 && idx < slots_per_page(c)) {
 			WARN_ON(kip->slot_used[idx] != SLOT_USED);
 			if (dirty) {
Signature · 2 lines
Masami Hiramatsu
e-mail: [email protected]
#1 lore raw

[tip:perf/urgent] kprobes: Calculate the index correctly when freeing the out-of-line execution slot

Commit-ID:  83ff56f46a8532488ee364bb93a9cb2a59490d33
Gitweb:     http://git.kernel.org/tip/83ff56f46a8532488ee364bb93a9cb2a59490d33
Author:     Masami Hiramatsu <[email protected]>
AuthorDate: Tue, 9 Mar 2010 10:22:19 -0500
Committer:  Ingo Molnar <[email protected]>
CommitDate: Thu, 11 Mar 2010 14:06:16 +0100

kprobes: Calculate the index correctly when freeing the out-of-line execution slot

Quoted 1 line

From : Ananth N Mavinakayanahalli <[email protected]>

When freeing the instruction slot, the arithmetic to calculate the index of the slot in the page needs to account for the total size of the instruction on the various architectures.

Calculate the index correctly when freeing the out-of-line execution slot.

LKML-Reference: <[email protected]>

---
 kernel/kprobes.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
kernel/kprobes.c +2 -1
index fa034d2..0ed46f3 100644
@@ -259,7 +259,8 @@ static void __kprobes __free_insn_slot(struct kprobe_insn_cache *c,
 	struct kprobe_insn_page *kip;
 
 	list_for_each_entry(kip, &c->pages, list) {
-		long idx = ((long)slot - (long)kip->insns) / c->insn_size;
+		long idx = ((long)slot - (long)kip->insns) /
+				(c->insn_size * sizeof(kprobe_opcode_t));
 		if (idx >= 0 && idx < slots_per_page(c)) {
 			WARN_ON(kip->slot_used[idx] != SLOT_USED);
 			if (dirty) {