Linux-mm Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Ren Wei <weir@nebusec.ai>
To: linux-mm@kvack.org
Cc: akpm@linux-foundation.org, david@kernel.org, ljs@kernel.org,
	liam@infradead.org, vbabka@kernel.org, rppt@kernel.org,
	surenb@google.com, mhocko@suse.com, notasas@gmail.com,
	vega@nebusec.ai, rakukuip@gmail.com, weir@nebusec.ai
Subject: [PATCH v2 0/1] mm/memory: constrain generic_access_phys() to page boundary
Date: Sat,  5 Sep 2026 22:12:16 +0800	[thread overview]
Message-ID: <cover.1788531737.git.rakukuip@gmail.com> (raw)

From: Luxiao Xu <rakukuip@gmail.com>

Hi all,

This is v2 of the fix for generic_access_phys() out-of-bounds mapping.

In v1, we attempted to handle multi-page ranges by adding an internal
chunk loop inside generic_access_phys(). Following feedback from David
Hildenbrand, we realized that caller (__access_remote_vm) already has an
outer loop and handles normal pages chunk-by-chunk.

Instead of duplicating the loop logic in generic_access_phys(), v2
clamps the access length passed to ->access() in __access_remote_vm() to
not cross the page boundary (PAGE_SIZE - offset_in_page(addr)). Because
all VMAs are page-aligned, this also naturally ensures accesses never
cross VMA boundaries. Each page access is then driven by the outer loop,
looking up the VMA and resolving PFN/protections per page.

Additionally, we fixed the missing (resource_size_t) cast in PFN
comparison as pointed out by Andrew Morton.

Thanks,
Luxiao / Ren Wei

Luxiao Xu (1):
  mm/memory: constrain generic_access_phys() to page boundary

 mm/memory.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

-- 
2.43.0



             reply	other threads:[~2026-09-05 14:12 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-05 14:12 Ren Wei [this message]
2026-09-05 14:12 ` [PATCH v2 1/1] mm/memory: constrain generic_access_phys() to page boundary Ren Wei
2026-09-05 23:03   ` Andrew Morton
2026-09-07 12:08   ` David Hildenbrand (Arm)

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=cover.1788531737.git.rakukuip@gmail.com \
    --to=weir@nebusec.ai \
    --cc=akpm@linux-foundation.org \
    --cc=david@kernel.org \
    --cc=liam@infradead.org \
    --cc=linux-mm@kvack.org \
    --cc=ljs@kernel.org \
    --cc=mhocko@suse.com \
    --cc=notasas@gmail.com \
    --cc=rakukuip@gmail.com \
    --cc=rppt@kernel.org \
    --cc=surenb@google.com \
    --cc=vbabka@kernel.org \
    --cc=vega@nebusec.ai \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox