Skip to content

Commit f0880e9

Browse files
matt-auldmehmetb0
authored andcommitted
drm/xe: prevent potential UAF in pf_provision_vf_ggtt()
BugLink: https://bugs.launchpad.net/bugs/2106652 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]> (cherry picked from commit 83dcf23) Signed-off-by: Thibault Ferrante <[email protected]> Acked-by: Massimiliano Pellizzer <[email protected]> Acked-by: Kuba Pawlak <[email protected]> Signed-off-by: Mehmet Basaran <[email protected]>
1 parent fe50b7c commit f0880e9

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
@@ -390,7 +390,7 @@ static void pf_release_vf_config_ggtt(struct xe_gt *gt, struct xe_gt_sriov_confi
390390
static int pf_provision_vf_ggtt(struct xe_gt *gt, unsigned int vfid, u64 size)
391391
{
392392
struct xe_gt_sriov_config *config = pf_pick_vf_config(gt, vfid);
393-
struct xe_ggtt_node *node = config->ggtt_region;
393+
struct xe_ggtt_node *node;
394394
struct xe_tile *tile = gt_to_tile(gt);
395395
struct xe_ggtt *ggtt = tile->mem.ggtt;
396396
u64 alignment = pf_get_ggtt_alignment(gt);
@@ -402,14 +402,14 @@ static int pf_provision_vf_ggtt(struct xe_gt *gt, unsigned int vfid, u64 size)
402402

403403
size = round_up(size, alignment);
404404

405-
if (xe_ggtt_node_allocated(node)) {
405+
if (xe_ggtt_node_allocated(config->ggtt_region)) {
406406
err = pf_distribute_config_ggtt(tile, vfid, 0, 0);
407407
if (unlikely(err))
408408
return err;
409409

410-
pf_release_ggtt(tile, node);
410+
pf_release_vf_config_ggtt(gt, config);
411411
}
412-
xe_gt_assert(gt, !xe_ggtt_node_allocated(node));
412+
xe_gt_assert(gt, !xe_ggtt_node_allocated(config->ggtt_region));
413413

414414
if (!size)
415415
return 0;

0 commit comments

Comments
 (0)