From: sashiko-bot@kernel.org
To: "Umesh Nerlige Ramappa" <umesh.nerlige.ramappa@intel.com>
Cc: intel-gfx@lists.freedesktop.org
Subject: Re: [PATCH 1/2] drm/i915/perf: Enable the stream before installing its fd
Date: Tue, 08 Sep 2026 23:29:53 +0000 [thread overview]
Message-ID: <20260908232954.455E11F00A3A@smtp.kernel.org> (raw)
In-Reply-To: <20260908231511.1217426-5-umesh.nerlige.ramappa@intel.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [Critical] File descriptor exposure race leading to use-after-free on `drm_device` due to unbalanced `drm_dev_put()`.
--
commit c98885955ea0ce4ff5699cebc897dbb4dbd8246b
Author: Umesh Nerlige Ramappa <umesh.nerlige.ramappa@intel.com>
drm/i915/perf: Enable the stream before installing its fd
This commit moves the enablement of the perf stream to occur before
installing the file descriptor in userspace. This prevents a race
condition where an I915_PERF_IOCTL_DISABLE ioctl could run concurrently
with stream enablement.
> diff --git a/drivers/gpu/drm/i915/i915_perf.c b/drivers/gpu/drm/i915/i915_perf.c
> index 19b82427aa412..96823dcd3fae2 100644
> --- a/drivers/gpu/drm/i915/i915_perf.c
> +++ b/drivers/gpu/drm/i915/i915_perf.c
[ ... ]
> @@ -3900,15 +3900,25 @@ i915_perf_open_ioctl_locked(struct i915_perf *perf,
[ ... ]
> + if (!(param->flags & I915_PERF_FLAG_DISABLED))
> + i915_perf_enable_locked(stream);
> +
> stream_fd = anon_inode_getfd("[i915_perf]", &fops, stream, f_flags);
> if (stream_fd < 0) {
> ret = stream_fd;
> - goto err_flags;
> + goto err_enable;
> }
>
> - if (!(param->flags & I915_PERF_FLAG_DISABLED))
> - i915_perf_enable_locked(stream);
> -
> /* Take a reference on the driver that will be kept with stream_fd
> * until its release.
> */
[Severity: Critical]
This is a pre-existing issue, but does anon_inode_getfd() expose the file
descriptor to userspace before the drm_device reference count is acquired?
Since anon_inode_getfd() installs the file descriptor in the process's fd
table, it becomes immediately visible to userspace. A concurrent thread
could guess the fd and call close() before the original ioctl thread in
i915_perf_open_ioctl_locked() has a chance to execute the subsequent
drm_dev_get().
If close() is called concurrently, it invokes i915_perf_release(), which
unconditionally calls drm_dev_put(&perf->i915->drm). Because the original
thread has not yet called drm_dev_get(), could this prematurely decrement
the reference count?
By racing multiple I915_PERF_OPEN ioctls with concurrent close() calls,
could this drive the drm_device refcount to 0, leading to a use-after-free
when the original thread finally executes drm_dev_get()?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260908231511.1217426-4-umesh.nerlige.ramappa@intel.com?part=1
next prev parent reply other threads:[~2026-09-08 23:29 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-08 23:15 [PATCH 0/2] Minor fixes to OA in i915 Umesh Nerlige Ramappa
2026-09-08 23:15 ` [PATCH 1/2] drm/i915/perf: Enable the stream before installing its fd Umesh Nerlige Ramappa
2026-09-08 23:29 ` sashiko-bot [this message]
2026-09-08 23:15 ` [PATCH 2/2] drm/i915/perf: Remove sysfs group on OA config idr_alloc() failure Umesh Nerlige Ramappa
2026-09-08 23:26 ` sashiko-bot
2026-09-09 0:19 ` ✓ i915.CI.BAT: success for Minor fixes to OA in i915 Patchwork
2026-09-09 17:10 ` ✓ i915.CI.Full: " Patchwork
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260908232954.455E11F00A3A@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=intel-gfx@lists.freedesktop.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=umesh.nerlige.ramappa@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox