From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=95.215.58.138 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1793503081; b=jTw4SjlIOjB8GAl+/WdyZ6fQTGMuu75rShZF2Yd4ejhZcEEy4Stq25eoUwM0z6G/XED/ MtefsKdfKEncjqS1XcwvKIAkOOzpKiLkc3g0EJ1Se2WpOVVqNHWj3h+kDxCTa+kflT8Dv zNhZ33hLoS5IfyOq/MeSdaIh2cCwgZoUo62WKddEdz+Y1cFfASpI5lGJnkxP/qKsreafl 6l+oNDNAwoYdwNMpP/e7Niigjt1b/qwyBXO0bJeEXjovH2uMzsQ7SpTtrG7rlgI+POljQ Xhk7XDBOQlPF/FGIFEDMZb5h2jQcH2OSFPP8dXeK1CH4v+0AVQtfLaumQizRyiY/kqA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1793503081; h=DMARC-Filter:X-Envelope-To:DKIM-Signature:X-Envelope-To:Received: X-Mizu-Trace-ID:X-Migadu-Flow:Date:From:To:Cc:Subject:Message-ID: References:MIME-Version:Content-Type:Content-Disposition:In-Reply-To; bh=Z6x5MIctxHa9/j/zlx7zweNCYHHtp8racH88QViVO7E=; b=VScl+y7qAtv+Di3RUc5bkL9liSMRSrg4WsOFNEYzJhWiMvYwv7sBglL84dsLdj0UHcop WONxUDsfOQcR4dZlVdv0qDvhP+KbFfbDCaqdbOXX0+AuSAXGxxnuzSK/nx4XtOaLY/6p0 Hn0Kv6CoNl3HvTa7oIY+aMOedZDUwhRbUWzW5LB5P5cH301WxX/6JpQl03M7CuWy3AQiX rQpTm419VrjwW5qdKD3MTiXQFJaOVliAS/u2cMBvYctW2W3xSN1OMvmAiutzoqrTmBYE/ vBHYB5JI0KTfNE4iH09l7VEfQstru54aSKnUgDMTt70M0cED3O/vFsSa40h7uvwRaew== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b="p/Q4ETTt"; arc=none smtp.remote-ip=95.215.58.138 Received: from mta1.migadu.com (out-138.mta1.migadu.com [95.215.58.138]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2BB65606A327 for ; Sun, 1 Nov 2026 03:17:59 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 2BB65606A327 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key, unprotected) header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=p/Q4ETTt X-Envelope-To: linux-cxl@vger.kernel.org DKIM-Signature: a=rsa-sha256; bh=VqvV8qpM4mS5SY0ZFKzHPcZcEDmnWQFJ4Ho78vSEfFk=; c=simple/simple; d=linux.dev; h=from:to:subject:date:message-id:mime-version:content-type; s=key1; t=1793503078; v=1; x=1794107878; b=p/Q4ETTtIC16vjBAdv8+ISuTf0FXF9cgntxqj25Zl5aIfG1jL2F0WbNloasy9A7EoIVpIFOr OxNrtrDS+/8yGvz1wt4ceJoaCmPzh5TpOQQ1e5tJ/a9TBWUPDyrRr4BKmkx4z9zaG7vrKKwqfCV BxONu9cspI2Vmlgf0XZ8Mkzo= X-Envelope-To: linux-cxl@vger.kernel.org Received: by mta10.migadu.com with ESMTPS id 83615b79e9b3fb35; Sun, 01 Nov 2026 03:17:57 +0000 X-Mizu-Trace-ID: 83615b79e9b3fb35 X-Migadu-Flow: FLOW_OUT Date: Sun, 1 Nov 2026 11:17:50 +0800 From: Baoquan He To: "David Hildenbrand (Arm)" Cc: Andrew Morton , Johannes Weiner , Michal Hocko , Qi Zheng , Shakeel Butt , Lorenzo Stoakes , Kairui Song , Barry Song , Axel Rasmussen , Yuanchu Xie , Wei Xu , Baolin Wang , "Liam R. Howlett" , Vlastimil Babka , Mike Rapoport , Suren Baghdasaryan , Michal Hocko , Kees Cook , Peter Zijlstra , Jann Horn , Pedro Falcato , Hugh Dickins , Pasha Tatashin , Pratyush Yadav , "Matthew Wilcox (Oracle)" , Jan Kara , Zi Yan , Lance Yang , Rik van Riel , Harry Yoo , Alistair Popple , Nico Pache , Ryan Roberts , Dev Jain , Usama Arif , Kiryl Shutsemau , Matthew Brost , John Hubbard , Peter Xu , Will Deacon , "Aneesh Kumar K.V" , Nick Piggin , Oscar Salvador , Minchan Kim , Muchun Song , Xu Xin , Chengming Zhou , Chris Li , Kemeng Shi , Nhat Pham , Youngjun Park , Gregory Price , Joshua Hahn , Rakie Kim , Ying Huang , Jason Gunthorpe , linux-mm@kvack.org, linux-kernel@vger.kernel.org, kexec@lists.infradead.org, linux-fsdevel@vger.kernel.org, linux-arch@vger.kernel.org, linux-cxl@vger.kernel.org, Josef Bacik , stable@vger.kernel.org, Muhammad Usama Anjum , SJ Park Subject: Re: [PATCH v3 01/47] mm/mglru: don't use stack pointers when walking PUD and PMD tables Message-ID: References: <20261031-fixes_core-v3-0-d6437171ecc3@kernel.org> <20261031-fixes_core-v3-1-d6437171ecc3@kernel.org> X-Mailing-List: linux-cxl@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20261031-fixes_core-v3-1-d6437171ecc3@kernel.org> On 10/31/26 at 10:39am, David Hildenbrand (Arm) wrote: > From: Josef Bacik > > MGLRU passes stack copies of page-table entries in walk_pud_range() and > walk_pmd_range() when walking to the next level. These copies can become > stale when khugepaged or MADV_DONTNEED (CONFIG_PT_RECLAIM) removes a PTE > table concurrently. > > This pattern dates back to commit bd74fdaea146 ("mm: multi-gen LRU: > support page table walks"). Likely, earlier locking masked the latent > bug. Later changes exposed it: commit 1d65b771bc08 ("mm/khugepaged: > retract_page_tables() without mmap or vma lock") allowed concurrent > retraction, and commit cf4a65539c13 ("memcg-v1: no need for memcg locking > for MGLRU") dropped the walker's outer RCU protection. > > The fix is simple, so just fix the original commit so we don't have to > speculate. To fix it, pass the actual PMD/PUD pointers. This restores the > RCU-protected lookup and validation against the live PMD. Note that the PUD > handling is required as well to handle folded page tables correctly in all > cases. > > Fix generated by an LLM and sent by Josef Bacik in private. > > [ david: handle walk_pud_range() as well, clarify+simplify description, > adjust Fixes: ] > > Fixes: bd74fdaea146 ("mm: multi-gen LRU: support page table walks") > Cc: stable@vger.kernel.org > Signed-off-by: Josef Bacik > Reviewed-by: Rik van Riel > Reviewed-by: Qi Zheng > Reviewed-by: Dev Jain > Reviewed-by: Lorenzo Stoakes (ARM) > Reviewed-by: Kairui Song > Tested-by: Muhammad Usama Anjum > Reviewed-by: Harry Yoo (Meta) > Reviewed-by: Barry Song > Reviewed-by: Baolin Wang > Reviewed-by: Pedro Falcato > Reviewed-by: Kiryl Shutsemau (Meta) > Reviewed-by: SJ Park > Signed-off-by: David Hildenbrand (Arm) > --- > mm/vmscan.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) LGTM, Reviewed-by: Baoquan He > > diff --git a/mm/vmscan.c b/mm/vmscan.c > index 9959ca158ce83..6a1af9b92349f 100644 > --- a/mm/vmscan.c > +++ b/mm/vmscan.c > @@ -3911,7 +3911,7 @@ static void walk_pmd_range(pud_t *pud, unsigned long start, unsigned long end, > > walk->mm_stats[MM_NONLEAF_FOUND]++; > > - if (!walk_pte_range(&val, addr, next, args)) > + if (!walk_pte_range(pmd + i, addr, next, args)) > continue; > > walk->mm_stats[MM_NONLEAF_ADDED]++; > @@ -3947,7 +3947,7 @@ static int walk_pud_range(p4d_t *p4d, unsigned long start, unsigned long end, > if (!pud_present(val) || WARN_ON_ONCE(pud_leaf(val))) > continue; > > - walk_pmd_range(&val, addr, next, args); > + walk_pmd_range(pud + i, addr, next, args); > > if (need_resched() || walk->batched >= MAX_LRU_BATCH) { > end = (addr | ~PUD_MASK) + 1; > > -- > 2.43.0 >