Skip to contentSkip to conversation

Remove the node from rblist in strlist__remove

PATCH In review Suzuki K. Poulose 3 participants 9 messages Aug 29, 2012 – Nov 5, 2012 perf events

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Remove the node from rblist in strlist__remove

The following commit:

author David Ahern <[email protected]>

	Tue, 31 Jul 2012 04:31:33 +0000 (22:31 -0600)
committer	Arnaldo Carvalho de Melo <[email protected]>
	Fri, 3 Aug 2012 13:39:51 +0000 (10:39 -0300)

commit ee8dd3ca43f151d9fbe1edeef68fb8a77eb9f047

causes a double free during a probe deletion as the node is never removed from the list via strlist__remove(), even though it gets 'deleted' (read free()'d). This causes a double free when we do strlist__delete() as the node is already deleted but present in the rblist.

[suzukikp@suzukikp perf]$ sudo ./perf probe -a do_fork Added new event:
probe:do_fork (on do_fork)

You can now use it in all perf tools, such as:

perf record -e probe:do_fork -aR sleep 1

[suzukikp@suzukikp perf]$ sudo ./perf probe -d do_fork
Removed event: probe:do_fork
*** glibc detected *** ./perf: double free or corruption (fasttop): 0x000000000133d600 *** ======= Backtrace: =========
/lib64/libc.so.6[0x38eec7dda6]
./perf(rblist__delete+0x5c)[0x47d3dc] ./perf(del_perf_probe_events+0xb6)[0x47b826] ./perf(cmd_probe+0x471)[0x42c8d1]
./perf[0x4150b3]
./perf(main+0x501)[0x4148e1] /lib64/libc.so.6(__libc_start_main+0xed)[0x38eec2169d]
./perf[0x414a61]

Make sure we remove the node from the rblist before we delete the node. The rblist__remove_node() will invoke rblist->node_delete, which will take care of deleting the node with the suitable function provided by the user.

---

 tools/perf/util/strlist.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
tools/perf/util/strlist.c +1 -1
index 95856ff..155d8b7 100644
@@ -93,7 +93,7 @@ out:
 
 void strlist__remove(struct strlist *slist, struct str_node *snode)
 {
-	str_node__delete(snode, slist->dupstr);
+	rblist__remove_node(&slist->rblist, &snode->rb_node);
 }
 
 struct str_node *strlist__find(struct strlist *slist, const char *entry)
Acked-by on v1 1/1
#1 lore raw
Quoted 41 lines · Suzuki K. Poulose

The following commit:

author David Ahern <[email protected]>

	Tue, 31 Jul 2012 04:31:33 +0000 (22:31 -0600)
committer	Arnaldo Carvalho de Melo <[email protected]>
	Fri, 3 Aug 2012 13:39:51 +0000 (10:39 -0300)

commit ee8dd3ca43f151d9fbe1edeef68fb8a77eb9f047

causes a double free during a probe deletion as the node is never removed from the list via strlist__remove(), even though it gets 'deleted' (read free()'d). This causes a double free when we do strlist__delete() as the node is already deleted but present in the rblist.

[suzukikp@suzukikp perf]$ sudo ./perf probe -a do_fork Added new event:
probe:do_fork (on do_fork)

You can now use it in all perf tools, such as:

perf record -e probe:do_fork -aR sleep 1

[suzukikp@suzukikp perf]$ sudo ./perf probe -d do_fork
Removed event: probe:do_fork
*** glibc detected *** ./perf: double free or corruption (fasttop): 0x000000000133d600 *** ======= Backtrace: =========
/lib64/libc.so.6[0x38eec7dda6]
./perf(rblist__delete+0x5c)[0x47d3dc] ./perf(del_perf_probe_events+0xb6)[0x47b826] ./perf(cmd_probe+0x471)[0x42c8d1]
./perf[0x4150b3]
./perf(main+0x501)[0x4148e1] /lib64/libc.so.6(__libc_start_main+0xed)[0x38eec2169d]
./perf[0x414a61]

Make sure we remove the node from the rblist before we delete the node. The rblist__remove_node() will invoke rblist->node_delete, which will take care of deleting the node with the suitable function provided by the user.

Quoted 4 lines

Same type of change is needed for util/intlist.c if you want to submit one, otherwise I will take care of it.

David

#2 lore raw
Quoted 48 lines · David Ahern
Quoted 42 lines · Suzuki K. Poulose

The following commit:

author David Ahern <[email protected]>

    Tue, 31 Jul 2012 04:31:33 +0000 (22:31 -0600)
committer    Arnaldo Carvalho de Melo <[email protected]>
    Fri, 3 Aug 2012 13:39:51 +0000 (10:39 -0300)

commit ee8dd3ca43f151d9fbe1edeef68fb8a77eb9f047

causes a double free during a probe deletion as the node is never removed from the list via strlist__remove(), even though it gets 'deleted' (read free()'d). This causes a double free when we do strlist__delete() as the node is already deleted but present in the rblist.

[suzukikp@suzukikp perf]$ sudo ./perf probe -a do_fork Added new event:
probe:do_fork (on do_fork)

You can now use it in all perf tools, such as:

perf record -e probe:do_fork -aR sleep 1

[suzukikp@suzukikp perf]$ sudo ./perf probe -d do_fork Removed event: probe:do_fork
*** glibc detected *** ./perf: double free or corruption (fasttop):
0x000000000133d600 ***
======= Backtrace: ========= /lib64/libc.so.6[0x38eec7dda6] ./perf(rblist__delete+0x5c)[0x47d3dc] ./perf(del_perf_probe_events+0xb6)[0x47b826] ./perf(cmd_probe+0x471)[0x42c8d1]
./perf[0x4150b3]
./perf(main+0x501)[0x4148e1] /lib64/libc.so.6(__libc_start_main+0xed)[0x38eec2169d] ./perf[0x414a61]

Make sure we remove the node from the rblist before we delete the node. The rblist__remove_node() will invoke rblist->node_delete, which will take care of deleting the node with the suitable function provided by the user.

Quoted 4 lines
Quoted 4 lines

Same type of change is needed for util/intlist.c if you want to submit one, otherwise I will take care of it.

I can send it.

Thanks
Suzuki

#3 lore raw

PATCH 1/1 Fix intlist node removal

In reply to David Ahern

Similar to the one in :

	https://lkml.org/lkml/2012/8/29/27

Make sure we remove the node from the rblist before we delete the node. The rblist__remove_node() will invoke rblist->node_delete, which will take care of deleting the node with the suitable function provided by the user.

---

 tools/perf/util/intlist.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
tools/perf/util/intlist.c +2 -2
index fd530dc..77c504f 100644
@@ -52,9 +52,9 @@ int intlist__add(struct intlist *ilist, int i)
 	return rblist__add_node(&ilist->rblist, (void *)((long)i));
 }
 
-void intlist__remove(struct intlist *ilist __used, struct int_node *node)
+void intlist__remove(struct intlist *ilist, struct int_node *node)
 {
-	int_node__delete(node);
+	rblist__remove_node(&ilist->rblist, &node->rb_node);
 }
 
 struct int_node *intlist__find(struct intlist *ilist, int i)
Acked-by on v1 1/1
#4 lore raw

Re: [PATCH] [perf] Fix intlist node removal

Quoted 23 lines · Suzuki K. Poulose

Similar to the one in :

	https://lkml.org/lkml/2012/8/29/27

Make sure we remove the node from the rblist before we delete the node. The rblist__remove_node() will invoke rblist->node_delete, which will take care of deleting the node with the suitable function provided by the user.

---

  tools/perf/util/intlist.c |    4 ++--
  1 files changed, 2 insertions(+), 2 deletions(-)
tools/perf/util/intlist.c +0 -0
index fd530dc..77c504f 100644
@@ -52,9 +52,9 @@ int intlist__add(struct intlist *ilist, int i)
  	return rblist__add_node(&ilist->rblist, (void *)((long)i));

tools/perf/util/intlist.c int intlist__add(struct intlist *ilist, int i) · line 60

Quoted 10 lines
tools/perf/util/intlist.c +2 -2
  }
 
-void intlist__remove(struct intlist *ilist __used, struct int_node *node)
+void intlist__remove(struct intlist *ilist, struct int_node *node)
  {
-	int_node__delete(node);
+	rblist__remove_node(&ilist->rblist, &node->rb_node);
  }
 
  struct int_node *intlist__find(struct intlist *ilist, int i)
#5 lore raw

[tip:perf/core] perf tools: Fix intlist node removal

In reply to Suzuki K. Poulose
Commit-ID:  60ebf328762914b80d3e4e5f07bda599043c8eda
Gitweb:     http://git.kernel.org/tip/60ebf328762914b80d3e4e5f07bda599043c8eda
Author:     Suzuki K. Poulose <[email protected]>
AuthorDate: Fri, 31 Aug 2012 12:28:47 +0530
Committer:  Arnaldo Carvalho de Melo <[email protected]>
CommitDate: Wed, 5 Sep 2012 17:35:24 -0300

perf tools: Fix intlist node removal

Similar to the one in :

	https://lkml.org/lkml/2012/8/29/27

Make sure we remove the node from the rblist before we delete the node. The rblist__remove_node() will invoke rblist->node_delete, which will take care of deleting the node with the suitable function provided by the user.

---
 tools/perf/util/intlist.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
tools/perf/util/intlist.c +2 -2
index fd530dc..77c504f 100644
@@ -52,9 +52,9 @@ int intlist__add(struct intlist *ilist, int i)
 	return rblist__add_node(&ilist->rblist, (void *)((long)i));
 }
 
