Skip to contentSkip to conversation

uprobes: Fix utask->depth accounting in handle_trampoline()

PATCH In review Oleg Nesterov 3 participants 3 messages Sep 11, 2013 – Sep 12, 2013

Subsystems (2)
lore
Share & tools
lore

Oleg Nesterov

author maintainer
#0 lore raw

PATCH 1/1 uprobes: Fix utask->depth accounting in handle_trampoline()

Currently utask->depth is simply the number of allocated/pending return_instance's in uprobe_task->return_instances list.

handle_trampoline() should decrement this counter every time we handle/free an instance, but due to typo it does this only if ->chained == T. This means that in the likely case this counter is never decremented and the probed task can't report more than MAX_URETPROBE_DEPTH events.

---
 kernel/events/uprobes.c |    4 +---
 1 files changed, 1 insertions(+), 3 deletions(-)
kernel/events/uprobes.c +1 -3
index f356974..ad8e1bd 100644
@@ -1682,12 +1682,10 @@ static bool handle_trampoline(struct pt_regs *regs)
 		tmp = ri;
 		ri = ri->next;
 		kfree(tmp);
+		utask->depth--;
 
 		if (!chained)
 			break;
-
-		utask->depth--;
-
 		BUG_ON(!ri);
 	}
 
Signature · 1 line
1.5.5.1
Acked-by on v1 1/1
#1 lore raw
Quoted 9 lines · Oleg Nesterov

Currently utask->depth is simply the number of allocated/pending return_instance's in uprobe_task->return_instances list.

handle_trampoline() should decrement this counter every time we handle/free an instance, but due to typo it does this only if ->chained == T. This means that in the likely case this counter is never decremented and the probed task can't report more than MAX_URETPROBE_DEPTH events.

Quoted 4 lines

Mikhail Kulemin has verified that this fix works for him.

Quoted 26 lines
---
 kernel/events/uprobes.c |    4 +---
 1 files changed, 1 insertions(+), 3 deletions(-)
kernel/events/uprobes.c +1 -3
index f356974..ad8e1bd 100644
@@ -1682,12 +1682,10 @@ static bool handle_trampoline(struct pt_regs *regs)
 		tmp = ri;
 		ri = ri->next;
 		kfree(tmp);
+		utask->depth--;
 
 		if (!chained)
 			break;
-
-		utask->depth--;
-
 		BUG_ON(!ri);
 	}
 
Signature · 1 line
1.5.5.1
Signature · 2 lines
Thanks and Regards
Srikar Dronamraju
#2 lore raw

[tip:perf/urgent] uprobes: Fix utask-> depth accounting in handle_trampoline()

In reply to Oleg Nesterov
uprobes: Fix utask->depth accounting in handle_trampoline()
Commit-ID:  878b5a6efd38030c7a90895dc8346e8fb1e09b4c
Gitweb:     http://git.kernel.org/tip/878b5a6efd38030c7a90895dc8346e8fb1e09b4c
Author:     Oleg Nesterov <[email protected]>
AuthorDate: Wed, 11 Sep 2013 17:47:26 +0200
Committer:  Ingo Molnar <[email protected]>
CommitDate: Thu, 12 Sep 2013 08:00:55 +0200

uprobes: Fix utask->depth accounting in handle_trampoline()

Currently utask->depth is simply the number of allocated/pending return_instance's in uprobe_task->return_instances list.

handle_trampoline() should decrement this counter every time we handle/free an instance, but due to typo it does this only if ->chained == T. This means that in the likely case this counter is never decremented and the probed task can't report more than MAX_URETPROBE_DEPTH events.

---
 kernel/events/uprobes.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
kernel/events/uprobes.c +1 -3
index f356974..ad8e1bd 100644
@@ -1682,12 +1682,10 @@ static bool handle_trampoline(struct pt_regs *regs)
 		tmp = ri;
 		ri = ri->next;
 		kfree(tmp);
+		utask->depth--;
 
 		if (!chained)
 			break;
-
-		utask->depth--;
-
 		BUG_ON(!ri);
 	}