[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20240502223341.1835070-3-keescook@chromium.org>
Date: Thu, 2 May 2024 15:33:38 -0700
From: Kees Cook <keescook@...omium.org>
To: Christian Brauner <brauner@...nel.org>
Cc: Kees Cook <keescook@...omium.org>,
Jani Nikula <jani.nikula@...ux.intel.com>,
Joonas Lahtinen <joonas.lahtinen@...ux.intel.com>,
Rodrigo Vivi <rodrigo.vivi@...el.com>,
Tvrtko Ursulin <tursulin@...ulin.net>,
David Airlie <airlied@...il.com>,
Daniel Vetter <daniel@...ll.ch>,
Andi Shyti <andi.shyti@...ux.intel.com>,
Lucas De Marchi <lucas.demarchi@...el.com>,
Matt Atwood <matthew.s.atwood@...el.com>,
Matthew Auld <matthew.auld@...el.com>,
Nirmoy Das <nirmoy.das@...el.com>,
Jonathan Cavitt <jonathan.cavitt@...el.com>,
intel-gfx@...ts.freedesktop.org,
dri-devel@...ts.freedesktop.org,
Al Viro <viro@...iv.linux.org.uk>,
Jan Kara <jack@...e.cz>,
Zack Rusin <zack.rusin@...adcom.com>,
Broadcom internal kernel review list <bcm-kernel-feedback-list@...adcom.com>,
Maarten Lankhorst <maarten.lankhorst@...ux.intel.com>,
Maxime Ripard <mripard@...nel.org>,
Thomas Zimmermann <tzimmermann@...e.de>,
Will Deacon <will@...nel.org>,
Peter Zijlstra <peterz@...radead.org>,
Boqun Feng <boqun.feng@...il.com>,
Mark Rutland <mark.rutland@....com>,
Kent Overstreet <kent.overstreet@...ux.dev>,
Masahiro Yamada <masahiroy@...nel.org>,
Nathan Chancellor <nathan@...nel.org>,
Nicolas Schier <nicolas@...sle.eu>,
Andrew Morton <akpm@...ux-foundation.org>,
linux-kernel@...r.kernel.org,
linux-fsdevel@...r.kernel.org,
linux-kbuild@...r.kernel.org,
linux-hardening@...r.kernel.org
Subject: [PATCH 3/5] drm/i915: Do not directly manipulate file->f_count
The correct helper for taking an f_count reference is get_file(). Use it
and check results.
Signed-off-by: Kees Cook <keescook@...omium.org>
---
Cc: Jani Nikula <jani.nikula@...ux.intel.com>
Cc: Joonas Lahtinen <joonas.lahtinen@...ux.intel.com>
Cc: Rodrigo Vivi <rodrigo.vivi@...el.com>
Cc: Tvrtko Ursulin <tursulin@...ulin.net>
Cc: David Airlie <airlied@...il.com>
Cc: Daniel Vetter <daniel@...ll.ch>
Cc: Andi Shyti <andi.shyti@...ux.intel.com>
Cc: Lucas De Marchi <lucas.demarchi@...el.com>
Cc: Matt Atwood <matthew.s.atwood@...el.com>
Cc: Matthew Auld <matthew.auld@...el.com>
Cc: Nirmoy Das <nirmoy.das@...el.com>
Cc: Jonathan Cavitt <jonathan.cavitt@...el.com>
Cc: intel-gfx@...ts.freedesktop.org
Cc: dri-devel@...ts.freedesktop.org
---
drivers/gpu/drm/i915/gt/shmem_utils.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/drivers/gpu/drm/i915/gt/shmem_utils.c b/drivers/gpu/drm/i915/gt/shmem_utils.c
index bccc3a1200bc..dc25e6dc884b 100644
--- a/drivers/gpu/drm/i915/gt/shmem_utils.c
+++ b/drivers/gpu/drm/i915/gt/shmem_utils.c
@@ -38,8 +38,9 @@ struct file *shmem_create_from_object(struct drm_i915_gem_object *obj)
void *ptr;
if (i915_gem_object_is_shmem(obj)) {
- file = obj->base.filp;
- atomic_long_inc(&file->f_count);
+ file = get_file(obj->base.filp);
+ if (!file)
+ return ERR_PTR(-ESRCH);
return file;
}
--
2.34.1
Powered by blists - more mailing lists