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=1796368400; b=YIdK+Z0Ph6j82/nHDxAZPn6W6dVpNayV2+pMyf2OkP6T25S3Yb8aubtZ7qoCffImT4ei 34oZTOz3KKB6jMrzwu45iFlRVmbRxMzXVUiCvUwA8UQNaGc+xChj7DABAy7Qje0gakFAs GPFoh1pgQt8vPsbprcJGBDBdvdHL+rcaJ4msqJogmQqF1j96rvpyG67OfsZKy22kE1DYM MEGDKKeTG2tKOrgRlbJWTtwmr751pnEb8RTCEKUS5GKQXObhbCkgtOmmIGb165UEaVnsC egmrVmVDY3bvTRkLl9GfZuRXZb9HgvrjKl0nwIicP8J91+C7Ln6jq/7JGt6ioFoZYyw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796368400; h=Received:DKIM-Signature:Date:From:To:Cc:Subject:Message-Id: In-Reply-To:References:X-Mailer:Mime-Version:Content-Type: Content-Transfer-Encoding; bh=noh/Y8clq8BDgF7yoCng1XtSGQodiNWKwdNnohC+ut4=; b=uX0U6bxICpRaq6UcmLs/ofOg7PZXoP2Ra2O1hs2XSnv9+La2fh5XZPb9kANHi/gPNcsZ 8nJpHzw6wkeyjjrYK1AEuDDctxX99gfuHo43sQL4kxCYiYSSYMGXSzh0VbcPTqJSkNy63 P+AY5PlQmBcugTHiBDY0sVY6O0+eWSyaSr44sJkJL05dQn5ZohohO+zbxY5MwoCFrZcK9 rFUg7/CiSYf725+Jic4Ivn4pa8pJF7eanLYnu3IXMjA1rw+JOLaR6NmAkisFtWzE84yRy DvTYWJJ4TtSbvM7mfm/SrHL4G9l5r0FyRWSi8Xas+4HrjWjyORnjEBZnzxmr7sy1Y3w== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linux-foundation.org header.i=@linux-foundation.org header.a=rsa-sha256 header.s=korg header.b=VSJsdTPz; 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 8AF52606A322; Fri, 4 Dec 2026 07:13:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.a=rsa-sha256 header.s=korg header.b=VSJsdTPz Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3A5B21F000C2; Fri, 4 Dec 2026 07:13:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=korg; t=1796368400; bh=noh/Y8clq8BDgF7yoCng1XtSGQodiNWKwdNnohC+ut4=; h=Date:From:To:Cc:Subject:In-Reply-To:References; b=VSJsdTPzWlXcJbyxu894r7pMrIXwGbIoMSdYiXCS1nuVeHY4NAI5QhZnKhiqldq+m Lq1TwY9Bj3elKk1Fcw55wx/XBvTx8ntfplAMteb7hIduPaNTzYEQOqeNEOV/rqHRzJ LFWF/pGkGTGcwYB9fnI1/AorE1Nro3e1uhz3AvlE= Date: Thu, 3 Dec 2026 23:13:17 -0800 From: Andrew Morton To: Muchun Song Cc: "David Hildenbrand (Arm)" , Oscar Salvador , Hongfu Li , Jinmeng Zhou , Mina Almasry , Davidlohr Bueso , Naoya Horiguchi , "Liam R. Howlett" , Vlastimil Babka , Mike Rapoport , Michal Hocko , Jonathan Corbet , Shuah Khan , Randy Dunlap , Vivek Kasireddy , Mel Gorman , Hugh Dickins , Baolin Wang , Dave Airlie , Jason Gunthorpe , Andy Whitcroft , Roman Gushchin , Barry Song , Andrea Arcangeli , Lorenzo Stoakes , Suren Baghdasaryan , Shakeel Butt , Pedro Falcato , Jann Horn , Guillaume Morin , Yang Shi , James Houghton , Rik van Riel , Harry Yoo , Lance Yang , Axel Rasmussen , Peter Xu , Sasha Levin , Kiryl Shutsemau , Christian Brauner , "Steven Rostedt (Google)" , Hongbo Li , Gregory Price , Zi Yan , Joshua Hahn , Rakie Kim , Ying Huang , Matthew Brost , Byungchul Park , Alistair Popple , Andi Kleen , David Rientjes , Joern Engel , "Aneesh Kumar K.V" , linux-mm@kvack.org, linux-doc@vger.kernel.org, Gerd Hoffmann , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, Johannes Weiner , Chris Mason , Jiaqi Yan Subject: Re: [PATCH v2 18/35] hugetlbfs: don't overflow the end of the unmap range on 32-bit Message-Id: <20261203231317.a373d18fa27198137ea0e61b@linux-foundation.org> In-Reply-To: <9CB3DC39-869D-484B-AAD2-D38432CAE612@linux.dev> References: <20261203-hugetlb_fixes_2-v2-0-9bbeabb555d2@kernel.org> <20261203-hugetlb_fixes_2-v2-18-9bbeabb555d2@kernel.org> <9CB3DC39-869D-484B-AAD2-D38432CAE612@linux.dev> X-Mailer: Sylpheed 3.8.0beta1 (GTK+ 2.24.33; x86_64-pc-linux-gnu) X-Mailing-List: linux-doc@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit On Fri, 4 Dec 2026 14:44:20 +0800 Muchun Song wrote: > > > > On Dec 3, 2026, at 19:37, David Hildenbrand (Arm) wrote: > > > > When truncating a file or punching a hole, hugetlb_vmdelete_list() uses > > vma_offset_end() to translate the end of the range in the file to an > > address in the VMA, limited to the end of the VMA. > > > > However, the end of the range can lie far beyond the end of the VMA, and > > on 32-bit, calculating the address can overflow before we limit it. > > > > Consequently, we might unmap only part of the VMA, or nothing at all. For > > example, when punching a hole covering the first 4.5 GiB of a file that > > is mapped by a 1 GiB VMA, we only unmap the first 512 MiB of that VMA. > > hugetlb_unmap_file_folio() later unmaps the page cache folios, but > > anonymous folios in private mappings, and for example poison markers, > > stay in the hole. > > > > Let's fix it by checking whether the range ends beyond the VMA before > > calculating the address, which also simplifies the code. > > > > This has low urgency, as it requires 32-bit and punching a hole that > > extends 4 GiB or more past the start of a mapping. No need to CC stable. > > > > Fixes: 1bfad99ab425 ("hugetlbfs: hugetlb_vmtruncate_list() needs to take a range to delete") > > Signed-off-by: David Hildenbrand (Arm) > > With Sashiko's comment resolved: This? --- a/fs/hugetlbfs/inode.c~hugetlbfs-dont-overflow-the-end-of-the-unmap-range-on-32-bit-fix +++ a/fs/hugetlbfs/inode.c @@ -346,10 +346,10 @@ static bool hugetlb_vma_maps_pfn(struct } /* - * Can vma_offset_start/vma_offset_end overflow on 32-bit arches? - * No, because the interval tree returns us only those vmas - * which overlap the truncated area starting at pgoff, - * and no vma on a 32-bit arch can span beyond the 4GB. + * The interval tree returns only VMAs that overlap the range starting at + * start, so vma_offset_start() stays within the VMA on 32-bit. + * The end can lie far beyond the VMA. vma_offset_end() must check the + * page offset before converting it to an address. */ static unsigned long vma_offset_start(struct vm_area_struct *vma, pgoff_t start) { _