From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.128.49 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795982132; b=YasuqZWjIB2QV0On3mpAsQh0kMyKPxBg+5isTOEZ+xfEb85NohbWz2Yi2ufSp3CasOah IwU3AYSsSEkMGvj+z+1pVsAjitNfCoPykhUdysEIW6ZkJzaKf1VIKCedTmxYj5xuAtSt3 67ckU20qPslKjAstfXXvQbOjjUqnjLS4OMIAVBM5Fy0CK7/5A4udq6UYOOogwrEHsYvfg Cm04+cQ5vcH/HzE3jGIdy/82lgovOEjRs+SfWnFYKQYouuzIEMYTlA5/CEdmiMp4PTozy O2o09tsA8rH4+KY9CyM9y/75p1j9JVgsljQhNFtxEInwefcd26YXU2+VffHkFJwCqPA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795982132; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: Message-ID:Date:MIME-Version:User-Agent:Subject:To:Cc:References: Content-Language:From:In-Reply-To:Content-Type: Content-Transfer-Encoding; bh=10lIXH+ug9JyJ9Q2jEr15V5UxJ7Xq2lKcnYCfQtSLj0=; b=Mh/7jC3sSbwZkBPqUpRgo/OkY7YFTYek+FuUbmZ+rElNB8RQ1k83hqBmuq+DiD6kpx3X IQfLM7YPUSUEz6jEwwDq8FPsXdES8ampJfIE7lpmAqK+4jdswafFY7SNKxviVhsfYJc53 q1enACWZQST41C4Z+VBrCjBLEDK8o5k35Pjn3AER4Uo/w9eL9Ks68m0iDmz9sdF+wOk3W 6AmTG0AFxhh5mYWBr4HicBI0LbRSKwPth/FCcnZoXO5xgw8BuqNbCfnKGo/i/d5azMfPl 0gr9dwPbtcqtS6t5dzXc3iBzRehgXXNbgwOz3A89im1+8y9DIvNFN26uuvjLbElYeSw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=xd0VurdK; arc=none smtp.remote-ip=209.85.128.49 Received: from mail-wm1-f49.google.com (mail-wm1-f49.google.com [209.85.128.49]) (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 B1660606A31C for ; Sun, 29 Nov 2026 19:55:31 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org B1660606A31C Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=xd0VurdK Received: by mail-wm1-f49.google.com with SMTP id 5b1f17b1804b1-4a9a8d6cea8so124022695e9.1 for ; Sun, 29 Nov 2026 11:55:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1795982130; x=1796586930; darn=vger.kernel.org; h=content-transfer-encoding:content-type:in-reply-to:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:from:to:cc:subject:date:message-id:reply-to :content-type; bh=10lIXH+ug9JyJ9Q2jEr15V5UxJ7Xq2lKcnYCfQtSLj0=; b=xd0VurdKpcISSvjMfQBhBaMEKo5GSeSIivjCm3BFHCsgUCR3ys3TlepQm+5m8mdOov hkRXt+XoQjjMDc00yskX/LN4bZAzmeVikAkcVPbHFsyBVG9XUUB/GambMXyDsgoGD4rP n3oLx+Aqg3jRjwEO9kizVG/Q19syoI8stiS4CoSAUtqR1xpdLIANWajOqLHlujNERskm XJ6Ju0f5zILBrT07sIBW+2pskOIH7HIyx01zoyp4eUSQ+zilzSXabmVUUIeo7D8HT6kD 2fEV9eFbFs2U8QGSUFjuoDlzZswYi0jVff/xgKVj2TuhBeP+KYGq7HTAs4t7aQfXkP3K 8zug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1795982130; x=1796586930; h=content-transfer-encoding:content-type:in-reply-to:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=10lIXH+ug9JyJ9Q2jEr15V5UxJ7Xq2lKcnYCfQtSLj0=; b=u3hN/THCga4dA53nCKy2lPOVAIYRCU6Ql8durCAOAz+1SDpbYhs5bF2Py/8gbNOjld fvtakSZVGV99KEU/N4gF7FgJUlPJQ6lfgnmQn8bel2s3akG81iobesjb/GGmCE/PtxJ7 5mVrCWtvIH9+ohV9NbWbxY2TTMj5eJQBRVxbNCc3oARBUvFN9Fg5+JMulWYtZ/H4LI1M Sy/Qv8Tn9csLFD6BR81lN8BYoy0IRVVO8XbgkNnCxizyd8NjoCSfDXhBdWEYBGzOjS4D xCjbPEM9jQODdTLys5MHfpeTFD7MYe3JnGwNeiCMclGmjvflweZN8JPskrJ0VQMQ9qiL ChAQ== X-Forwarded-Encrypted: i=1; AL+hErETKbbUlJqK3jP0uadz4RAODprcbV0az0YLsDbEuccG8yjCZlLjmhZ9bznPsY2U63JffIbX1IbxhHE7kiU=@vger.kernel.org X-Gm-Message-State: APuU4Z+RZ/N9esn6XefrYtmbWdh6226E/4u88NQthkdm0EA2mwCe6xxu Pq8yNBP0m6gzAaYVZBFYgF0QGo96n7rXQfVyChRH1EaxBPJMWEa6Dw9k X-Gm-Gg: AZFdTZcfzvLsnzWGz/SxNZZKIk+EgPFoJ3M5+vkMt+N3yGuPDQpXVKlE4SyvfPbCec5 UBseg3Rh5p2mpcAe/P6p+FScsPg5ze6NUtNMB2LEU9hfS4dOFkr8u0kMpIApeFBf4G0I7LP3n1g AzAlxO88T/ICmaG80PV3JyJWWGDuenghPDxzgpaVFAGXX1tFFom94VOnKz4Z+sV+0whKHlKM1kw b2Ekqv5Nk33Ti9YDqx3oYaSTlx45qNc1frGIVrm+Ej8mMee80mplZFqxcHQaK7uLqI3cpFtIMV2 nw/3xPHQ6JMa4bBxonC0wTpGogFHWUtbodkdmspjBg3OAPXbmX4s9KFRwZxBHimzs211ioLN8OA v0KFExH/gvYqek22t35ZRL3Ps/Vs82eR3SDVxOhZ7c5+XYzHcadPFDdywgCNFdaxsIaDZriYUjT /6IdO31QTvYl1M5afow/BGr5bQfj0fNrCNo4UkpWIk6u4NaSqExl0MJ3hQHPBaof2hczrnh/ChF Wey05zPHzT1tUfbTuD67RDM5zMwBM22Gdsi+vSgKqNU81RsnLRh2/2s6QdcbotQezHUseBY3N8T areXVsc3eS1d6brl/rmk5wgl X-Received: by 2002:a7b:c5c1:0:b0:4bb:b850:15ba with SMTP id 5b1f17b1804b1-4bbb850174cmr118843285e9.11.1795982129986; Sun, 29 Nov 2026 11:55:29 -0800 (PST) Received: from [192.168.1.22] ([83.231.69.9]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4ab6a68048esm62984965f8f.29.2026.11.29.11.55.25 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 29 Nov 2026 11:55:28 -0800 (PST) Message-ID: <99ebb6f3-1647-4067-b6aa-198b54ff556c@gmail.com> Date: Sun, 29 Nov 2026 20:55:24 +0100 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 , Baolin Wang , 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> Content-Language: en-US From: "Jose A. Perez de Azpillaga" In-Reply-To: <20261129-fixes_core_3-v1-7-f66094116801@kernel.org> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 11/29/26 11:06 AM, 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: Jose A. Perez de Azpillaga -- cheers, jose a. p-a