Skip to content

Commit 4fe9af8

Browse files
icklerodrigovivi
authored andcommitted
drm/i915/gem: Serialise debugfs i915_gem_objects with ctx->mutex
Since the debugfs may peek into the GEM contexts as the corresponding client/fd is being closed, we may try and follow a dangling pointer. However, the context closure itself is serialised with the ctx->mutex, so if we hold that mutex as we inspect the state coupled in the context, we know the pointers within the context are stable and will remain valid as we inspect their tables. Signed-off-by: Chris Wilson <[email protected]> Cc: CQ Tang <[email protected]> Cc: Daniel Vetter <[email protected]> Cc: [email protected] Reviewed-by: Tvrtko Ursulin <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected] (cherry picked from commit 102f5aa) Signed-off-by: Rodrigo Vivi <[email protected]>
1 parent cef8ce5 commit 4fe9af8

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

drivers/gpu/drm/i915/i915_debugfs.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,7 @@ static void print_context_stats(struct seq_file *m,
326326
}
327327
i915_gem_context_unlock_engines(ctx);
328328

329+
mutex_lock(&ctx->mutex);
329330
if (!IS_ERR_OR_NULL(ctx->file_priv)) {
330331
struct file_stats stats = {
331332
.vm = rcu_access_pointer(ctx->vm),
@@ -346,6 +347,7 @@ static void print_context_stats(struct seq_file *m,
346347

347348
print_file_stats(m, name, stats);
348349
}
350+
mutex_unlock(&ctx->mutex);
349351

350352
spin_lock(&i915->gem.contexts.lock);
351353
list_safe_reset_next(ctx, cn, link);

0 commit comments

Comments
 (0)