-void intlist__remove(struct intlist *ilist __used, struct int_node *node)
+void intlist__remove(struct intlist *ilist, struct int_node *node)
 {
-	int_node__delete(node);
+	rblist__remove_node(&ilist->rblist, &node->rb_node);
 }
 
 struct int_node *intlist__find(struct intlist *ilist, int i)
#6 lore raw

[tip:perf/core] perf tools: Remove the node from rblist in strlist__remove

In reply to Suzuki K. Poulose
Commit-ID:  4592281403e74dc4401d5803ec9948d43bbee7ae
Gitweb:     http://git.kernel.org/tip/4592281403e74dc4401d5803ec9948d43bbee7ae
Author:     Suzuki K. Poulose <[email protected]>
AuthorDate: Wed, 29 Aug 2012 11:30:07 +0530
Committer:  Arnaldo Carvalho de Melo <[email protected]>
CommitDate: Wed, 5 Sep 2012 17:36:42 -0300

perf tools: Remove the node from rblist in strlist__remove

The following commit:

author David Ahern <[email protected]>

	Tue, 31 Jul 2012 04:31:33 +0000 (22:31 -0600)
committer	Arnaldo Carvalho de Melo <[email protected]>
	Fri, 3 Aug 2012 13:39:51 +0000 (10:39 -0300)

