* [PATCH] drm/i915: Do not dereference pointers from ring buffer in evict event
@ 2014-03-18 15:27 Steven Rostedt
2014-03-18 15:31 ` Steven Rostedt
0 siblings, 1 reply; 4+ messages in thread
From: Steven Rostedt @ 2014-03-18 15:27 UTC (permalink / raw)
To: LKML
Cc: Daniel Vetter, Ben Widawsky, Chris Wilson, Ramkumar Ramachandra,
Jiri Olsa, Arnaldo Carvalho de Melo, Namhyung Kim, stable
The TP_printk() should never dereference any pointers, because the ring
buffer can be read at some unknown time in the future. If a device no
longer exists, it can cause a kernel oops. This also makes this
event useless when saving the ring buffer in userspaces tools such as
perf and trace-cmd.
The i915_gem_evict_vm dereferences the vm pointer which may also not
exist when the ring buffer is read sometime in the future.
Link: http://lkml.kernel.org/r/1395095198-20034-3-git-send-email-artagnon@gmail.com
Reported-by: Ramkumar Ramachandra <artagnon@gmail.com> Cc:
stable@vger.kernel.org # 3.13+
Fixes: bcccff847d1f "drm/i915: trace vm eviction instead of everything"
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
---
diff --git a/drivers/gpu/drm/i915/i915_trace.h b/drivers/gpu/drm/i915/i915_trace.h
index 6e580c9..f3e8a90 100644
--- a/drivers/gpu/drm/i915/i915_trace.h
+++ b/drivers/gpu/drm/i915/i915_trace.h
@@ -238,14 +238,16 @@ TRACE_EVENT(i915_gem_evict_vm,
TP_ARGS(vm),
TP_STRUCT__entry(
+ __field(u32, dev)
__field(struct i915_address_space *, vm)
),
TP_fast_assign(
+ __entry->dev = dev->primary->index;
__entry->vm = vm;
),
- TP_printk("dev=%d, vm=%p", __entry->vm->dev->primary->index, __entry->vm)
+ TP_printk("dev=%d, vm=%p", __entry->dev, __entry->vm)
);
TRACE_EVENT(i915_gem_ring_sync_to,
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] drm/i915: Do not dereference pointers from ring buffer in evict event
2014-03-18 15:27 [PATCH] drm/i915: Do not dereference pointers from ring buffer in evict event Steven Rostedt
@ 2014-03-18 15:31 ` Steven Rostedt
2014-03-18 19:50 ` Daniel Vetter
0 siblings, 1 reply; 4+ messages in thread
From: Steven Rostedt @ 2014-03-18 15:31 UTC (permalink / raw)
To: Steven Rostedt
Cc: LKML, Daniel Vetter, Ben Widawsky, Chris Wilson,
Ramkumar Ramachandra, Jiri Olsa, Arnaldo Carvalho de Melo,
Namhyung Kim, stable
On Tue, 18 Mar 2014 11:27:37 -0400
Steven Rostedt <rostedt@goodmis.org> wrote:
> The TP_printk() should never dereference any pointers, because the ring
> buffer can be read at some unknown time in the future. If a device no
> longer exists, it can cause a kernel oops. This also makes this
> event useless when saving the ring buffer in userspaces tools such as
> perf and trace-cmd.
>
> The i915_gem_evict_vm dereferences the vm pointer which may also not
> exist when the ring buffer is read sometime in the future.
>
> Link: http://lkml.kernel.org/r/1395095198-20034-3-git-send-email-artagnon@gmail.com
> Reported-by: Ramkumar Ramachandra <artagnon@gmail.com> Cc:
> stable@vger.kernel.org # 3.13+
Bah, claw's mail is playing havoc with my line wraps. Please fix the
above when applying, or I can send anothe patch. Thanks :-)
I had to re-insert the patch due to it but didn't see the screw up with
the Cc of stable.
-- Steve
> Fixes: bcccff847d1f "drm/i915: trace vm eviction instead of everything"
> Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
> ---
> diff --git a/drivers/gpu/drm/i915/i915_trace.h b/drivers/gpu/drm/i915/i915_trace.h
> index 6e580c9..f3e8a90 100644
> --- a/drivers/gpu/drm/i915/i915_trace.h
> +++ b/drivers/gpu/drm/i915/i915_trace.h
> @@ -238,14 +238,16 @@ TRACE_EVENT(i915_gem_evict_vm,
> TP_ARGS(vm),
>
> TP_STRUCT__entry(
> + __field(u32, dev)
> __field(struct i915_address_space *, vm)
> ),
>
> TP_fast_assign(
> + __entry->dev = dev->primary->index;
> __entry->vm = vm;
> ),
>
> - TP_printk("dev=%d, vm=%p", __entry->vm->dev->primary->index, __entry->vm)
> + TP_printk("dev=%d, vm=%p", __entry->dev, __entry->vm)
> );
>
> TRACE_EVENT(i915_gem_ring_sync_to,
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] drm/i915: Do not dereference pointers from ring buffer in evict event
2014-03-18 15:31 ` Steven Rostedt
@ 2014-03-18 19:50 ` Daniel Vetter
2014-03-19 1:25 ` [PATCH v2] " Steven Rostedt
0 siblings, 1 reply; 4+ messages in thread
From: Daniel Vetter @ 2014-03-18 19:50 UTC (permalink / raw)
To: Steven Rostedt
Cc: LKML, Daniel Vetter, Ben Widawsky, Chris Wilson,
Ramkumar Ramachandra, Jiri Olsa, Arnaldo Carvalho de Melo,
Namhyung Kim, stable
On Tue, Mar 18, 2014 at 11:31:36AM -0400, Steven Rostedt wrote:
> On Tue, 18 Mar 2014 11:27:37 -0400
> Steven Rostedt <rostedt@goodmis.org> wrote:
>
> > The TP_printk() should never dereference any pointers, because the ring
> > buffer can be read at some unknown time in the future. If a device no
> > longer exists, it can cause a kernel oops. This also makes this
> > event useless when saving the ring buffer in userspaces tools such as
> > perf and trace-cmd.
> >
> > The i915_gem_evict_vm dereferences the vm pointer which may also not
> > exist when the ring buffer is read sometime in the future.
> >
> > Link: http://lkml.kernel.org/r/1395095198-20034-3-git-send-email-artagnon@gmail.com
> > Reported-by: Ramkumar Ramachandra <artagnon@gmail.com> Cc:
> > stable@vger.kernel.org # 3.13+
>
> Bah, claw's mail is playing havoc with my line wraps. Please fix the
> above when applying, or I can send anothe patch. Thanks :-)
>
> I had to re-insert the patch due to it but didn't see the screw up with
> the Cc of stable.
Patch applied and cc: stable fixed, thanks.
-Daniel
--
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH v2] drm/i915: Do not dereference pointers from ring buffer in evict event
2014-03-18 19:50 ` Daniel Vetter
@ 2014-03-19 1:25 ` Steven Rostedt
0 siblings, 0 replies; 4+ messages in thread
From: Steven Rostedt @ 2014-03-19 1:25 UTC (permalink / raw)
To: Daniel Vetter
Cc: LKML, Daniel Vetter, Ben Widawsky, Chris Wilson,
Ramkumar Ramachandra, Jiri Olsa, Arnaldo Carvalho de Melo,
Namhyung Kim, stable
The TP_printk() should never dereference any pointers, because the ring
buffer can be read at some unknown time in the future. If a device no
longer exists, it can cause a kernel oops. This also makes this
event useless when saving the ring buffer in userspaces tools such as
perf and trace-cmd.
The i915_gem_evict_vm dereferences the vm pointer which may also not
exist when the ring buffer is read sometime in the future.
Link: http://lkml.kernel.org/r/1395095198-20034-3-git-send-email-artagnon@gmail.com
Reported-by: Ramkumar Ramachandra <artagnon@gmail.com>
Cc: stable@vger.kernel.org # 3.13+
Fixes: bcccff847d1f "drm/i915: trace vm eviction instead of everything"
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
---
v2 - fixed build bug. This time tested on a box with an i915.
diff --git a/drivers/gpu/drm/i915/i915_trace.h b/drivers/gpu/drm/i915/i915_trace.h
index 6e580c9..783ae08 100644
--- a/drivers/gpu/drm/i915/i915_trace.h
+++ b/drivers/gpu/drm/i915/i915_trace.h
@@ -238,14 +238,16 @@ TRACE_EVENT(i915_gem_evict_vm,
TP_ARGS(vm),
TP_STRUCT__entry(
+ __field(u32, dev)
__field(struct i915_address_space *, vm)
),
TP_fast_assign(
+ __entry->dev = vm->dev->primary->index;
__entry->vm = vm;
),
- TP_printk("dev=%d, vm=%p", __entry->vm->dev->primary->index, __entry->vm)
+ TP_printk("dev=%d, vm=%p", __entry->dev, __entry->vm)
);
TRACE_EVENT(i915_gem_ring_sync_to,
^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2014-03-19 1:25 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-03-18 15:27 [PATCH] drm/i915: Do not dereference pointers from ring buffer in evict event Steven Rostedt
2014-03-18 15:31 ` Steven Rostedt
2014-03-18 19:50 ` Daniel Vetter
2014-03-19 1:25 ` [PATCH v2] " 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.