This is the mail archive of the
systemtap@sourceware.org
mailing list for the systemtap project.
[PATCH] uprobes: register_uprobe() crashes when bailing out.
- From: Torsten Polle <Torsten dot Polle at gmx dot de>
- To: systemtap at sourceware dot org
- Date: Wed, 10 Apr 2013 22:40:08 +0200
- Subject: [PATCH] uprobes: register_uprobe() crashes when bailing out.
Hi,
I had a problem with register_uprobe() when it did not return
successfully. I've not checked whether any other uses of hlist_del() may
cause similar symptoms.
Kind Regards,
Torsten
>From 9ea411a8619d2fe7d927e8068c66059c7fd002a6 Mon Sep 17 00:00:00 2001
Message-Id: <9ea411a8619d2fe7d927e8068c66059c7fd002a6.1365626073.git.Torsten.Polle@gmx.de>
From: Torsten Polle <Torsten.Polle@gmx.de>
Date: Wed, 10 Apr 2013 22:33:47 +0200
Subject: [PATCH] uprobes: register_uprobe() crashes when bailing out.
uprobe_mk_process() initialises uproc->hlist, but does not put uproc on any
list, i.e. uproc_table. If register_uprobe() now bails out before uproc is put
on a list, uprobe_free_process() still tries to remove uproc from a list. But
hlist_del() only works, if the element is already on list. hlist_del_init()
first checks if the element is on any list, before it removes the element
(uproc) from the list.
Signed-off-by: Torsten Polle <Torsten.Polle@gmx.de>
---
runtime/linux/uprobes/uprobes.c | 2 +-
runtime/linux/uprobes2/uprobes.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/runtime/linux/uprobes/uprobes.c b/runtime/linux/uprobes/uprobes.c
index 01e2652..100dee9 100644
--- a/runtime/linux/uprobes/uprobes.c
+++ b/runtime/linux/uprobes/uprobes.c
@@ -519,7 +519,7 @@ static void uprobe_free_process(struct uprobe_process *uproc)
uprobe_release_ssol_vma(uproc);
if (area->slots)
kfree(area->slots);
- hlist_del(&uproc->hlist);
+ hlist_del_init(&uproc->hlist);
list_for_each_entry_safe(utask, tmp, &uproc->thread_list, list) {
/*
* utrace_detach() is OK here (required, it seems) even if
diff --git a/runtime/linux/uprobes2/uprobes.c b/runtime/linux/uprobes2/uprobes.c
index bb997f2..b8003f9 100644
--- a/runtime/linux/uprobes2/uprobes.c
+++ b/runtime/linux/uprobes2/uprobes.c
@@ -611,7 +611,7 @@ static void uprobe_free_process(struct uprobe_process *uproc, int in_callback)
if (area->slots)
kfree(area->slots);
- hlist_del(&uproc->hlist);
+ hlist_del_init(&uproc->hlist);
list_for_each_entry_safe(utask, tmp, &uproc->thread_list, list)
uprobe_free_task(utask, in_callback);
put_pid(uproc->tg_leader);
--
1.7.4.1