linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mm: arm64: Fix the out-of-bounds issue in contpte_clear_young_dirty_ptes
@ 2024-05-24  0:54 Barry Song
  2024-05-24  3:40 ` Baolin Wang
                   ` (4 more replies)
  0 siblings, 5 replies; 9+ messages in thread
From: Barry Song @ 2024-05-24  0:54 UTC (permalink / raw)
  To: akpm, linux-mm
  Cc: linux-arm-kernel, linux-kernel, Barry Song, Lance Yang,
	Barry Song, Ryan Roberts, David Hildenbrand, Jeff Xie,
	Kefeng Wang, Michal Hocko, Minchan Kim, Muchun Song, Peter Xu,
	Yang Shi, Yin Fengwei, Zach O'Keefe, Catalin Marinas,
	Will Deacon

From: Barry Song <v-songbaohua@oppo.com>

We are passing a huge nr to __clear_young_dirty_ptes() right
now. While we should pass the number of pages, we are actually
passing CONT_PTE_SIZE. This is causing lots of crashes of
MADV_FREE, panic oops could vary everytime.

Fixes: 89e86854fb0a ("mm/arm64: override clear_young_dirty_ptes() batch helper")
Cc: Lance Yang <ioworker0@gmail.com>
Cc: Barry Song <21cnbao@gmail.com>
Cc: Ryan Roberts <ryan.roberts@arm.com>
Cc: David Hildenbrand <david@redhat.com>
Cc: Jeff Xie <xiehuan09@gmail.com>
Cc: Kefeng Wang <wangkefeng.wang@huawei.com>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Minchan Kim <minchan@kernel.org>
Cc: Muchun Song <songmuchun@bytedance.com>
Cc: Peter Xu <peterx@redhat.com>
Cc: Yang Shi <shy828301@gmail.com>
Cc: Yin Fengwei <fengwei.yin@intel.com>
Cc: Zach O'Keefe <zokeefe@google.com>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Will Deacon <will@kernel.org>
Signed-off-by: Barry Song <v-songbaohua@oppo.com>
---
 arch/arm64/mm/contpte.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/arm64/mm/contpte.c b/arch/arm64/mm/contpte.c
index 9f9486de0004..a3edced29ac1 100644
--- a/arch/arm64/mm/contpte.c
+++ b/arch/arm64/mm/contpte.c
@@ -376,7 +376,7 @@ void contpte_clear_young_dirty_ptes(struct vm_area_struct *vma,
 	 * clearing access/dirty for the whole block.
 	 */
 	unsigned long start = addr;
-	unsigned long end = start + nr;
+	unsigned long end = start + nr * PAGE_SIZE;
 
 	if (pte_cont(__ptep_get(ptep + nr - 1)))
 		end = ALIGN(end, CONT_PTE_SIZE);
@@ -386,7 +386,7 @@ void contpte_clear_young_dirty_ptes(struct vm_area_struct *vma,
 		ptep = contpte_align_down(ptep);
 	}
 
-	__clear_young_dirty_ptes(vma, start, ptep, end - start, flags);
+	__clear_young_dirty_ptes(vma, start, ptep, (end - start) / PAGE_SIZE, flags);
 }
 EXPORT_SYMBOL_GPL(contpte_clear_young_dirty_ptes);
 
-- 
2.34.1



^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2024-05-29 15:21 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-05-24  0:54 [PATCH] mm: arm64: Fix the out-of-bounds issue in contpte_clear_young_dirty_ptes Barry Song
2024-05-24  3:40 ` Baolin Wang
2024-05-24  3:54 ` Lance Yang
2024-05-24  7:04 ` David Hildenbrand
2024-05-24 17:10 ` Chris Li
2024-05-28  8:26 ` Mark Rutland
2024-05-28  8:39   ` Barry Song
2024-05-29 14:59     ` Mark Rutland
2024-05-29 15:21       ` Will Deacon

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox