[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CAGsJ_4whENJnq+XBu9VnRWMTh9HouQdULO5u1G=+d3JVmdRpeA@mail.gmail.com>
Date: Sat, 28 Jun 2025 10:42:49 +1200
From: Barry Song <21cnbao@...il.com>
To: Lance Yang <lance.yang@...ux.dev>
Cc: David Hildenbrand <david@...hat.com>, akpm@...ux-foundation.org,
baolin.wang@...ux.alibaba.com, chrisl@...nel.org, kasong@...cent.com,
linux-arm-kernel@...ts.infradead.org, linux-kernel@...r.kernel.org,
linux-mm@...ck.org, linux-riscv@...ts.infradead.org,
lorenzo.stoakes@...cle.com, ryan.roberts@....com, v-songbaohua@...o.com,
x86@...nel.org, huang.ying.caritas@...il.com, zhengtangquan@...o.com,
riel@...riel.com, Liam.Howlett@...cle.com, vbabka@...e.cz,
harry.yoo@...cle.com, mingzhe.yang@...com, stable@...r.kernel.org,
Lance Yang <ioworker0@...il.com>
Subject: Re: [PATCH v2 1/1] mm/rmap: fix potential out-of-bounds page table
access during batched unmap
On Sat, Jun 28, 2025 at 3:29 AM Lance Yang <lance.yang@...ux.dev> wrote:
[...]
>
> Based on that, I think we're on the same page now. I'd like to post
> the following commit message for the next version:
>
> ```
> As pointed out by David[1], the batched unmap logic in try_to_unmap_one()
> may read past the end of a PTE table when a large folio's PTE mappings
> are not fully contained within a single page table.
>
> While this scenario might be rare, an issue triggerable from userspace must
> be fixed regardless of its likelihood. This patch fixes the out-of-bounds
> access by refactoring the logic into a new helper, folio_unmap_pte_batch().
>
> The new helper correctly calculates the safe batch size by capping the
> scan at both the VMA and PMD boundaries. To simplify the code, it also
> supports partial batching (i.e., any number of pages from 1 up to the
> calculated safe maximum), as there is no strong reason to special-case
> for fully mapped folios.
> ```
>
> So, wdyt?
>
Acked-by: Barry Song <baohua@...nel.org>
Thanks
Barry
Powered by blists - more mailing lists