From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.128.46 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796383277; b=okNWkcUcJtHWiZUg509+TuM4CsIOxUGwwrGw+bCI5tJEtlUtEyecp7QVCHc1sQg67Ipy ZUVDGUyGEcg1FUyAxs9ATlg31vARHItgaND5shI8Lbxtuc7iFrH8mJPHRegPYl82ktTM+ 25qVydxEVDFIqtukuaA8/s99PupbnJ9m6gEtb6H0hgrYJCJMARnf+ERdnHq3I9km8PiJ7 IyZWqxFS+/61c5M8kiI7w2hfhii5ZbvOfTWRZQyNJ/Q6B1t7FPcW+P73ABv0OnTrQLkhT kr4lkh9ha86ZAqym1je9NZQCtkHXSclH9PRVS5dKnOXWL8EiZRBT3Eo7HAQfy3ZTr6g== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796383277; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: Message-ID:Date:MIME-Version:User-Agent:Subject:To:Cc:References: Content-Language:From:In-Reply-To:Content-Type: Content-Transfer-Encoding; bh=fglGtPlPornySKUmWKmYMke/+iF+4QKkQJ+kPOzmGQU=; b=4AFG4ZVIyRQWI4737jrTA2iuqrG/QCLKdO4GamzCNE0EM2yoiHxf8xxij3iIV3vsagxL Ak8W1pDQY4lg2IlJCE+mei9EJtNAF+fe8dhEUIGUmntEh8Mnqtf5YQO17EcmJDGk123k3 A0URoqVYJXa3EqT94+PumRjUxgVPfCgiBv3+WIXtdeRuunEe4fou/tqwasi4PabjPdXIY axNhjP6WI7o0eZFZiqY+T5/awXYV77mKWXP8nHm5Ikyq76fKVL30zgjNDxrh/v7ynKura FpDEzz8tr6FlvkurKi801CzKOdFEenV60P4mj3UxK1iM1jCzfROIJJS7L1ET3rIFXKg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b="tI+/4LzE"; arc=none smtp.remote-ip=209.85.128.46 Received: from mail-wm1-f46.google.com (mail-wm1-f46.google.com [209.85.128.46]) (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 42F04606A332 for ; Fri, 4 Dec 2026 11:21:17 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 42F04606A332 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=tI+/4LzE Received: by mail-wm1-f46.google.com with SMTP id 5b1f17b1804b1-4bb702a7548so3699095e9.1 for ; Fri, 04 Dec 2026 03:21:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796383276; x=1796988076; darn=vger.kernel.org; h=content-transfer-encoding:content-type:in-reply-to:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:from:to:cc:subject:date:message-id:reply-to :content-type; bh=fglGtPlPornySKUmWKmYMke/+iF+4QKkQJ+kPOzmGQU=; b=tI+/4LzEcxMExcpQm2cYaUc0HpiZIvYhIKTc0ceMXfl10HiHBIhpxAznsor+upprxf THyRAOd8H2+ew2nj15fjeLSa1UYmmMlG9G+Iw9GWSMp1xXKNypqh/w/n9ySkSd2UfQe4 AVYYj1b22X+6CN/yXSWbIq0c6MAR71yhz4MwVwWcnQCCv2h9PheyW6It32eiM0qxI8oz c8Uj5teDJZFD1mPVqmrHJpJ7wirav+8U7JfXM2eO94Ca8Ii3kXy3uHaFYFQ3GKHp9+R7 TzrVkSBqRg86vuI/gahaAgYhV1oTsHiAEmaio9MFC3KSVfNYPQy/XtBWZVbeaR9GJIMD ZZYA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796383276; x=1796988076; h=content-transfer-encoding:content-type:in-reply-to:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=fglGtPlPornySKUmWKmYMke/+iF+4QKkQJ+kPOzmGQU=; b=QRCv6sOBgLaBq76lJf0oMrDemM9gonaFhdFdoWFX19abFkjl5HvFNgW42MMvr7bCPf VN2PHhUzUKRx9lBZqIbgmZqmq79x4Lg12Xr7Dkmhzd3+MKIlOOgOmQbSbjTC0Ves/pQh 2MnQKU0BiUclx9XIGnYmNtU23W1j1GBxkxj6tvyrbMs/nCYvcpylImIB33KxG86QqBs8 Exdk5KQPr06RBNeT3jwaSqtz6sabVAWJaLn0iPL7uImqs2PHmP1JtI3Rhb9nVYz6z/1g b8Hauzo/7Qjbrae1CYw+M4LZEYviW48paXEONJJU7ZTOGDbRe3ku27SH2dzQN+1nDoHk VNKw== X-Forwarded-Encrypted: i=1; AL+hErGPMveFlyOOwuftpqs0Em34D8N7UKhoZAsIlmSQi2bKFR3oUz20FeCLpBxuKlo5Zj0EAm39I+uK+KAxVzg=@vger.kernel.org X-Gm-Message-State: APuU4Z/RrW6tdErLvCPJr4nKpRRgE93We5sB0Ena7/0W7koIPQkriGt7 Jw3b7tj/YbX1UkU+5xokbX593nJ2TirKRDcRdmTtmaCoznWLkjO0/0Xc X-Gm-Gg: AZFdTZe5V4knGeh2dAB5Bu/O6G/FbwlMxz4BteMMe8i4e6JFNKO3NDVm40CciOR3rJ0 coOn1mRgmfhW21UxjPCadsFN7KmXI02fqJDA9Eh1DKiBuIctrhmUGHmxhyL4V+zA6nWn0dLyqa3 7ApDWmni4dVTQh5TLB7w4Cq3NcSmHIQGB9AvZmYk57cy9v9+/2EcHm4XEYm3G9BHguAGNIh18vW XI/Snh59rQiA9jecm78DmrYtY4riBx7f4Nq/yP/CI0/nLHkRfESM5PSjtRzTT4xAINgAiyTYkAr odj+B+3yhmMkZJmCt6h2nB0mMBmP42GB+JxFSW+5zgwdHbd7z0H4WmRlnwQ6+Kr52JIZD2jIZKP jkoj9gxwJGIoj9RcwcwM3RrEyx9S1Nibvl0nAiuM6O6s8o/JlKc1K2h+6DzL8mxeK02iIvaBPps hO0CSfccBToSmfVgC6L3RJ67Y77HTUZsWxR9P/j1n1lj2oxInQSbjUnej5oSK0Z1Kd3DhnB+2MP omLVq0M5fkxe8AjZqUl0jmow5OZR+mdjavRtVcV3JbFsILVSw5G2a4T/LqCg7yyvtu5zuC6kGQ8 nCxGRY0LPSoPl+8KwnQa4+WhZEHaeqXM1z5E7b2cHWBxRumu3YiSi//cNXqqm4bSt/5fzkYqr2T h X-Received: by 2002:a05:600c:828e:b0:4a2:392:9de2 with SMTP id 5b1f17b1804b1-4bbeb8ede8dmr30219875e9.28.1796383275509; Fri, 04 Dec 2026 03:21:15 -0800 (PST) Received: from [192.168.1.22] ([83.231.69.9]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4bbe00a30absm150432515e9.10.2026.12.04.03.21.11 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 04 Dec 2026 03:21:15 -0800 (PST) Message-ID: <7c01cbd8-2ed1-4445-9ac0-6bffc19acaf6@gmail.com> Date: Fri, 4 Dec 2026 12:21:11 +0100 X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2 22/35] mm/hugetlb: serialize private faults with truncation To: "David Hildenbrand (Arm)" , Muchun Song , Oscar Salvador , Andrew Morton , 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" Cc: 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 References: <20261203-hugetlb_fixes_2-v2-0-9bbeabb555d2@kernel.org> <20261203-hugetlb_fixes_2-v2-22-9bbeabb555d2@kernel.org> Content-Language: en-US From: "Jose A. Perez de Azpillaga" In-Reply-To: <20261203-hugetlb_fixes_2-v2-22-9bbeabb555d2@kernel.org> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 12/3/26 12:37 PM, David Hildenbrand (Arm) wrote: > When we fault in a folio in a MAP_PRIVATE hugetlb mapping at an index > without a page cache folio, hugetlb_no_page() checks that the index is > not beyond EOF, allocates a new anonymous folio and maps it. Truncation > first updates i_size under the invalidate lock, and then unmaps the > truncated range from all VMAs. > > For page cache folios, we recently started rechecking EOF under > filemap_invalidate_lock_shared() to handle exactly that. > > However, nothing serializes the allocation of anonymous folios with > truncation: if truncation unmaps the range after we checked EOF, but > before we mapped the new folio, the folio stays mapped beyond EOF. > > Consequently, accessing the truncated range does not raise SIGBUS, and > the process keeps the folio mapped until it unmaps it. > > Reproduced by artificially delaying hugetlb_no_page() before allocating > the folio, while another thread truncates the file: the page beyond EOF > stays mapped. > > Let's fix it by also rechecking EOF under the invalidate lock for > anonymous folios, and holding it until we mapped the folio, such that > truncation will unmap it. > > Like faults in shared mappings, faults in private mappings now briefly take > the invalidate lock in read mode, and might have to wait for a concurrent > truncation. Which seems to be the right thing to do. > > This has low urgency, as it requires racing a page fault in a private > mapping with truncation. No need to CC stable. > > Fixes: fa27759af4a6 ("hugetlb: clean up code checking for fault/truncation races") > Signed-off-by: David Hildenbrand (Arm) LGTM: Reviewed-by: Jose A. Perez de Azpillaga -- cheers, jose a. p-a