From: "David Hildenbrand (Arm)" <david@kernel.org>
To: Ren Wei <enjou1224z@gmail.com>, linux-mm@kvack.org
Cc: akpm@linux-foundation.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
Subject: Re: [PATCH 1/1] mm: fix out-of-bounds access and race in generic_access_phys
Date: Tue, 21 Jul 2026 16:49:59 +0200 [thread overview]
Message-ID: <25e3e218-cb74-4d7d-9301-24b583f4323f@kernel.org> (raw)
In-Reply-To: <f618e2f57ad0086a8d7a95cb17dcf5a1f0cf0e45.1784428532.git.rakukuip@gmail.com>
On 7/21/26 16:26, Ren Wei wrote:
> From: Luxiao Xu <rakukuip@gmail.com>
>
> generic_access_phys() improperly validates the memory access range. It
> only validates the start address using follow_pfnmap_start() and then
> uses ioremap_prot() to map the entire requested length. This fails to
> verify if the access range stays within the VMA boundaries or if it
> crosses into adjacent physical/MMIO mappings, allowing out-of-bounds
> read or write access.
>
> Furthermore, the previous implementation failed to handle partial
> progress semantics required by __access_remote_vm() and lacked
> necessary concurrency checks (retry logic) to prevent the use of
> stale mappings after releasing the PFNMAP lock.
>
> Fix this by:
> - Processing memory access in page-sized chunks, ensuring every page
> is validated within its VMA boundaries.
> - Introducing a retry mechanism to re-validate the PFN/protection
> after mapping, ensuring safety against concurrent page table
> modifications.
> - Returning the total number of bytes successfully copied to satisfy
> the partial progress semantics of the access_process_vm
> infrastructure.
>
> Fixes: 9cb12d7b4cca ("mm/memory.c: actually remap enough memory")
> Cc: stable@vger.kernel.org
> Reported-by: Vega <vega@nebusec.ai>
> Assisted-by: Codex:gpt-5.4
> Signed-off-by: Luxiao Xu <rakukuip@gmail.com>
> Signed-off-by: Ren Wei <enjou1224z@gmail.com>
Hm, I wonder if it's responsibility of the callers to make sure that [addr,
addr+len) is actually within VMA bounds. Just like it's the callers
responsibility to ensure that "addr" falls within the VMA.
That makes the ->access() implementation harder to get wrong.
--
Cheers,
David
next prev parent reply other threads:[~2026-07-21 14:50 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-21 14:26 [PATCH 0/1] mm: fix out-of-bounds access in generic_access_phys Ren Wei
2026-07-21 14:26 ` [PATCH 1/1] mm: fix out-of-bounds access and race " Ren Wei
2026-07-21 14:49 ` David Hildenbrand (Arm) [this message]
2026-07-21 21:12 ` Andrew Morton
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=25e3e218-cb74-4d7d-9301-24b583f4323f@kernel.org \
--to=david@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=enjou1224z@gmail.com \
--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