commit ee8dd3ca43f151d9fbe1edeef68fb8a77eb9f047

causes a double free during a probe deletion as the node is never removed from the list via strlist__remove(), even though it gets 'deleted' (read free()'d). This causes a double free when we do strlist__delete() as the node is already deleted but present in the rblist.

[suzukikp@suzukikp perf]$ sudo ./perf probe -a do_fork Added new event:
probe:do_fork (on do_fork)

You can now use it in all perf tools, such as:

perf record -e probe:do_fork -aR sleep 1

[suzukikp@suzukikp perf]$ sudo ./perf probe -d do_fork
Removed event: probe:do_fork
*** glibc detected *** ./perf: double free or corruption (fasttop): 0x000000000133d600 *** ======= Backtrace: =========
/lib64/libc.so.6[0x38eec7dda6]
./perf(rblist__delete+0x5c)[0x47d3dc] ./perf(del_perf_probe_events+0xb6)[0x47b826] ./perf(cmd_probe+0x471)[0x42c8d1]
./perf[0x4150b3]
./perf(main+0x501)[0x4148e1] /lib64/libc.so.6(__libc_start_main+0xed)[0x38eec2169d]
./perf[0x414a61]

Make sure we remove the node from the rblist before we delete the node. The rblist__remove_node() will invoke rblist->node_delete, which will take care of deleting the node with the suitable function provided by the user.

---
 tools/perf/util/strlist.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
tools/perf/util/strlist.c +1 -1
index 95856ff..155d8b7 100644
@@ -93,7 +93,7 @@ out:
 
 void strlist__remove(struct strlist *slist, struct str_node *snode)
 {
-	str_node__delete(snode, slist->dupstr);
+	rblist__remove_node(&slist->rblist, &snode->rb_node);
 }
 
 struct str_node *strlist__find(struct strlist *slist, const char *entry)
#7 lore raw

Re: [tip:perf/core] perf tools: Remove the node from rblist in strlist__remove

Quoted 4 lines · tip-bot for Suzuki K. Poulose
Quoted 8 lines

Shouldn't this patch go to the -stable queues, too?

#8 lore raw

Re: [tip:perf/core] perf tools: Remove the node from rblist in strlist__remove

Quoted 15 lines · Hannes Frederic Sowa
Quoted 4 lines · tip-bot for Suzuki K. Poulose
Quoted 8 lines
Quoted 2 lines

Shouldn't this patch go to the -stable queues, too?

yes for 3.5

David