All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] trace-cmd: Don't SIGSEGV when event field format cannot be parsed.
@ 2010-07-13 18:44 David Daney
  2010-07-22 20:08 ` Steven Rostedt
  0 siblings, 1 reply; 4+ messages in thread
From: David Daney @ 2010-07-13 18:44 UTC (permalink / raw)
  To: rostedt; +Cc: linux-kernel, David Daney

>From the MIPS kernel we get things like:

print fmt: "page=%p pfn=%lu order=%d migratetype=%d", REC->page, ({ struct page *__pg = (REC->page); int __sec = page_to_section(__pg); (unsigned long)(__pg - __section_mem_map_addr(__nr_to_section(__sec))); }), REC->order, REC->migratetype

This cannot be parsed, leading to a NULL struct event_format* being
passed to pevent_get_common_field_val, which produces a SIGSEGV.  It
would be good to get a parsable format from the kernel, but to
remediate the problem for legacy kernels, we can just return an error
indicator in this case.  This allows some output from trace-cmd
report, although perhaps with some missing data.  But this is better
than crashing.

Signed-off-by: David Daney <ddaney@caviumnetworks.com>
---
 parse-events.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/parse-events.c b/parse-events.c
index 9d5a3fa..16fff12 100644
--- a/parse-events.c
+++ b/parse-events.c
@@ -4481,6 +4481,9 @@ int pevent_get_common_field_val(struct trace_seq *s, struct event_format *event,
 {
 	struct format_field *field;
 
+	if (!event)
+		return -1;
+
 	field = pevent_find_common_field(event, name);
 
 	return get_field_val(s, field, name, record, val, err);
-- 
1.6.6.1


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

* Re: [PATCH] trace-cmd: Don't SIGSEGV when event field format cannot be parsed.
  2010-07-13 18:44 [PATCH] trace-cmd: Don't SIGSEGV when event field format cannot be parsed David Daney
@ 2010-07-22 20:08 ` Steven Rostedt
  2010-07-22 21:05   ` [PATCH] trace-cmd: Don't SIGSEGV when event field format cannot be parsed (v2) David Daney
  0 siblings, 1 reply; 4+ messages in thread
From: Steven Rostedt @ 2010-07-22 20:08 UTC (permalink / raw)
  To: David Daney; +Cc: linux-kernel

On Tue, 2010-07-13 at 11:44 -0700, David Daney wrote:
> >From the MIPS kernel we get things like:
> 
> print fmt: "page=%p pfn=%lu order=%d migratetype=%d", REC->page, ({ struct page *__pg = (REC->page); int __sec = page_to_section(__pg); (unsigned long)(__pg - __section_mem_map_addr(__nr_to_section(__sec))); }), REC->order, REC->migratetype
> 
> This cannot be parsed, leading to a NULL struct event_format* being
> passed to pevent_get_common_field_val, which produces a SIGSEGV.  It
> would be good to get a parsable format from the kernel, but to
> remediate the problem for legacy kernels, we can just return an error
> indicator in this case.  This allows some output from trace-cmd
> report, although perhaps with some missing data.  But this is better
> than crashing.
> 
> Signed-off-by: David Daney <ddaney@caviumnetworks.com>
> ---
>  parse-events.c |    3 +++
>  1 files changed, 3 insertions(+), 0 deletions(-)
> 
> diff --git a/parse-events.c b/parse-events.c
> index 9d5a3fa..16fff12 100644
> --- a/parse-events.c
> +++ b/parse-events.c
> @@ -4481,6 +4481,9 @@ int pevent_get_common_field_val(struct trace_seq *s, struct event_format *event,
>  {

To be consistent, probably all the pevent_get_*field* should test for
null event.

Did you want to resend a patch that does that?

-- Steve

>  	struct format_field *field;
>  
> +	if (!event)
> +		return -1;
> +
>  	field = pevent_find_common_field(event, name);
>  
>  	return get_field_val(s, field, name, record, val, err);



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

* [PATCH] trace-cmd: Don't SIGSEGV when event field format cannot be parsed (v2).
  2010-07-22 20:08 ` Steven Rostedt
@ 2010-07-22 21:05   ` David Daney
  2010-07-23 15:10     ` Steven Rostedt
  0 siblings, 1 reply; 4+ messages in thread
From: David Daney @ 2010-07-22 21:05 UTC (permalink / raw)
  To: rostedt; +Cc: linux-kernel, David Daney

>From the MIPS kernel we get things like:

print fmt: "page=%p pfn=%lu order=%d migratetype=%d", REC->page, ({ struct page *__pg = (REC->page); int __sec = page_to_section(__pg); (unsigned long)(__pg - __section_mem_map_addr(__nr_to_section(__sec))); }), REC->order, REC->migratetype

This cannot be parsed, leading to a NULL struct event_format* being
passed to pevent_get_common_field_val, which produces a SIGSEGV.  It
would be good to get a parsable format from the kernel, but to
remediate the problem for legacy kernels, we can just return an error
indicator in this case.  This allows some output from trace-cmd
report, although perhaps with some missing data.  But this is better
than crashing.

(v2): Do the check in all pevent_get_*

Signed-off-by: David Daney <ddaney@caviumnetworks.com>
---
 parse-events.c |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/parse-events.c b/parse-events.c
index 1e854e2..595ba90 100644
--- a/parse-events.c
+++ b/parse-events.c
@@ -4464,6 +4464,9 @@ int pevent_get_field_val(struct trace_seq *s, struct event_format *event,
 {
 	struct format_field *field;
 
+	if (!event)
+		return -1;
+
 	field = pevent_find_field(event, name);
 
 	return get_field_val(s, field, name, record, val, err);
@@ -4486,6 +4489,9 @@ int pevent_get_common_field_val(struct trace_seq *s, struct event_format *event,
 {
 	struct format_field *field;
 
+	if (!event)
+		return -1;
+
 	field = pevent_find_common_field(event, name);
 
 	return get_field_val(s, field, name, record, val, err);
@@ -4508,6 +4514,9 @@ int pevent_get_any_field_val(struct trace_seq *s, struct event_format *event,
 {
 	struct format_field *field;
 
+	if (!event)
+		return -1;
+
 	field = pevent_find_any_field(event, name);
 
 	return get_field_val(s, field, name, record, val, err);
-- 
1.7.1.1


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

* Re: [PATCH] trace-cmd: Don't SIGSEGV when event field format cannot be parsed (v2).
  2010-07-22 21:05   ` [PATCH] trace-cmd: Don't SIGSEGV when event field format cannot be parsed (v2) David Daney
@ 2010-07-23 15:10     ` Steven Rostedt
  0 siblings, 0 replies; 4+ messages in thread
From: Steven Rostedt @ 2010-07-23 15:10 UTC (permalink / raw)
  To: David Daney; +Cc: linux-kernel

On Thu, 2010-07-22 at 14:05 -0700, David Daney wrote:
> >From the MIPS kernel we get things like:
> 
> print fmt: "page=%p pfn=%lu order=%d migratetype=%d", REC->page, ({ struct page *__pg = (REC->page); int __sec = page_to_section(__pg); (unsigned long)(__pg - __section_mem_map_addr(__nr_to_section(__sec))); }), REC->order, REC->migratetype
> 
> This cannot be parsed, leading to a NULL struct event_format* being
> passed to pevent_get_common_field_val, which produces a SIGSEGV.  It
> would be good to get a parsable format from the kernel, but to
> remediate the problem for legacy kernels, we can just return an error
> indicator in this case.  This allows some output from trace-cmd
> report, although perhaps with some missing data.  But this is better
> than crashing.
> 
> (v2): Do the check in all pevent_get_*
> 
> Signed-off-by: David Daney <ddaney@caviumnetworks.com>

Applied, thanks David!

-- Steve



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

end of thread, other threads:[~2010-07-23 15:10 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-07-13 18:44 [PATCH] trace-cmd: Don't SIGSEGV when event field format cannot be parsed David Daney
2010-07-22 20:08 ` Steven Rostedt
2010-07-22 21:05   ` [PATCH] trace-cmd: Don't SIGSEGV when event field format cannot be parsed (v2) David Daney
2010-07-23 15:10     ` Steven Rostedt

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.