Skip to content

Commit 83dcf23

Browse files
matt-auldlucasdemarchi
authored andcommitted
drm/xe: prevent potential UAF in pf_provision_vf_ggtt()
The node ptr can point to an already freed ptr, if we hit the path with an already allocated node. We later dereference that pointer with: xe_gt_assert(gt, !xe_ggtt_node_allocated(node)); which is a potential UAF. Fix this by not stashing the ptr for node. Also since it is likely a bad idea to leave config->ggtt_region pointing to a stale ptr, also set that to NULL by calling pf_release_vf_config_ggtt() instead of pf_release_ggtt(). Fixes: 34e8042 ("drm/xe: Make xe_ggtt_node struct independent") Signed-off-by: Matthew Auld <[email protected]> Cc: Matthew Brost <[email protected]> Cc: Rodrigo Vivi <[email protected]> Reviewed-by: Rodrigo Vivi <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected] (cherry picked from commit 89076b5) Signed-off-by: Lucas De Marchi <[email protected]>
1 parent b615b9c commit 83dcf23

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

drivers/gpu/drm/xe/xe_gt_sriov_pf_config.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,7 @@ static void pf_release_vf_config_ggtt(struct xe_gt *gt, struct xe_gt_sriov_confi
399399
static int pf_provision_vf_ggtt(struct xe_gt *gt, unsigned int vfid, u64 size)
400400
{
401401
struct xe_gt_sriov_config *config = pf_pick_vf_config(gt, vfid);
402-
struct xe_ggtt_node *node = config->ggtt_region;
402+
struct xe_ggtt_node *node;
403403
struct xe_tile *tile = gt_to_tile(gt);
404404
struct xe_ggtt *ggtt = tile->mem.ggtt;
405405
u64 alignment = pf_get_ggtt_alignment(gt);
@@ -411,14 +411,14 @@ static int pf_provision_vf_ggtt(struct xe_gt *gt, unsigned int vfid, u64 size)
411411

412412
size = round_up(size, alignment);
413413

414-
if (xe_ggtt_node_allocated(node)) {
414+
if (xe_ggtt_node_allocated(config->ggtt_region)) {
415415
err = pf_distribute_config_ggtt(tile, vfid, 0, 0);
416416
if (unlikely(err))
417417
return err;
418418

419-
pf_release_ggtt(tile, node);
419+
pf_release_vf_config_ggtt(gt, config);
420420
}
421-
xe_gt_assert(gt, !xe_ggtt_node_allocated(node));
421+
xe_gt_assert(gt, !xe_ggtt_node_allocated(config->ggtt_region));
422422

423423
if (!size)
424424
return 0;

0 commit comments

Comments
 (0)