From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796381076; b=SRyDnP4N+xGQckqRNP439Ix1U1LJ3VzRUaffOIESHkg/gKxr0b/M4icXP5Zp+/MPJKOe q+9UUal2NJQ57t5NjtfYOHK6NoB12SkWQ2jQTwLkQvYXPUc6xpz2UkenI90G7LZ9iSRcU DHEtiGIJmETHV/LwwGNKcHTK6sFFhBNyttsfSIJMtDNyrHHGbsUHPEGye5/YVNVMqlxJN ydEPcTSl6gph3LV7qVQ1Y/S+Y89Y1uHiEkozhayVW6MWS2vW9t/TcYAbQTzWOzagXe4SP a3aiaAHfTKjfHIXuc2EsDr1kuwmuo3jyw2STNUb7Sq2T+/711lr5NlEoMPAt0NWko2g== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796381076; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=IXBo3Rt8hrpn/fPv7GoF2Kq9PE5h8h1UeYtV+BIhpVw=; b=X/TNvn7INBuHHrK3rSoyPuS1V0NLN0TaxoDB3VRAWj1O6EuVqU3mH/YPdbEx64f9gSdR H0EhfDYTePCg7hQZoevHAY6MmEuS92V2jlymCRwVCanlUvKHWhNSehQLD7aPg1qrDeJBd /47HLo/jUaLRy6mZ0y61OQeFAaKKJdWrfvFXJ2YKnJV8fThYX9MGXfpObly9PHjqS1Mdh 2oiUk9kYljonf2BcEsDf9TNKTMWDxjQJ8qmwRWiEHFcElCRhqqHLy5qMkbpckrsRafpop 8DTsraRE09n661GYsHJgJpV1yzVM1bzcI6FBo4kelLmOBPJ/Pu5yMdi/dPHJzQGkrxg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=UIw4b321; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D5157606A322; Fri, 4 Dec 2026 10:44:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=UIw4b321 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1C71B1F00931; Fri, 4 Dec 2026 10:44:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796381076; bh=IXBo3Rt8hrpn/fPv7GoF2Kq9PE5h8h1UeYtV+BIhpVw=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=UIw4b321Pm4zetgyjQegxLNXvWT0KBcKqykwnyqQAjI3KLZd7wCL92gtYyVIVkoNU rGvFlkCzojSJNcTLvFHZEQ2lm+1bkCYs385mfHNMzbuwsAWe6+OTrMAA1ucLufzTM1 Hk537vC1inqIGS8vfrd7DvSahkcf4A/5GPvSnL1s= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Chris Mason , Baolin Wang , "David Hildenbrand (Arm)" Subject: [PATCH 7.3 548/742] mm/rmap: fix PTE table overruns during batched unmap Date: Fri, 4 Dec 2026 19:06:52 +0900 Message-ID: <20261204100649.716623902@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100635.034361255@linuxfoundation.org> References: <20261204100635.034361255@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 7.3-stable review patch. If anyone has any objections, please let me know. ------------------ From: David Hildenbrand (Arm) commit d8bbf585893c7868234b71d7e7f32484ed0d8458 upstream. With a folded PMD, pmd_addr_end() simply returns the supplied end. folio_unmap_pte_batch() can therefore walk past the PTE table when unmapping a large folio. Folded PMDs are uncommon, but can occur even on arm64, for example with 64K pages and a 42-bit virtual address space. Use pte_table_clamped_end() to clamp the range to the PTE table and VMA boundaries. Fixes: 354dffd29575 ("mm: support batched unmap for lazyfree large folios during reclamation") Cc: stable@vger.kernel.org Reported-by: Chris Mason Reviewed-by: Baolin Wang Link: https://patch.msgid.link/20261111-pte_table_clamped_end-v1-2-2dbe339c487a@kernel.org Signed-off-by: David Hildenbrand (Arm) Signed-off-by: Greg Kroah-Hartman --- mm/rmap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/mm/rmap.c +++ b/mm/rmap.c @@ -1980,7 +1980,7 @@ static inline unsigned int folio_unmap_p return 1; /* We may only batch within a single VMA and a single page table. */ - end_addr = pmd_addr_end(addr, vma->vm_end); + end_addr = pte_table_clamped_end(addr, vma->vm_end); max_nr = (end_addr - addr) >> PAGE_SHIFT; /* We only support lazyfree or file folios batching for now ... */