From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=91.218.175.89 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796368652; b=3nzi3+5xZZuloV/4LPpiibkQa28DJwlDw3MVxbHRMw3WIkmzDQ2D5seXGisYzkCUrSeX Jy7rzB4ay9ijF/Nf1zOCPoQwSuGhx6rMpEnDOtb/DDz12zE8uvESXfsiiTZbTlFbh96rh /ZYe7aipPP17zkugwOM43NznqpCgjMT7l6NPNMFyjeuEQmwL4X8hUHRc7Df3NCUJgylme J3zyJxRTGBrBqwo4URoXLW2eAfQ6htVVfckn6h7tPIgjPyrsChjOqszuyEueUXvWLLiGX tDGHz4r7rNNXRP+PMfS4+PS2G8lmqAMnCNQPkT0E82mjFdMI64GmmqhKIR1IgjvpbQQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796368652; h=DMARC-Filter:X-Envelope-To:DKIM-Signature:X-Envelope-To:Received: X-Mizu-Trace-ID:X-Migadu-Flow:Content-Type:Mime-Version:Subject:From: In-Reply-To:Date:Cc:Content-Transfer-Encoding:Message-Id:References: To:X-Mailer; bh=HgXCGfPHFZjPNO550o4+lWwmmsoly34pmY0FCbgCJBk=; b=MTM1OcV3nx5CY+N1EqIvIpyO90myyDKKQgBGZR+fZBrihAXOaxRkQ49xUhTcHx0dPLYr DPCxndz09yLS56CxCcPMkn1K7yNLhJYxUuoIyvCNhBr42ibca0toxg5N1yCGyeYC8kBz9 oqu8wvaCcfzjUMPdeF8OoUEzK0CkKhKW80UXFj2T0ZSp3D46LqKpuAZnX9JfZnKTq0Ck4 WF+ijpVKo4bRigcwVRWYZc1DaYhc9zDuq95+pN60ritNSovsoZVlVlexbDcJTNcMU7XXP XYRCiVpsoSD0IwY5745UEIlOJGRUc9x3BkkIjGNPKC09IBceb1rGupuXsV15oBtX6Gw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=FEF+VUb3; arc=none smtp.remote-ip=91.218.175.89 Received: from mta0.migadu.com (out-89.mta0.migadu.com [91.218.175.89]) (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 4E104606A32C for ; Fri, 4 Dec 2026 07:17:31 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 4E104606A32C Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key, unprotected) header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=FEF+VUb3 X-Envelope-To: linux-doc@vger.kernel.org DKIM-Signature: a=rsa-sha256; bh=QOxW3WtFmljPTMMcJ/UTYh12gOqp3Pa8r3WUsmixwRI=; c=simple/simple; d=linux.dev; h=from:to:subject:date:message-id:mime-version:content-type; s=key1; t=1796368649; v=1; x=1796973449; b=FEF+VUb3Pe9C8Dz9DiuKYCNhzJ+eRD9iCKsOUwrvHpTh40xknwbcE3GLeCCE6G7o7OH8A2Ur IDW4Aq/Skh+jpYQiLs5fDJCPnCpCIK3nNr886mp/FZtOVMEvjYdt5obcHj6VKJjsTN4swAJ9x+w 0qRLS3ZSXFwJUkiXxB8nbtx8= X-Envelope-To: linux-doc@vger.kernel.org Received: by smtp.migadu.com with ESMTPS id 727cc1638c2b8086; Fri, 04 Dec 2026 07:17:28 +0000 X-Mizu-Trace-ID: 727cc1638c2b8086 X-Migadu-Flow: FLOW_OUT Content-Type: text/plain; charset=us-ascii 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 (Mac OS X Mail 16.0 \(3901.200.71.1.16\)) Subject: Re: [PATCH v2 18/35] hugetlbfs: don't overflow the end of the unmap range on 32-bit From: Muchun Song In-Reply-To: <20261203231317.a373d18fa27198137ea0e61b@linux-foundation.org> Date: Fri, 4 Dec 2026 15:16:55 +0800 Cc: Muchun Song , "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 Content-Transfer-Encoding: quoted-printable Message-Id: <4E14E5C3-3E90-4170-A2CF-55389448BD88@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> <20261203231317.a373d18fa27198137ea0e61b@linux-foundation.org> To: Andrew Morton X-Mailer: Apple Mail (2.3901.200.71.1.16) > On Dec 4, 2026, at 15:13, Andrew Morton = wrote: >=20 > On Fri, 4 Dec 2026 14:44:20 +0800 Muchun Song = wrote: >=20 >>=20 >>=20 >>> On Dec 3, 2026, at 19:37, David Hildenbrand (Arm) = wrote: >>>=20 >>> 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. >>>=20 >>> 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. >>>=20 >>> 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. >>>=20 >>> Let's fix it by checking whether the range ends beyond the VMA = before >>> calculating the address, which also simplifies the code. >>>=20 >>> 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. >>>=20 >>> Fixes: 1bfad99ab425 ("hugetlbfs: hugetlb_vmtruncate_list() needs to = take a range to delete") >>> Signed-off-by: David Hildenbrand (Arm) >>=20 >> With Sashiko's comment resolved: >=20 > This? Definitely. >=20 > --- = 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 > } >=20 > /* > - * 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. > */ LGTM. Thanks. > static unsigned long vma_offset_start(struct vm_area_struct *vma, = pgoff_t start) > { > _ >=20