From: sashiko-bot@kernel.org
To: "Christian A. Ehrhardt" <lk@c--e.de>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH] drm/panthor: Check VMA boundaries for PMD mappings
Date: Tue, 23 Jun 2026 18:52:54 +0000 [thread overview]
Message-ID: <20260623185255.38FE41F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260623181942.1536598-1-lk@c--e.de>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] VMA page offset calculation ignores VMA splits, causing the wrong GEM pages to be mapped
--
commit 0ed0c5c04749e14eb0003e5dbc760b6b5b001ce2
Author: Christian A. Ehrhardt <lk@c--e.de>
drm/panthor: Check VMA boundaries for PMD mappings
In the ->huge_fault handler do not install a PMD huge page mapping if the
huge page exceeds the boundaries of the VMA.
Link: https://lore.kernel.org/lkml/20260622215718.1532689-1-lk@c--e.de/
Link: https://sashiko.dev/#/patchset/20260622215718.1532689-1-lk%40c--e.de
> diff --git a/drivers/gpu/drm/panthor/panthor_gem.c b/drivers/gpu/drm/panthor/panthor_gem.c
> index a1e2eb1ca7bbe..54535bae2b0cf 100644
> --- a/drivers/gpu/drm/panthor/panthor_gem.c
> +++ b/drivers/gpu/drm/panthor/panthor_gem.c
> @@ -802,9 +802,13 @@ static vm_fault_t insert_page(struct vm_fault *vmf, unsigned int order, struct p
> } else if (order == PMD_ORDER) {
> unsigned long pfn = page_to_pfn(page);
> unsigned long paddr = pfn << PAGE_SHIFT;
> + struct vm_area_struct *vma = vmf->vma;
> + unsigned long start = ALIGN_DOWN(vmf->address, PMD_SIZE);
> + unsigned long end = start + PMD_SIZE;
> + bool in_range = vma->vm_start <= start && end <= vma->vm_end;
> bool aligned = (vmf->address & ~PMD_MASK) == (paddr & ~PMD_MASK);
>
> - if (aligned &&
> + if (aligned && in_range &&
> folio_test_pmd_mappable(page_folio(page))) {
> pfn &= PMD_MASK >> PAGE_SHIFT;
> return vmf_insert_pfn_pmd(vmf, pfn, vmf->flags & FAULT_FLAG_WRITE);
[Severity: High]
This isn't a bug introduced by this patch, but looking further down in
panthor_gem_any_fault():
drivers/gpu/drm/panthor/panthor_gem.c:panthor_gem_any_fault() {
...
/* Offset to faulty address in the VMA. */
page_offset = vmf->pgoff - vma->vm_pgoff;
...
}
Does this VMA page offset calculation ignore VMA splits?
If a userspace process maps a Panthor GEM object and then unmaps the first
page using munmap(), the core memory management subsystem splits the VMA and
increments vma->vm_pgoff by 1.
When a page fault subsequently occurs at the new VMA start address, both
vmf->pgoff and vma->vm_pgoff have advanced by 1, which means page_offset
incorrectly evaluates to 0 instead of 1.
Could this logic error cause the fault handler to map incorrect physical
pages (bo->backing.pages[0] instead of bo->backing.pages[1]) from the GEM
object into userspace memory?
The calculation should probably subtract the GEM object's base fake offset
using drm_vma_node_start(&bo->base.vma_node).
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260623181942.1536598-1-lk@c--e.de?part=1
prev parent reply other threads:[~2026-06-23 18:52 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-23 18:19 [PATCH] drm/panthor: Check VMA boundaries for PMD mappings Christian A. Ehrhardt
2026-06-23 18:33 ` Matthew Wilcox
2026-06-23 20:03 ` Boris Brezillon
2026-06-23 20:44 ` Boris Brezillon
2026-06-23 18:52 ` sashiko-bot [this message]
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=20260623185255.38FE41F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=lk@c--e.de \
--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.