From: Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com>
To: Min Li <lm0963hack@gmail.com>,
jani.nikula@linux.intel.com,
Umesh Nerlige Ramappa <umesh.nerlige.ramappa@intel.com>,
Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Cc: intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org,
dri-devel@lists.freedesktop.org, daniel@ffwll.ch,
rodrigo.vivi@intel.com, airlied@gmail.com
Subject: Re: [Intel-gfx] [PATCH 1/1] drm/i915: fix race condition UAF in i915_perf_add_config_ioctl
Date: Tue, 28 Mar 2023 14:08:47 +0100 [thread overview]
Message-ID: <e7541f73-f100-3b1f-de80-376fa55f2479@linux.intel.com> (raw)
In-Reply-To: <20230328093627.5067-1-lm0963hack@gmail.com>
On 28/03/2023 10:36, Min Li wrote:
> Userspace can guess the id value and try to race oa_config object creation
> with config remove, resulting in a use-after-free if we dereference the
> object after unlocking the metrics_lock. For that reason, unlocking the
> metrics_lock must be done after we are done dereferencing the object.
>
> Signed-off-by: Min Li <lm0963hack@gmail.com>
Fixes: f89823c21224 ("drm/i915/perf: Implement I915_PERF_ADD/REMOVE_CONFIG interface")
Cc: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Cc: Umesh Nerlige Ramappa <umesh.nerlige.ramappa@intel.com>
Cc: <stable@vger.kernel.org> # v4.14+
> ---
> drivers/gpu/drm/i915/i915_perf.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/i915_perf.c b/drivers/gpu/drm/i915/i915_perf.c
> index 824a34ec0b83..93748ca2c5da 100644
> --- a/drivers/gpu/drm/i915/i915_perf.c
> +++ b/drivers/gpu/drm/i915/i915_perf.c
> @@ -4634,13 +4634,13 @@ int i915_perf_add_config_ioctl(struct drm_device *dev, void *data,
> err = oa_config->id;
> goto sysfs_err;
> }
> -
> - mutex_unlock(&perf->metrics_lock);
> + id = oa_config->id;
>
> drm_dbg(&perf->i915->drm,
> "Added config %s id=%i\n", oa_config->uuid, oa_config->id);
> + mutex_unlock(&perf->metrics_lock);
>
> - return oa_config->id;
> + return id;
>
> sysfs_err:
> mutex_unlock(&perf->metrics_lock);
LGTM.
Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Umesh or Lionel could you please double check? I can merge if confirmed okay.
Regards,
Tvrtko
next prev parent reply other threads:[~2023-03-28 13:09 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-28 9:36 [Intel-gfx] [PATCH 1/1] drm/i915: fix race condition UAF in i915_perf_add_config_ioctl Min Li
2023-03-28 13:08 ` Tvrtko Ursulin [this message]
2023-03-29 0:48 ` Umesh Nerlige Ramappa
2023-03-29 9:20 ` Tvrtko Ursulin
2023-03-28 20:57 ` Andi Shyti
2023-03-28 21:08 ` Andi Shyti
2023-03-28 23:17 ` [Intel-gfx] ✓ Fi.CI.BAT: success for series starting with [1/1] " Patchwork
2023-03-29 12:47 ` [Intel-gfx] ✓ Fi.CI.IGT: " 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=e7541f73-f100-3b1f-de80-376fa55f2479@linux.intel.com \
--to=tvrtko.ursulin@linux.intel.com \
--cc=airlied@gmail.com \
--cc=daniel@ffwll.ch \
--cc=dri-devel@lists.freedesktop.org \
--cc=intel-gfx@lists.freedesktop.org \
--cc=jani.nikula@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=lionel.g.landwerlin@intel.com \
--cc=lm0963hack@gmail.com \
--cc=rodrigo.vivi@intel.com \
--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