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 v3 0/1] mm/memory: constrain generic_access_phys() to page boundary
Date: Thu, 10 Sep 2026 11:42:49 +0800 [thread overview]
Message-ID: <cover.1788842306.git.rakukuip@gmail.com> (raw)
From: Luxiao Xu <rakukuip@gmail.com>
Hi all,
This patch addresses an issue in generic_access_phys() where accessing memory
across page boundaries in PFNMAP VMAs assumes physical pages are contiguous,
which can lead to accessing unintended physical memory or exceeding VMA boundaries.
In v3, we address review feedback from David Hildenbrand on v2:
1. Revert changes to __access_remote_vm(): Capping the access length to
(PAGE_SIZE - offset) inside generic_access_phys() is completely sufficient,
as __access_remote_vm() already loops over the requested length and handles
short transfers.
2. Drop the redundant 'len <= 0' check.
3. Add an explanatory comment clarifying that accesses are limited to one page
at a time because follow_pfnmap_start() only validates a single PTE.
4. Regarding min() vs min_t(): min_t(int, ...) is retained because len is a
signed int while PAGE_SIZE is unsigned long ((1UL) << PAGE_SHIFT), which
triggers a compile-time "signedness error" if plain min() is used.
Thanks for the reviews and guidance.
v2 -> v3:
- Drop modification to __access_remote_vm(); capping in generic_access_phys()
is sufficient because the caller loop already handles partial transfers
(David Hildenbrand).
- Drop unnecessary 'len <= 0' check.
- Add comment explaining the single-page limitation (David Hildenbrand).
- v2 Link: https://lore.kernel.org/all/cover.1788531737.git.rakukuip@gmail.com/
v1 -> v2:
- Drop internal multi-page loop in generic_access_phys(); clamp the chunk
size leveraging the existing caller loop (David Hildenbrand).
- Map only PAGE_SIZE in generic_access_phys().
- Add missing (resource_size_t) cast when checking args.pfn (Andrew Morton).
Luxiao Xu (1):
mm/memory: constrain generic_access_phys() to page boundary
mm/memory.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
--
2.43.0
next reply other threads:[~2026-09-10 3:43 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-10 3:42 Ren Wei [this message]
2026-09-10 3:42 ` [PATCH v3 1/1] mm/memory: constrain generic_access_phys() to page boundary Ren Wei
2026-09-10 6:18 ` Andrew Morton
2026-09-10 8:16 ` 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.1788842306.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 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.