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=1794590409; b=v5ubu6Xviw/VtU33VQAmAX6pRjdKtfbOEauGxf/S7y/HH6toW3rUBvvW4MwqpnCN0MXK GhezkIMo1UaLOix6PNfZioJYvwBY0zvU80Xbyl/sGNsUyifcms2SGUpB5f6LOTg78o3c9 jjo9CKkNU9GlDOcTK4ItWk49boZRAgzkIMY+O/8XkkbsJiC/TE+9PYnLHSAs9yafSYBqc CShgQPVH5Ny9HuC5RYn1yLGUg+6RFgWFP98g/cR5cRC9vKEo5TNPLkgtj7yt3mfJOHNDQ 9+RhUhWzResfsl+eDBQpQzOiuJfa0pgssKpDPiw5II1/W6AUiBuHUSr3XITWgSxd42g== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794590409; 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=g3W8rCo3yknCsjH3nt0tiLXK/diPngMJ2TnjqB93QtU=; b=qg+v6fMuKejjcR38Lo/2U3E9sxgnTiEYoFgOFuJ+KjP+yRsk6VWbxwIbxUjszO1wQKIs 3O6u22WuHRwFWqDrlWTisUfGeBvijBnzSHcHO96unTeer2K2L4aWAu4mb+7P53jxHK2Vw drYfMdpQig430yJ8xcxvVdoxBrgy8ToJLR69knoSrgn6P5s1ZrhTp2t23apvCXPT98yaF HK8d2xWFkq1x3gOJXn4DLi3E61jyUi7QoUsEWqD9nmaaLFq8i4aUQAdzgpsCXGZ1wN/vp 1e1Jpj9mDRUV0+IiO9ckzTdu1iSgUo7zzXzAHRtFLuNOfJxxlAMRFmyqDwt1+JwY/rA== 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="txAMx/fl"; 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 D6305606B47B; Fri, 13 Nov 2026 17:20:09 +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=txAMx/fl Received: by smtp.kernel.org (Postfix) with ESMTPSA id 563541F000C7; Fri, 13 Nov 2026 17:20:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1794590409; bh=g3W8rCo3yknCsjH3nt0tiLXK/diPngMJ2TnjqB93QtU=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=txAMx/flOeSFpVmRowJFTvMfnqZDB/aF77djjzs+5dpfght3YdSf+9tQHPBXRjpur libvZDgAip4asmDqbiGq5lX7EraSxfYdRtNHKCx7qsWCFqYnSd6L3EIbeCWLG0wFZk mrNNB6/CgC0MnX+ahK6Zl3O5bd1HQEqjEzSE729A= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Josef Bacik , "Lorenzo Stoakes (ARM)" , Qi Zheng , "Gregory Price (Meta)" , Dev Jain , Muchun Song , Pedro Falcato , SJ Park , Muhammad Usama Anjum , "David Hildenbrand (Arm)" , Sasha Levin Subject: [PATCH 6.18 376/686] mm/mmu_gather: fix flushing ranges with 4 GiB or larger Date: Fri, 13 Nov 2026 10:48:29 -0500 Message-ID: <20261113153833.655938944@linuxfoundation.org> X-Mailer: git-send-email 2.56.0 In-Reply-To: <20261113153820.902362109@linuxfoundation.org> References: <20261113153820.902362109@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 6.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Josef Bacik [ Upstream commit 64ae7959a1df8af8eec504e31df2ec9670424a4e ] __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 Reviewed-by: SJ Park Tested-by: Muhammad Usama Anjum Link: https://patch.msgid.link/20261031-fixes_core-v3-27-d6437171ecc3@kernel.org Signed-off-by: David Hildenbrand (Arm) Signed-off-by: Sasha Levin --- 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 4d679d2a206b4..16dd46d376559 100644 --- a/include/asm-generic/tlb.h +++ b/include/asm-generic/tlb.h @@ -395,8 +395,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.53.0