From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=115.124.30.101 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1793175885; b=okfBMucZFQ8u8489/zWQaKSaV6G+v2nS7tdMKl4RgCHLB48moluvlNHKkahjTm8L/QMn GZQ7wlXGo6Vh4xTIoo7308ewO0QDti4Wee/oFHr1X+h0m04wiyAcdUClqedLAVID+zXVa BPvItCeMbxxdzIElGr32YTmNe67Tz4Z6zc9qNbbdSXeyf4JxQLMFsea9jdgSvZ+B5VNFH fQ+d/gGpKWEHQEuu2LH+anl+oj1vwwwtekcknw9OvbZ/rgM1F2P+Vat3Lqd+hmFWKIcKy URLImm+Uks6r1p3FdP15wEK6MHZGLFBOvBDrK2Zm0TZyMlQSE1hr2rJqySN43uEIDqQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1793175885; h=DMARC-Filter:DKIM-Signature:X-Alimail-AntiSpam:Received:Message-ID: Date:MIME-Version:User-Agent:Subject:To:Cc:References:From: In-Reply-To:Content-Type:Content-Transfer-Encoding; bh=nfoVrSYOIzxmSP8r27IFAd8Frmu7ylTcKW71rW773Fg=; b=lFK/zc+5xYc5a/83+Pe7/bX3+V1G2hBdzdpiA7IUodCyrwnyO14dHB9wEBtvCzC1yiWr ZfcsrvScDS0ZAXd0aaKzthKBymYaJHK+3MAmjqJN+lCMDn8IMuStDfs329HhRYQKjEpGg h+kt6wyNAB5y8ka8kGzTCYgDBMcWCKr5Q8ToYfM97Dd1LjbbxlVzSx+ZwMhp4NvuywKBh TK+BKnFFMMn0oPBvPfALHzw3XivP7Ym7ttmlXBfe08Yl6b69QU/b75NlRn9+zEt5wrUN5 qtKiZXuXHAYWuKBX5sM+s7fgtkXruQCFcsJ6cfJr8G+SeRr+6rEWCE6b0KlHIM0L9cg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=linux.alibaba.com; spf=pass smtp.mailfrom=linux.alibaba.com; dkim=pass header.d=linux.alibaba.com header.i=@linux.alibaba.com header.a=rsa-sha256 header.s=default header.b="O5f/0fRB"; arc=none smtp.remote-ip=115.124.30.101 Received: from out30-101.freemail.mail.aliyun.com (out30-101.freemail.mail.aliyun.com [115.124.30.101]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 47A67606A31A; Wed, 28 Oct 2026 08:24:41 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 47A67606A31A Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.alibaba.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.alibaba.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key, unprotected) header.d=linux.alibaba.com header.i=@linux.alibaba.com header.a=rsa-sha256 header.s=default header.b=O5f/0fRB DKIM-Signature:v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.alibaba.com; s=default; t=1793175880; h=Message-ID:Date:MIME-Version:Subject:To:From:Content-Type; bh=nfoVrSYOIzxmSP8r27IFAd8Frmu7ylTcKW71rW773Fg=; b=O5f/0fRB2Frq2mKpntajf3aTwVJtKNZhrCJZCR8SIfw2+VY9JX1MUi2QGEQvS4P+tJiPI2zNuwMfhQpqrjD8hdVTKc6wiHi8cj/XXBhhIpZwNeceg7UD8i1E75/2IqLlCgjAGdMdO3aMPxHtvylzscKvlvA3BHLZnEmBk2sxAv0= X-Alimail-AntiSpam:AC=PASS;BC=-1|-1;BR=01201311R111e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=maildocker-contentspam033037033178;MF=baolin.wang@linux.alibaba.com;NM=1;PH=DS;RN=65;SR=0;TI=SMTPD_---0XDgGDMt_1793175874; Received: from 30.74.144.137(mailfrom:baolin.wang@linux.alibaba.com fp:SMTPD_---0XDgGDMt_1793175874 cluster:ay36) by smtp.aliyun-inc.com; Wed, 28 Oct 2026 16:24:37 +0800 Message-ID: Date: Wed, 28 Oct 2026 16:24:34 +0800 X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 01/46] mm/mglru: don't use stack pointers when walking PUD and PMD tables To: "David Hildenbrand (Arm)" , Andrew Morton , Johannes Weiner , Michal Hocko , Qi Zheng , Shakeel Butt , Lorenzo Stoakes , Kairui Song , Barry Song , Axel Rasmussen , Yuanchu Xie , Wei Xu , Baoquan He , "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 Cc: 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 References: <20261027-fixes_core-v1-0-6f74bec9a5bb@kernel.org> <20261027-fixes_core-v1-1-6f74bec9a5bb@kernel.org> From: Baolin Wang In-Reply-To: <20261027-fixes_core-v1-1-6f74bec9a5bb@kernel.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 10/27/26 7:17 AM, 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. > > Fixes: bd74fdaea146 ("mm: multi-gen LRU: support page table walks") > Cc: stable@vger.kernel.org > Signed-off-by: Josef Bacik > [ david: handle walk_pud_range() as well, clarify+simplify description, > adjust Fixes: ] > Signed-off-by: David Hildenbrand (Arm) > --- LGTM. Reviewed-by: Baolin Wang