From: Nirmoy Das <nirmoy.das@linux.intel.com>
To: Matthew Auld <matthew.auld@intel.com>, intel-xe@lists.freedesktop.org
Cc: Matthew Brost <matthew.brost@intel.com>
Subject: Re: [PATCH v2 2/2] drm/xe/queue: move xa_alloc to prevent UAF
Date: Wed, 25 Sep 2024 13:50:02 +0200 [thread overview]
Message-ID: <33ac357b-4ac9-4d2f-937c-0f136dc7b0a8@linux.intel.com> (raw)
In-Reply-To: <8d83962f-abff-455e-a14e-d3bf7c5a9cbf@intel.com>
On 9/25/2024 1:24 PM, Matthew Auld wrote:
> On 25/09/2024 11:44, Nirmoy Das wrote:
>>
>> On 9/25/2024 11:51 AM, Matthew Auld wrote:
>>> On 25/09/2024 10:33, Nirmoy Das wrote:
>>>>
>>>> On 9/25/2024 9:14 AM, 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.
>>>>
>>>> The commit message doesn't match the diff, xa_alloc already happening at the end here.
>>>
>>> It's not at the end. It is dereferencing the q to set xef after the xa_alloc, but that needs to happen before it is visible to userspace.
>>
>>
>> Ah I see, that make sense.
>>
>> I think now we have to undo xe_file_get() if xe_alloc fails.
>
> That is already handled by the queue put().
Ok, that took some digging. Thanks for clearing my doubts.
Reviewed-by: Nirmoy Das <nirmoy.das@intel.com>
>
>>
>>
>> Regards,
>>
>> Nirmoy
>>
>>>
>>>>
>>>>> v2:
>>>>> - Rebase
>>>>>
>>>>> 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 7743ebdcbf4b..d098d2dd1b2d 100644
>>>>> --- a/drivers/gpu/drm/xe/xe_exec_queue.c
>>>>> +++ b/drivers/gpu/drm/xe/xe_exec_queue.c
>>>>> @@ -635,12 +635,14 @@ int xe_exec_queue_create_ioctl(struct drm_device *dev, void *data,
>>>>> }
>>>>> }
>>>>> + q->xef = xe_file_get(xef);
>>>>> +
>>>>> + /* user id alloc must always be last in ioctl to prevent UAF */
>>>>> err = xa_alloc(&xef->exec_queue.xa, &id, q, xa_limit_32b, GFP_KERNEL);
>>>>> if (err)
>>>>> goto kill_exec_queue;
>>>>> args->exec_queue_id = id;
>>>>> - q->xef = xe_file_get(xef);
>>>>> return 0;
>>>>>
next prev parent reply other threads:[~2024-09-25 11:53 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-25 7:14 [PATCH v2 1/2] drm/xe/vm: move xa_alloc to prevent UAF Matthew Auld
2024-09-25 7:14 ` [PATCH v2 2/2] drm/xe/queue: " Matthew Auld
2024-09-25 9:33 ` Nirmoy Das
2024-09-25 9:51 ` Matthew Auld
2024-09-25 10:44 ` Nirmoy Das
2024-09-25 11:24 ` Matthew Auld
2024-09-25 11:50 ` Nirmoy Das [this message]
2024-09-25 16:34 ` Matthew Brost
2024-09-25 9:24 ` [PATCH v2 1/2] drm/xe/vm: " Nirmoy Das
2024-09-25 16:33 ` Matthew Brost
2024-09-26 9:14 ` ✓ CI.Patch_applied: success for series starting with [v2,1/2] " Patchwork
2024-09-26 9:14 ` ✓ CI.checkpatch: " Patchwork
2024-09-26 9:15 ` ✓ CI.KUnit: " Patchwork
2024-09-26 9:27 ` ✓ CI.Build: " Patchwork
2024-09-26 9:29 ` ✓ CI.Hooks: " Patchwork
2024-09-26 9:30 ` ✓ CI.checksparse: " Patchwork
2024-09-26 10:00 ` ✓ CI.BAT: " Patchwork
2024-09-27 1:40 ` ✗ CI.FULL: failure " 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=33ac357b-4ac9-4d2f-937c-0f136dc7b0a8@linux.intel.com \
--to=nirmoy.das@linux.intel.com \
--cc=intel-xe@lists.freedesktop.org \
--cc=matthew.auld@intel.com \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.