From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=115.124.30.124 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796202453; b=csfMM5NW/cd0J/qgcydq8vnkUFAeXxmVoEISHphEIvKA2C5Q7Wi4TyKD2T+Yppl/DQ66 eDUQ415TyyxL1/gEkNYMswLMoRC2e30jYSUUkQouoEBXv1BLQl+rRTFWdVOM+wh3YRPGH 8xMgORzVb49s9kqSBQ8Ywe329IpyXeu69ITt4fsWbiNsR99px0TxXtNOvHTQu16NiPU1x Gm1YJPUGqKyoR0JyUuDXyea1H7GTOi1Uo7OZxyqDatkaaUxNSgiOLYjYZbriceWh8Bqd5 HalMurs+Ek5JcCA9mOKZyahZRoGIWpD+ycGRsQkfE2DTSS3f5OXSic/DIR7WAM4kA8Q== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796202453; 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=YLPqfHoO21lJVpZDLFi0Da6jQzesoK5I1oDo94TZDok=; b=XsoooayTMCDDZKEkc+MBS1S6hQRFu6UUGgCMe6aY76308ALMxVfoTzVyOU1baetJoSOL UAmRvhzSOd0qZcThY0pIZrqW9uyhHBhiHUdaI29NhcXVH0VqvKL/lztHssBjeUIaunvnj 7x9dCvgxh8eFH59/8Di2jH9EY304wpoEGuVNoEt7Lk46hEsHXmSw79DyCYnP+k+PQgypu hZYxKGB0wjf3mv88NW9ubWOnaoAs37911ddqJ+b88/8LOSMZ3nR2ChtYSXuyt1kqdrKAf qZhS2uEaezyP2UaxKTqGwCuhx0Vhu27Tc8E3X1vhXc89u+GRi43GXsTx5QoSNCJREJA== 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="c6/d+xjf"; arc=none smtp.remote-ip=115.124.30.124 Received: from out30-124.freemail.mail.aliyun.com (out30-124.freemail.mail.aliyun.com [115.124.30.124]) (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 656C6606A322; Wed, 2 Dec 2026 09:07:31 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 656C6606A322 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) header.d=linux.alibaba.com header.i=@linux.alibaba.com header.a=rsa-sha256 header.s=default header.b=c6/d+xjf DKIM-Signature:v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.alibaba.com; s=default; t=1796202450; h=Message-ID:Date:MIME-Version:Subject:To:From:Content-Type; bh=YLPqfHoO21lJVpZDLFi0Da6jQzesoK5I1oDo94TZDok=; b=c6/d+xjfTqiVh8Er7N1JLFKJFOAAhv2ZO6cIa/N2EZYX51EcOkq9ZssfqdoPO7PolsnglZbmjF07jaLhnSer/LP/zldrn+mQA4lqQNqPbi8xXr+CTOm67mnUjGlm+LV6Ms4CrLeukwGMpV9M4pFkUcAnNQcxNMnvbI4J/fy5/90= X-Alimail-AntiSpam:AC=PASS;BC=-1|-1;BR=01201311R141e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=maildocker-contentspam033040069076;MF=baolin.wang@linux.alibaba.com;NM=1;PH=DS;RN=81;SR=0;TI=SMTPD_---0XG8ycE9_1796202441; Received: from 30.74.144.133(mailfrom:baolin.wang@linux.alibaba.com fp:SMTPD_---0XG8ycE9_1796202441 cluster:ay36) by smtp.aliyun-inc.com; Wed, 02 Dec 2026 17:07:24 +0800 Message-ID: Date: Wed, 2 Dec 2026 17:07:20 +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 07/32] mm/khugepaged: check the VMA before walking page tables when collapsing To: "David Hildenbrand (Arm)" , Hugh Dickins , Andrew Morton , Mike Rapoport , Peter Xu , Michal Hocko , Kiryl Shutsemau , Manfred Spraul , Davidlohr Bueso , Cyrill Gorcunov , Zi Yan , "Liam R. Howlett" , Nico Pache , Ryan Roberts , Dev Jain , Barry Song , Lance Yang , Usama Arif , Lorenzo Stoakes , Rik van Riel , Vlastimil Babka , Harry Yoo , Jann Horn , Yang Shi , Zach O'Keefe , Song Liu , David Stevens , Kefeng Wang , Alex Williamson , Suren Baghdasaryan , Dave Jiang , Matthew Wilcox , Miaohe Lin , David Rientjes , Shakeel Butt , Jan Kara , Mel Gorman , Jason Gunthorpe , John Hubbard , Gerd Hoffmann , Vivek Kasireddy , Dave Airlie , Matthew Brost , Joshua Hahn , Byungchul Park , Gregory Price , Ying Huang , Alistair Popple , Hagen Paul Pfeifer , James Bottomley , Felix Kuehling , Alex Sierra , Balbir Singh , Kairui Song , Qi Zheng , Axel Rasmussen , Yuanchu Xie , Wei Xu , Baoquan He , Oscar Salvador , Muchun Song , Dan Williams , Rakie Kim , Hao Li , Christoph Lameter , Roman Gushchin , Sebastian Andrzej Siewior , Clark Williams , Steven Rostedt , Alexei Starovoitov , Xu Xin , Chengming Zhou , Shivank Garg Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-cxl@vger.kernel.org, linux-rt-devel@lists.linux.dev, SJ Park , stable@vger.kernel.org, Chris Mason References: <20261129-fixes_core_3-v1-0-f66094116801@kernel.org> <20261129-fixes_core_3-v1-7-f66094116801@kernel.org> From: Baolin Wang In-Reply-To: <20261129-fixes_core_3-v1-7-f66094116801@kernel.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 11/29/26 6:06 PM, David Hildenbrand (Arm) wrote: > MADV_COLLAPSE and khugepaged can end up traversing page tables of a VMA > through find_pmd_or_thp_or_none() before verifying that the VMA is still > as expected. > > Calling find_pmd_or_thp_or_none() on a mapping with PUDs > (hugetlb/dax/PFNMAP) is invalid, as it treats every present PUD entry as > a pointer to a PMD table. > > Consequently, we can end up interpreting the memory mapped by a PUD leaf > as a PMD table. > > Let's fix it by performing the thp_vma_allowable_order() check before > the page table walk. > > Further, let's also make find_pmd_or_thp_or_none() harder to get wrong > by rejecting any pgd/p4d/pud leaves. > > This has high urgency, as unprivileged users can trigger it, although > getting relevant PUD mappings (e.g., hugetlb) should be rather uncommon > in most setups. > > Fixes: 58ac9a8993a1 ("mm/khugepaged: attempt to map file/shmem-backed pte-mapped THPs by pmds") > Cc: stable@vger.kernel.org > Reported-by: Chris Mason > Signed-off-by: David Hildenbrand (Arm) > --- LGTM. Reviewed-by: Baolin Wang