From: Rodrigo Vivi <rodrigo.vivi@intel.com>
To: Matthew Auld <matthew.auld@intel.com>
Cc: <intel-xe@lists.freedesktop.org>,
Matthew Brost <matthew.brost@intel.com>
Subject: Re: [PATCH] drm/xe: prevent potential UAF in pf_provision_vf_ggtt()
Date: Wed, 28 Aug 2024 14:23:31 -0400 [thread overview]
Message-ID: <Zs9rI2MIMezCDtA0@intel.com> (raw)
In-Reply-To: <20240828104341.180111-2-matthew.auld@intel.com>
On Wed, Aug 28, 2024 at 11:43:42AM +0100, Matthew Auld wrote:
> 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.
Not true because xe_ggtt_node_allocated is checking for that.
But probably after this patch we could remove the check there?!
> 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().
This is a very good idea.
I wonder if this should be a separate patch, or another commit message,
but the end result is cleaner code, so no reason to block:
Reviewed-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
>
> Fixes: 34e804220f69 ("drm/xe: Make xe_ggtt_node struct independent")
> Signed-off-by: Matthew Auld <matthew.auld@intel.com>
> Cc: Matthew Brost <matthew.brost@intel.com>
> Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>
> ---
> drivers/gpu/drm/xe/xe_gt_sriov_pf_config.c | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/gpu/drm/xe/xe_gt_sriov_pf_config.c b/drivers/gpu/drm/xe/xe_gt_sriov_pf_config.c
> index 41ed07b153b5..be198a426cdc 100644
> --- a/drivers/gpu/drm/xe/xe_gt_sriov_pf_config.c
> +++ b/drivers/gpu/drm/xe/xe_gt_sriov_pf_config.c
> @@ -390,7 +390,7 @@ static void pf_release_vf_config_ggtt(struct xe_gt *gt, struct xe_gt_sriov_confi
> static int pf_provision_vf_ggtt(struct xe_gt *gt, unsigned int vfid, u64 size)
> {
> struct xe_gt_sriov_config *config = pf_pick_vf_config(gt, vfid);
> - struct xe_ggtt_node *node = config->ggtt_region;
> + struct xe_ggtt_node *node;
> struct xe_tile *tile = gt_to_tile(gt);
> struct xe_ggtt *ggtt = tile->mem.ggtt;
> 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)
>
> size = round_up(size, alignment);
>
> - if (xe_ggtt_node_allocated(node)) {
> + if (xe_ggtt_node_allocated(config->ggtt_region)) {
> err = pf_distribute_config_ggtt(tile, vfid, 0, 0);
> if (unlikely(err))
> return err;
>
> - pf_release_ggtt(tile, node);
> + pf_release_vf_config_ggtt(gt, config);
> }
> - xe_gt_assert(gt, !xe_ggtt_node_allocated(node));
> + xe_gt_assert(gt, !xe_ggtt_node_allocated(config->ggtt_region));
>
> if (!size)
> return 0;
> --
> 2.46.0
>
next prev parent reply other threads:[~2024-08-28 18:23 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-28 10:43 [PATCH] drm/xe: prevent potential UAF in pf_provision_vf_ggtt() Matthew Auld
2024-08-28 13:13 ` ✓ CI.Patch_applied: success for " Patchwork
2024-08-28 13:13 ` ✓ CI.checkpatch: " Patchwork
2024-08-28 13:14 ` ✓ CI.KUnit: " Patchwork
2024-08-28 13:27 ` ✓ CI.Build: " Patchwork
2024-08-28 13:32 ` ✓ CI.Hooks: " Patchwork
2024-08-28 13:33 ` ✓ CI.checksparse: " Patchwork
2024-08-28 13:52 ` ✓ CI.BAT: " Patchwork
2024-08-28 18:23 ` Rodrigo Vivi [this message]
2024-08-29 8:09 ` [PATCH] " Matthew Auld
2024-08-28 21:13 ` ✗ CI.FULL: failure for " 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=Zs9rI2MIMezCDtA0@intel.com \
--to=rodrigo.vivi@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.