From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 4585B606A32C for ; Thu, 29 Oct 2026 20:40:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=tG7yDmX8; dkim=pass (2048-bit key, unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=iUNGuoc0 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References :Message-Id:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date: From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Unsubscribe-Post: List-Owner; bh=FUMlocCCR3FNPkXe9l59Im2VqUBDzK2bwkLLReRcpPc=; b=tG7yDmX8mAyXPa d42beW1B5Rs1FOoqVjWGCLCWe4gYuXj4dUUN0NxatYB0EIR7pinOadb6IjUmtcT3TxlFru3vXJqEK pdcLvjcDRfCP6dow+ICsPrNL5a/0rpgMx5NOTq1pYgA08xWqSaZc2DvxvaFz6GJe/I5We5z3KXtTd JDKWuomWA4iC9UDG1pPDG73pfXOqUOcI3YMKwS0fX5Da7NUF+8zJZahRlmyAbaMyjs5239lcnDMmI 0RDGp5JoToL6jTG0Bu6GOmoMsSV8EQpnKjzAs7acNQ/5tG1QOl8KBB5ZH9p6kr2LFL884vXgl6h4S cgQI+1bn3yGzEtiXPE2g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.100.1 #2 (Red Hat Linux)) id 1xMWuw-0000000ALhD-49n3; Thu, 29 Oct 2026 20:40:10 +0000 Received: from tor.source.kernel.org ([172.105.4.254]) by bombadil.infradead.org with esmtps (Exim 4.100.1 #2 (Red Hat Linux)) id 1xMWuw-0000000ALh2-01AY for kexec@lists.infradead.org; Thu, 29 Oct 2026 20:40:10 +0000 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by tor.source.kernel.org (Postfix) with ESMTP id 5E8436061B; Thu, 29 Oct 2026 20:40:09 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C01EC1F01825; Thu, 29 Oct 2026 20:39:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1793306409; bh=FUMlocCCR3FNPkXe9l59Im2VqUBDzK2bwkLLReRcpPc=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=iUNGuoc0WeakiHgmDXnhuPlSghajcP6iyTr2aD2FuFZ51pYroFUry3bk8JUaMuEA3 XXcNDCVFvoALkSqrqd4c4ihHA2LGsPX/upOgvPJuWvhrp+8/2zaa0PLUJuKsN/8plW 9iGLRa5wuxHYdpBgli4Hpi+HHP6EIxJmTlApX431kJFtoeZ0B1B1M0Zp4gzk9TElJz VP0ojaFjbHD+kB+2kggTzsPRUHMqSoFzPO0brdXePjOTplmQj3LV3C4wd16dRHjz6d LfhgkMqYVhJp4fw1eMSl1gAQOa6lfEyik4W4IucHpl8YgrOAayJWXboJOwGq83GAdS y6H9j/Ymf33KA== From: "David Hildenbrand (Arm)" Date: Thu, 29 Oct 2026 21:33:22 +0100 Subject: [PATCH v2 27/47] mm/mmu_gather: fix flushing ranges with 4 GiB or larger X-Archived-By: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20261029-fixes_core-v2-27-a64ce7f83abb@kernel.org> References: <20261029-fixes_core-v2-0-a64ce7f83abb@kernel.org> In-Reply-To: <20261029-fixes_core-v2-0-a64ce7f83abb@kernel.org> To: Andrew Morton , Johannes Weiner , Michal Hocko , Qi Zheng , Shakeel Butt , Lorenzo Stoakes , Kairui Song , Barry Song , Axel Rasmussen , Yuanchu Xie , Wei Xu , Baoquan He , 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 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, "David Hildenbrand (Arm)" X-Mailer: b4 0.16.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2091; i=david@kernel.org; h=from:subject:message-id; bh=QH73tRoFq91DTzVscInadBQ8PK5Px8G2ighCsSz8YrU=; b=owGbwMvMwCF2/OVpCdfQ3ZWMp9WSGLIer23f+WLDDxbu6impZza76Sw7pvh0S2eDTcz8nSb2D zL3qncc6ChlYRDjYJAVU2QJCr5v8PLlutpqNz5mmDmsTCBDGLg4BWAizaYM/905uFk2VqfFhrmz XVlbZVP9L0C+ZDrvTsdXQa7Hvk8vSmL4p10dqrF9woXJN66x3TSeKXedRyrsAptEvgMXa+HZI8n PuAE= X-Developer-Key: i=david@kernel.org; a=openpgp; fpr=1BD9CAAD735C4C3A460DFCCA4DDE10F700FF835A X-BeenThere: kexec@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "kexec" X-Spam-Status: No, score=-18.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 From: Josef Bacik __tlb_adjust_range() takes the size of the range which has to be flushed as an unsigned int. Its callers, tlb_flush_{pte,pmd,pud,p4d}_range(), get and pass an unsigned long. Consequently, a range that is 4 GiB or larger gets truncated, possibly to 0. On arm64 with hugetlb, a 64k kernel can have 16 GiB hugetlb folios mapped contiguously at the PMD level and flush them when unmapping, and a 16k kernel can flush 64 GiB PUDs through tlb_unshare_pmd_ptdesc(). So at least these two scenarios are affected. Fix it by flushing the proper range instead of the truncated one by properly using "unsigned long" for range_size. Fix generated by an LLM and sent by Josef Bacik in private. Fixes: b528e4b6405b ("mm/hugetlb: add tlb_remove_hugetlb_entry for handling hugetlb pages") Fixes: 8ce720d5bd91 ("mm/hugetlb: fix excessive IPI broadcasts when unsharing PMD tables using mmu_gather") Cc: stable@vger.kernel.org Signed-off-by: Josef Bacik Acked-by: Lorenzo Stoakes (ARM) [ david: use two-tab indent, simplify description ] Reviewed-by: Qi Zheng Reviewed-by: Gregory Price (Meta) Tested-by: Gregory Price (Meta) Reviewed-by: Dev Jain Reviewed-by: Muchun Song Reviewed-by: Pedro Falcato Signed-off-by: David Hildenbrand (Arm) --- include/asm-generic/tlb.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/include/asm-generic/tlb.h b/include/asm-generic/tlb.h index fbe1114e9a44..3f4a180b48f3 100644 --- a/include/asm-generic/tlb.h +++ b/include/asm-generic/tlb.h @@ -350,8 +350,7 @@ struct mmu_gather { void tlb_flush_mmu(struct mmu_gather *tlb); static inline void __tlb_adjust_range(struct mmu_gather *tlb, - unsigned long address, - unsigned int range_size) + unsigned long address, unsigned long range_size) { tlb->start = min(tlb->start, address); tlb->end = max(tlb->end, address + range_size); -- 2.43.0