From: sashiko-bot@kernel.org
To: "Jan Stancek" <jstancek@redhat.com>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH] drm/pagemap: Guard HPAGE_PMD_ORDER use with CONFIG_ARCH_ENABLE_THP_MIGRATION
Date: Tue, 21 Jul 2026 10:56:45 +0000 [thread overview]
Message-ID: <20260721105646.6C9541F000E9@smtp.kernel.org> (raw)
In-Reply-To: <84a35e16f72330d6e7b2d6e969040f36959e2dad.1784630290.git.jstancek@redhat.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [Critical] Aborting a migration mid-loop leaves raw device PFNs in the migration array, causing a bogus pointer dereference and kernel panic in migrate_vma_pages().
--
--- Patch [1]: [PATCH] drm/pagemap: Guard HPAGE_PMD_ORDER use with CONFIG_ARCH_ENABLE_THP_MIGRATION ---
commit 66a306e51148532e3b7d883d3232632355c05797
Author: Jan Stancek <jstancek@redhat.com>
drm/pagemap: Guard HPAGE_PMD_ORDER use with CONFIG_ARCH_ENABLE_THP_MIGRATION
This commit fixes a compile error when both CONFIG_TRANSPARENT_HUGEPAGE
and CONFIG_HUGETLB_PAGE are disabled. It guards HPAGE_PMD_ORDER uses with
CONFIG_ARCH_ENABLE_THP_MIGRATION.
Link: https://lore.kernel.org/r/202607201914.LpAGsbXs-lkp@intel.com/
> diff --git a/drivers/gpu/drm/drm_pagemap.c b/drivers/gpu/drm/drm_pagemap.c
> index 15c78eca180b7..53a78752c8be3 100644
> --- a/drivers/gpu/drm/drm_pagemap.c
> +++ b/drivers/gpu/drm/drm_pagemap.c
[ ... ]
> @@ -763,7 +765,10 @@ int drm_pagemap_migrate_to_devmem(struct drm_pagemap_devmem *devmem_allocation,
> }
> migrate.dst[i] = migrate_pfn(migrate.dst[i]);
>
> +#ifdef CONFIG_ARCH_ENABLE_THP_MIGRATION
> if (migrate.src[i] & MIGRATE_PFN_COMPOUND) {
> + unsigned long j;
> +
> drm_WARN_ONCE(dpagemap->drm, src_page &&
> folio_order(page_folio(src_page)) != HPAGE_PMD_ORDER,
> "Unexpected folio order\n");
> @@ -774,6 +779,7 @@ int drm_pagemap_migrate_to_devmem(struct drm_pagemap_devmem *devmem_allocation,
> for (j = 1; j < NR_PAGES(order) && i + j < npages; j++)
> migrate.dst[i + j] = 0;
> }
> +#endif
>
> drm_pagemap_get_devmem_page(page, order, zdd);
[Severity: Critical]
This is a pre-existing issue, but can the error path here leave raw device
PFNs in the migration array, causing a bogus pointer dereference in
migrate_vma_pages()?
In drm_pagemap_migrate_to_devmem(), ops->populate_devmem_pfn() populates
migrate.dst with sequential raw device PFNs. The loop processes these and
converts them into the migrate_pfn() format. If a migration batch fails
mid-loop:
err = drm_pagemap_migrate_range(...);
if (err) {
npages = i + 1;
goto err_finalize;
}
The error path zeros out migrate.dst entries up to index i, and then
falls through to err_aborted_migration:
err_finalize:
if (err)
drm_pagemap_migration_unlock_put_pages(npages, migrate.dst);
err_aborted_migration:
migrate_vma_pages(&migrate);
Because migrate_vma_pages() iterates up to the original migrate.npages,
unprocessed entries (where index > i) still contain unformatted raw PFNs.
Since PFNs are sequential, half of them are odd numbers, meaning bit 0
(MIGRATE_PFN_VALID) is set.
Will __migrate_device_pages() misinterpret these odd raw PFNs as valid
migration entries, leading to a dereference of a completely bogus
struct page pointer when it calls pfn_to_page()?
--
Sashiko AI review · https://sashiko.dev/#/patchset/84a35e16f72330d6e7b2d6e969040f36959e2dad.1784630290.git.jstancek@redhat.com?part=1
next prev parent reply other threads:[~2026-07-21 10:56 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-20 11:36 drivers/gpu/drm/drm_pagemap.c:480:12: error: call to '__compiletime_assert_458' declared with 'error' attribute: BUILD_BUG failed kernel test robot
2026-07-21 10:40 ` [PATCH] drm/pagemap: Guard HPAGE_PMD_ORDER use with CONFIG_ARCH_ENABLE_THP_MIGRATION Jan Stancek
2026-07-21 10:56 ` sashiko-bot [this message]
2026-07-21 19:12 ` Matthew Brost
2026-07-21 19:15 ` Matthew Brost
2026-07-21 19:35 ` Jan Stancek
-- strict thread matches above, loose matches on Subject: below --
2026-07-21 22:32 Matthew Brost
2026-07-22 5:21 ` Jan Stancek
2026-07-22 5:32 ` Ghimiray, Himal Prasad
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=20260721105646.6C9541F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=jstancek@redhat.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.