All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Matthew Brost" <matthew.brost@intel.com>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH] drm/pagemap: Clear driver-provided PFNs from migration PFN array
Date: Tue, 21 Jul 2026 20:32:31 +0000	[thread overview]
Message-ID: <20260721203232.5341B1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260721201959.1082266-1-matthew.brost@intel.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Pre-existing issues:
- [High] If `ops->populate_devmem_pfn()` fails, `migrate.dst` is not cleared of unencoded driver PFNs, leading to wild pointer dereferences and memory corruption in `migrate_vma_pages()`.
--

--- Patch [1]: [PATCH] drm/pagemap: Clear driver-provided PFNs from migration PFN array ---
commit ed7304923def6f0807fcb47377684c7a1ab58012
Author: Matthew Brost <matthew.brost@intel.com>

drm/pagemap: Clear driver-provided PFNs from migration PFN array

This patch clears remaining driver-provided PFNs from the migration PFN
array when an error occurs during the incremental copy phase. This prevents
migrate_vma_*() functions from processing unencoded device PFNs.

Reported-by: Sashiko <sashiko-bot@kernel.org>
Fixes: 3902846af36b ("drm/pagemap Fix error paths in drm_pagemap_migrate_to_devmem")
Fixes: ec265e1f1cfc ("drm/pagemap: Support source migration over interconnect")
Cc: stable@vger.kernel.org
Signed-off-by: Matthew Brost <matthew.brost@intel.com>

> diff --git a/drivers/gpu/drm/drm_pagemap.c b/drivers/gpu/drm/drm_pagemap.c
> index 15c78eca180b7..f991b296c8e19 100644
> --- a/drivers/gpu/drm/drm_pagemap.c
> +++ b/drivers/gpu/drm/drm_pagemap.c
> @@ -807,8 +807,11 @@ int drm_pagemap_migrate_to_devmem(struct drm_pagemap_devmem *devmem_allocation,
>  		msecs_to_jiffies(mdetails->timeslice_ms);
>  
>  err_finalize:
> -	if (err)
> +	if (err) {
>  		drm_pagemap_migration_unlock_put_pages(npages, migrate.dst);
> +		for (i = npages; i < npages_in_range(start, end); ++i)
> +			migrate.dst[i] = 0;
> +	}
>  err_aborted_migration:
>  	migrate_vma_pages(&migrate);

[Severity: High]
This is a pre-existing issue, but I noticed an error path that might still
bypass this new zeroing loop.

Earlier in drm_pagemap_migrate_to_devmem(), if ops->populate_devmem_pfn()
fails, the code jumps directly to err_aborted_migration:

	err = ops->populate_devmem_pfn(devmem_allocation, npages, migrate.dst);
	if (err)
		goto err_aborted_migration;

Since this jumps directly to err_aborted_migration, it skips the err_finalize
block completely. If migrate.dst was partially populated with unencoded driver
PFNs before the failure, wouldn't migrate_vma_pages() then process those
raw PFNs?

If a raw driver-provided PFN happens to have its lowest bit set,
migrate_pfn_to_page() could interpret it as MIGRATE_PFN_VALID and return a
bogus struct page pointer, which might lead to memory corruption.

Should the populate_devmem_pfn() failure jump to err_finalize instead, or
should the array clearing be moved to cover all abort paths?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260721201959.1082266-1-matthew.brost@intel.com?part=1

  reply	other threads:[~2026-07-21 20:32 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-21 20:19 [PATCH] drm/pagemap: Clear driver-provided PFNs from migration PFN array Matthew Brost
2026-07-21 20:32 ` sashiko-bot [this message]
2026-07-21 20:37 ` ✗ CI.checkpatch: warning for " Patchwork
2026-07-21 20:38 ` ✓ CI.KUnit: success " Patchwork
2026-07-21 21:39 ` ✓ Xe.CI.BAT: " 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=20260721203232.5341B1F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=matthew.brost@intel.com \
    --cc=sashiko-reviews@lists.linux.dev \
    /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.