From: Matthew Auld <matthew.auld@intel.com>
To: Matthew Brost <matthew.brost@intel.com>
Cc: intel-xe@lists.freedesktop.org
Subject: Re: [PATCH 2/2] drm/xe/queue: move xa_alloc to prevent UAF
Date: Mon, 23 Sep 2024 17:09:01 +0100 [thread overview]
Message-ID: <2b406f25-3a2f-4e9c-8617-79641c9e6085@intel.com> (raw)
In-Reply-To: <ZvGR4eIX2jsl5sD4@DUT025-TGLU.fm.intel.com>
On 23/09/2024 17:05, Matthew Brost wrote:
> On Mon, Sep 23, 2024 at 01:57:35PM +0100, Matthew Auld wrote:
>> Evil user can guess the next id of the queue before the ioctl completes
>> and then call queue destroy ioctl to trigger UAF since create ioctl is
>> still referencing the same queue. Move the xa_alloc all the way to the end
>> to prevent this.
>>
>> Fixes: 2149ded63079 ("drm/xe: Fix use after free when client stats are captured")
>> Signed-off-by: Matthew Auld <matthew.auld@intel.com>
>> Cc: Matthew Brost <matthew.brost@intel.com>
>> ---
>> drivers/gpu/drm/xe/xe_exec_queue.c | 4 +++-
>> 1 file changed, 3 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/gpu/drm/xe/xe_exec_queue.c b/drivers/gpu/drm/xe/xe_exec_queue.c
>> index 7f28b7fc68d5..a1d4b9b0726e 100644
>> --- a/drivers/gpu/drm/xe/xe_exec_queue.c
>> +++ b/drivers/gpu/drm/xe/xe_exec_queue.c
>> @@ -635,6 +635,9 @@ int xe_exec_queue_create_ioctl(struct drm_device *dev, void *data,
>> }
>> }
>>
>> + q->xef = xe_file_get(xef);
>
> Same comment as last patch, this looks coreect shall I merge my series
> and then you rebase?
Yeah, sounds fine.
>
> Matt
>
>> +
>> + /* user id alloc must always be last in ioctl to prevent UAF */
>> mutex_lock(&xef->exec_queue.lock);
>> err = xa_alloc(&xef->exec_queue.xa, &id, q, xa_limit_32b, GFP_KERNEL);
>> mutex_unlock(&xef->exec_queue.lock);
>> @@ -642,7 +645,6 @@ int xe_exec_queue_create_ioctl(struct drm_device *dev, void *data,
>> goto kill_exec_queue;
>>
>> args->exec_queue_id = id;
>> - q->xef = xe_file_get(xef);
>>
>> return 0;
>>
>> --
>> 2.46.1
>>
next prev parent reply other threads:[~2024-09-23 16:10 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-23 12:57 [PATCH 1/2] drm/xe/vm: move xa_alloc to prevent UAF Matthew Auld
2024-09-23 12:57 ` [PATCH 2/2] drm/xe/queue: " Matthew Auld
2024-09-23 16:05 ` Matthew Brost
2024-09-23 16:09 ` Matthew Auld [this message]
2024-09-24 16:05 ` Matthew Brost
2024-09-23 16:02 ` [PATCH 1/2] drm/xe/vm: " Matthew Brost
2024-09-25 20:09 ` ✗ CI.Patch_applied: failure for series starting with [1/2] " 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=2b406f25-3a2f-4e9c-8617-79641c9e6085@intel.com \
--to=matthew.auld@intel.com \
--cc=intel-xe@lists.freedesktop.org \
--cc=matthew.brost@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