mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 0/3] [GIT PULL] tracing: fixes for 2.6.32
@ 2009-09-13  1:49 Steven Rostedt
  2009-09-13  1:49 ` [PATCH 1/3] tracing: prevent NULL pointer dereference in ftrace_raw_event_block_bio_bounce Steven Rostedt
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Steven Rostedt @ 2009-09-13  1:49 UTC (permalink / raw)
  To: linux-kernel
  Cc: Ingo Molnar, Andrew Morton, Frederic Weisbecker, Li Zefan,
	Thomas Gleixner, Carsten Emde


Ingo,

Please pull the latest tip/tracing/core tree, which can be found at:

  git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-2.6-trace.git
tip/tracing/core


Carsten Emde (3):
      tracing: prevent NULL pointer dereference in ftrace_raw_event_block_bio_bounce
      tracing: remove unused local variables in tracer probe functions
      tracing: do not update tracing_max_latency when tracer is stopped

----
 include/trace/events/block.h      |    4 +++-
 kernel/trace/trace.c              |    5 +++++
 kernel/trace/trace.h              |    1 +
 kernel/trace/trace_irqsoff.c      |   16 ++++------------
 kernel/trace/trace_sched_wakeup.c |   16 ++++------------
 5 files changed, 17 insertions(+), 25 deletions(-)
-- 

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

* [PATCH 1/3] tracing: prevent NULL pointer dereference in ftrace_raw_event_block_bio_bounce
  2009-09-13  1:49 [PATCH 0/3] [GIT PULL] tracing: fixes for 2.6.32 Steven Rostedt
@ 2009-09-13  1:49 ` Steven Rostedt
  2009-09-13  1:49 ` [PATCH 2/3] tracing: remove unused local variables in tracer probe functions Steven Rostedt
  2009-09-13  1:49 ` [PATCH 3/3] tracing: do not update tracing_max_latency when tracer is stopped Steven Rostedt
  2 siblings, 0 replies; 4+ messages in thread
From: Steven Rostedt @ 2009-09-13  1:49 UTC (permalink / raw)
  To: linux-kernel
  Cc: Ingo Molnar, Andrew Morton, Frederic Weisbecker, Li Zefan,
	Thomas Gleixner, Carsten Emde, Carsten Emde

[-- Attachment #1: 0001-tracing-prevent-NULL-pointer-dereference-in-ftrace_r.patch --]
[-- Type: text/plain, Size: 1570 bytes --]

From: Carsten Emde <Carsten.Emde@osadl.org>

Booting 2.6.31 and executing
   echo 1 >/sys/kernel/debug/tracing/events/enable
leads to
BUG: unable to handle kernel NULL pointer dereference at (null)
IP: [<c032a583>] ftrace_raw_event_block_bio_bounce+0x4b/0xb9

Apparently,
   bio = bio_map_user(q, NULL, uaddr, len, reading, gfp_mask);
is called in block/blk-map.c:58 where bio->bi_bdev in set to NULL and
still is NULL when an attempt is made to evaluate bio->bi_bdev->bd_dev
in include/trace/events/block.h:189.

The tracepoint should ensure bio->bi_bdev is not dereferenced, if NULL.

Signed-off-by: Carsten Emde <C.Emde@osadl.org>
LKML-Reference: <4AAAC9B1.9060505@osadl.org>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
---
 include/trace/events/block.h |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/include/trace/events/block.h b/include/trace/events/block.h
index 9a74b46..d86af94 100644
--- a/include/trace/events/block.h
+++ b/include/trace/events/block.h
@@ -171,6 +171,7 @@ TRACE_EVENT(block_rq_complete,
 		  (unsigned long long)__entry->sector,
 		  __entry->nr_sector, __entry->errors)
 );
+
 TRACE_EVENT(block_bio_bounce,
 
 	TP_PROTO(struct request_queue *q, struct bio *bio),
@@ -186,7 +187,8 @@ TRACE_EVENT(block_bio_bounce,
 	),
 
 	TP_fast_assign(
-		__entry->dev		= bio->bi_bdev->bd_dev;
+		__entry->dev		= bio->bi_bdev ?
+					  bio->bi_bdev->bd_dev : 0;
 		__entry->sector		= bio->bi_sector;
 		__entry->nr_sector	= bio->bi_size >> 9;
 		blk_fill_rwbs(__entry->rwbs, bio->bi_rw, bio->bi_size);
-- 
1.6.3.3

-- 

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

* [PATCH 2/3] tracing: remove unused local variables in tracer probe functions
  2009-09-13  1:49 [PATCH 0/3] [GIT PULL] tracing: fixes for 2.6.32 Steven Rostedt
  2009-09-13  1:49 ` [PATCH 1/3] tracing: prevent NULL pointer dereference in ftrace_raw_event_block_bio_bounce Steven Rostedt
@ 2009-09-13  1:49 ` Steven Rostedt
  2009-09-13  1:49 ` [PATCH 3/3] tracing: do not update tracing_max_latency when tracer is stopped Steven Rostedt
  2 siblings, 0 replies; 4+ messages in thread
From: Steven Rostedt @ 2009-09-13  1:49 UTC (permalink / raw)
  To: linux-kernel
  Cc: Ingo Molnar, Andrew Morton, Frederic Weisbecker, Li Zefan,
	Thomas Gleixner, Carsten Emde, Carsten Emde

[-- Attachment #1: 0002-tracing-remove-unused-local-variables-in-tracer-prob.patch --]
[-- Type: text/plain, Size: 2778 bytes --]

From: Carsten Emde <Carsten.Emde@osadl.org>

When the nsecs_to_usecs() conversion in probe_wakeup_sched_switch() and
check_critical_timing() was moved to a later stage in order to avoid
unnecessary computing, it was overlooked to remove the original
variables, assignments and comments..

Signed-off-by: Carsten Emde <C.Emde@osadl.org>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
---
 kernel/trace/trace_irqsoff.c      |   12 +-----------
 kernel/trace/trace_sched_wakeup.c |   10 ----------
 2 files changed, 1 insertions(+), 21 deletions(-)

diff --git a/kernel/trace/trace_irqsoff.c b/kernel/trace/trace_irqsoff.c
index 5555b75..06f8ea9 100644
--- a/kernel/trace/trace_irqsoff.c
+++ b/kernel/trace/trace_irqsoff.c
@@ -129,15 +129,10 @@ check_critical_timing(struct trace_array *tr,
 		      unsigned long parent_ip,
 		      int cpu)
 {
-	unsigned long latency, t0, t1;
 	cycle_t T0, T1, delta;
 	unsigned long flags;
 	int pc;
 
-	/*
-	 * usecs conversion is slow so we try to delay the conversion
-	 * as long as possible:
-	 */
 	T0 = data->preempt_timestamp;
 	T1 = ftrace_now(cpu);
 	delta = T1-T0;
@@ -157,17 +152,12 @@ check_critical_timing(struct trace_array *tr,
 
 	trace_function(tr, CALLER_ADDR0, parent_ip, flags, pc);
 
-	latency = nsecs_to_usecs(delta);
-
 	if (data->critical_sequence != max_sequence)
 		goto out_unlock;
 
-	tracing_max_latency = delta;
-	t0 = nsecs_to_usecs(T0);
-	t1 = nsecs_to_usecs(T1);
-
 	data->critical_end = parent_ip;
 
+	tracing_max_latency = delta;
 	update_max_tr_single(tr, current, cpu);
 
 	max_sequence++;
diff --git a/kernel/trace/trace_sched_wakeup.c b/kernel/trace/trace_sched_wakeup.c
index cf43bdb..6e1529b 100644
--- a/kernel/trace/trace_sched_wakeup.c
+++ b/kernel/trace/trace_sched_wakeup.c
@@ -110,7 +110,6 @@ static void notrace
 probe_wakeup_sched_switch(struct rq *rq, struct task_struct *prev,
 	struct task_struct *next)
 {
-	unsigned long latency = 0, t0 = 0, t1 = 0;
 	struct trace_array_cpu *data;
 	cycle_t T0, T1, delta;
 	unsigned long flags;
@@ -156,10 +155,6 @@ probe_wakeup_sched_switch(struct rq *rq, struct task_struct *prev,
 	trace_function(wakeup_trace, CALLER_ADDR0, CALLER_ADDR1, flags, pc);
 	tracing_sched_switch_trace(wakeup_trace, prev, next, flags, pc);
 
-	/*
-	 * usecs conversion is slow so we try to delay the conversion
-	 * as long as possible:
-	 */
 	T0 = data->preempt_timestamp;
 	T1 = ftrace_now(cpu);
 	delta = T1-T0;
@@ -167,12 +162,7 @@ probe_wakeup_sched_switch(struct rq *rq, struct task_struct *prev,
 	if (!report_latency(delta))
 		goto out_unlock;
 
-	latency = nsecs_to_usecs(delta);
-
 	tracing_max_latency = delta;
-	t0 = nsecs_to_usecs(T0);
-	t1 = nsecs_to_usecs(T1);
-
 	update_max_tr(wakeup_trace, wakeup_task, wakeup_cpu);
 
 out_unlock:
-- 
1.6.3.3

-- 

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

* [PATCH 3/3] tracing: do not update tracing_max_latency when tracer is stopped
  2009-09-13  1:49 [PATCH 0/3] [GIT PULL] tracing: fixes for 2.6.32 Steven Rostedt
  2009-09-13  1:49 ` [PATCH 1/3] tracing: prevent NULL pointer dereference in ftrace_raw_event_block_bio_bounce Steven Rostedt
  2009-09-13  1:49 ` [PATCH 2/3] tracing: remove unused local variables in tracer probe functions Steven Rostedt
@ 2009-09-13  1:49 ` Steven Rostedt
  2 siblings, 0 replies; 4+ messages in thread
From: Steven Rostedt @ 2009-09-13  1:49 UTC (permalink / raw)
  To: linux-kernel
  Cc: Ingo Molnar, Andrew Morton, Frederic Weisbecker, Li Zefan,
	Thomas Gleixner, Carsten Emde, Carsten Emde

[-- Attachment #1: 0003-tracing-do-not-update-tracing_max_latency-when-trace.patch --]
[-- Type: text/plain, Size: 2595 bytes --]

From: Carsten Emde <Carsten.Emde@osadl.org>

The state of the function pair tracing_stop()/tracing_start() is
correctly considered when tracer data are updated. However, the global
and externally accessible variable tracing_max_latency is always updated
- even when tracing is stopped.

The update should only occur, if tracing was not stopped.

Signed-off-by: Carsten Emde <C.Emde@osadl.org>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
---
 kernel/trace/trace.c              |    5 +++++
 kernel/trace/trace.h              |    1 +
 kernel/trace/trace_irqsoff.c      |    6 ++++--
 kernel/trace/trace_sched_wakeup.c |    6 ++++--
 4 files changed, 14 insertions(+), 4 deletions(-)

diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index 45c3f03..ef82a7f 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -825,6 +825,11 @@ static void trace_init_cmdlines(void)
 	cmdline_idx = 0;
 }
 
+int is_tracing_stopped(void)
+{
+	return trace_stop_count;
+}
+
 /**
  * ftrace_off_permanent - disable all ftrace code permanently
  *
diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h
index 28247ce..4ad4e1d 100644
--- a/kernel/trace/trace.h
+++ b/kernel/trace/trace.h
@@ -461,6 +461,7 @@ void tracing_stop_sched_switch_record(void);
 void tracing_start_sched_switch_record(void);
 int register_tracer(struct tracer *type);
 void unregister_tracer(struct tracer *type);
+int is_tracing_stopped(void);
 
 extern unsigned long nsecs_to_usecs(unsigned long nsecs);
 
diff --git a/kernel/trace/trace_irqsoff.c b/kernel/trace/trace_irqsoff.c
index 06f8ea9..3aa7eaa 100644
--- a/kernel/trace/trace_irqsoff.c
+++ b/kernel/trace/trace_irqsoff.c
@@ -157,8 +157,10 @@ check_critical_timing(struct trace_array *tr,
 
 	data->critical_end = parent_ip;
 
-	tracing_max_latency = delta;
-	update_max_tr_single(tr, current, cpu);
+	if (likely(!is_tracing_stopped())) {
+		tracing_max_latency = delta;
+		update_max_tr_single(tr, current, cpu);
+	}
 
 	max_sequence++;
 
diff --git a/kernel/trace/trace_sched_wakeup.c b/kernel/trace/trace_sched_wakeup.c
index 6e1529b..26185d7 100644
--- a/kernel/trace/trace_sched_wakeup.c
+++ b/kernel/trace/trace_sched_wakeup.c
@@ -162,8 +162,10 @@ probe_wakeup_sched_switch(struct rq *rq, struct task_struct *prev,
 	if (!report_latency(delta))
 		goto out_unlock;
 
-	tracing_max_latency = delta;
-	update_max_tr(wakeup_trace, wakeup_task, wakeup_cpu);
+	if (likely(!is_tracing_stopped())) {
+		tracing_max_latency = delta;
+		update_max_tr(wakeup_trace, wakeup_task, wakeup_cpu);
+	}
 
 out_unlock:
 	__wakeup_reset(wakeup_trace);
-- 
1.6.3.3

-- 

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

end of thread, other threads:[~2009-09-13  1:50 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-09-13  1:49 [PATCH 0/3] [GIT PULL] tracing: fixes for 2.6.32 Steven Rostedt
2009-09-13  1:49 ` [PATCH 1/3] tracing: prevent NULL pointer dereference in ftrace_raw_event_block_bio_bounce Steven Rostedt
2009-09-13  1:49 ` [PATCH 2/3] tracing: remove unused local variables in tracer probe functions Steven Rostedt
2009-09-13  1:49 ` [PATCH 3/3] tracing: do not update tracing_max_latency when tracer is stopped Steven Rostedt

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

all inboxes | Powered by JetHome®