public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] [perf] convert_variable_type does not correctly check type of arrays
@ 2012-11-05 22:49 Hannes Frederic Sowa
  2012-11-07  7:46 ` Namhyung Kim
  0 siblings, 1 reply; 2+ messages in thread
From: Hannes Frederic Sowa @ 2012-11-05 22:49 UTC (permalink / raw)
  To: linux-kernel; +Cc: a.p.zijlstra, paulus, mingo, acme

While casting an array of (unsigned) chars to a string, perf does not
check the containing type but only the opaque type and is bailing out:

  $ perf probe -v -a 'neigh_destroy:22 dev->name:string'
  probe-definition(0): neigh_destroy:22 dev->name:string
  symbol:neigh_destroy file:(null) line:22 offset:0 return:0 lazy:(null)
  parsing arg: dev->name:string into type:string dev, name(1)
  1 arguments
  Use vmlinux: /home/hannes/linux/vmlinux
  Using /home/hannes/linux/vmlinux for symbols
  Probe point found: neigh_destroy+115
  Searching 'dev' variable in context.
  Converting variable dev into trace event.
  converting name in dev
  name type is (null).
  Failed to cast into string: name is not (unsigned) char *.
  Failed to find 'dev' in this function.
  An error occurred in debuginfo analysis (-22).
    Error: Failed to add events. (-22)

After the code flow ensures that type could only be a pointer or
array type, call die_get_real_type unconditionally again to fetch the
containing type and have further validation been done on that Die.

Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
Signed-off-by: Hannes Frederic Sowa <hannes@stressinduktion.org>
---
 tools/perf/util/probe-finder.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/tools/perf/util/probe-finder.c b/tools/perf/util/probe-finder.c
index 1daf5c1..2a61ea5 100644
--- a/tools/perf/util/probe-finder.c
+++ b/tools/perf/util/probe-finder.c
@@ -413,12 +413,13 @@ static int convert_variable_type(Dwarf_Die *vr_die,
 				   dwarf_diename(vr_die), dwarf_diename(&type));
 			return -EINVAL;
 		}
+		if (die_get_real_type(&type, &type) == NULL) {
+			pr_warning("Failed to get a type  information.\n");
+			return -ENOENT;
+		}
+		pr_debug("containing type of %s is %s.\n",
+			dwarf_diename(vr_die), dwarf_diename(&type));
 		if (ret == DW_TAG_pointer_type) {
-			if (die_get_real_type(&type, &type) == NULL) {
-				pr_warning("Failed to get a type"
-					   " information.\n");
-				return -ENOENT;
-			}
 			while (*ref_ptr)
 				ref_ptr = &(*ref_ptr)->next;
 			/* Add new reference with offset +0 */


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] [perf] convert_variable_type does not correctly check type of arrays
  2012-11-05 22:49 [PATCH] [perf] convert_variable_type does not correctly check type of arrays Hannes Frederic Sowa
@ 2012-11-07  7:46 ` Namhyung Kim
  0 siblings, 0 replies; 2+ messages in thread
From: Namhyung Kim @ 2012-11-07  7:46 UTC (permalink / raw)
  To: linux-kernel, Hannes Frederic Sowa
  Cc: a.p.zijlstra, paulus, mingo, acme, hyc.lee

Hi Hannes,

On Mon, 5 Nov 2012 23:49:16 +0100, Hannes Frederic Sowa wrote:
> While casting an array of (unsigned) chars to a string, perf does not
> check the containing type but only the opaque type and is bailing out:
>
>   $ perf probe -v -a 'neigh_destroy:22 dev->name:string'
>   probe-definition(0): neigh_destroy:22 dev->name:string
>   symbol:neigh_destroy file:(null) line:22 offset:0 return:0 lazy:(null)
>   parsing arg: dev->name:string into type:string dev, name(1)
>   1 arguments
>   Use vmlinux: /home/hannes/linux/vmlinux
>   Using /home/hannes/linux/vmlinux for symbols
>   Probe point found: neigh_destroy+115
>   Searching 'dev' variable in context.
>   Converting variable dev into trace event.
>   converting name in dev
>   name type is (null).
>   Failed to cast into string: name is not (unsigned) char *.
>   Failed to find 'dev' in this function.
>   An error occurred in debuginfo analysis (-22).
>     Error: Failed to add events. (-22)
>
> After the code flow ensures that type could only be a pointer or
> array type, call die_get_real_type unconditionally again to fetch the
> containing type and have further validation been done on that Die.

Hyeoncheol posted a same fix before, but not merged yet, Arnaldo?

  https://lkml.org/lkml/2012/9/20/3

Thanks,
Namhyung


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2012-11-07  7:46 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-11-05 22:49 [PATCH] [perf] convert_variable_type does not correctly check type of arrays Hannes Frederic Sowa
2012-11-07  7:46 ` Namhyung Kim

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox