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=1796007156; b=QDEoVaPwljQdDb7MHQqKROtcav3Upo2kBfGixY8xI+/e9NK8sj98yonUNAa2n+rnmhEf mEPlQ/U5ijVwpQfYTqX7ryhC7w54gqb0l/JmzcYiI11t8cL9DtQD1uRrSIUwfCBpTBOYF cl3Ftdgwk42RbmOe/uB6whfneysZxPSUamtzUthQ8ShppGLUYjRFbl6jgZprnH+t7pwHP ZU1KPRED1x09p7vf0IqjO+/EV8TuVzJ3S3DqNQtdYfRFHorjsxM30oky6aw2dzV46O2Iu bdZMNTpSDU+HjGrM0WYBIloilaexdyDUJjXseUgZqbO3WPLxGjaxHvqJyLRw2606jdQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796007156; h=Received:DKIM-Signature:Date:To:From:In-Reply-To:References:Subject: Message-Id; bh=x/wI1mogXdRNt7ULhTP/sp6tv9/zGuQ/pztNoGCHq7M=; b=Odadb2CF+23g8yyB90eFwm08dAJLHqnLzqpaIzAwYieZVghJPJKgnq3wVXTjjF3WzEiR hGYQ9I53LpcGB68ExD2i80Zh+hq72GoIkslmo1lCPKXkseexVzuwL0GkC35L6TjXCQuC1 swJrdZpeQFqA3T86hfFMLVtt97nlYYcG/wCoBCy/9yNsuqczK2pWK091uzK+CtXWpuQkt +tCHs2FHcrQa1PKlCupOA7K8TNL8Fp2Gjlnv7AlS6mm/sDkHBcFWelZnpjAbRbX022zxH R3lSl3hRpYBx/Se/WKDoA3691/yZkGiBHoZjebqT1mas4t2HW015RGti9bpYFauNA5g== 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=2nMDLDxl; 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 CC31B606A31C for ; Mon, 30 Nov 2026 02:52:36 +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=2nMDLDxl Received: by smtp.kernel.org (Postfix) with ESMTPSA id 95C431F00896; Mon, 30 Nov 2026 02:52:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=korg; t=1796007156; bh=x/wI1mogXdRNt7ULhTP/sp6tv9/zGuQ/pztNoGCHq7M=; h=Date:To:From:In-Reply-To:References:Subject; b=2nMDLDxldzfDUKZIKjwaUlaU1rcyK/X0gHeUAfE2lPtZZ+3FicQ9HzC3yR1nWr1Jr YMCJuLIudvVU7822tUtxR5AkxO7p0muFpfKoiHvsaL5aMQYOdpEVW57ZJjt8tu5FP/ GSZAORxufVrvXhYS2kWLhpFtvXFPBZpPH3dgiA4c= Date: Sun, 29 Nov 2026 18:52:36 -0800 To: mm-commits@vger.kernel.org,mason@kernel.org,akpm@linux-foundation.org From: Andrew Morton In-Reply-To: <20261125-hugetlb_fixes_2-v1-17-db27fd2f71a8@kernel.org> References: <20261125-hugetlb_fixes_2-v1-17-db27fd2f71a8@kernel.org> Subject: + hugetlbfs-seal-shm_hugetlb-files-against-growth.patch added to mm-new branch Message-Id: <20261130025236.95C431F00896@smtp.kernel.org> X-Mailing-List: mm-commits@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list The patch titled Subject: hugetlbfs: seal SHM_HUGETLB files against growth has been added to the -mm mm-new branch. Its filename is hugetlbfs-seal-shm_hugetlb-files-against-growth.patch This patch will shortly appear at https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/hugetlbfs-seal-shm_hugetlb-files-against-growth.patch This patch will later appear in the mm-new branch at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm Note, mm-new is a provisional staging ground for work-in-progress patches, and acceptance into mm-new is a notification for others take notice and to finish up reviews. Please do not hesitate to respond to review feedback and post updated versions to replace or incrementally fixup patches in mm-new. The mm-new branch of mm.git is not included in linux-next If a few days of testing in mm-new is successful, the patch will me moved into mm.git's mm-unstable branch, which is included in linux-next Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/process/submit-checklist.rst when testing your code *** The -mm tree is included into linux-next via various branches at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm and is updated there most days ------------------------------------------------------ From: Chris Mason Subject: hugetlbfs: seal SHM_HUGETLB files against growth Date: Wed, 25 Nov 2026 23:33:15 +0100 The size of a SysV shared memory segment is fixed at shmget(), and do_shmat() relies on that by mapping i_size bytes of the backing file. However, with SHM_HUGETLB, the hugetlbfs file can be grown through an fd obtained from /proc//map_files with ftruncate() or fallocate(). Also, remap_file_pages() with a pgoff beyond the segment can grow it, because hugetlbfs_file_mmap() grows the file to the end of a writable mapping: shmget(key, 4M, SHM_HUGETLB) i_size = 4M addr = shmat(id, NULL, 0) remap_file_pages(addr, 2M, 0, 6M >> PAGE_SHIFT, 0) i_size = 8M shmat(id, NULL, 0) maps 8M Later calls to shmat() will map the bigger size. Using /proc//map_files requires CAP_CHECKPOINT_RESTORE, but remap_file_pages() does not require any privileges, so we focus on the latter. Let's fix it by setting F_SEAL_GROW on the inode when creating it for a segment. remap_file_pages() beyond the segment still succeeds, like for shmem segments, but accessing pages there now correctly results in SIGBUS. This has low urgency, and likely nobody ever ran into this in practice. Let's not CC stable. [david@kernel.org: adjust description] Link: https://patch.msgid.link/20261125-hugetlb_fixes_2-v1-17-db27fd2f71a8@kernel.org Fixes: c8d78c1823f4 ("mm: replace remap_file_pages() syscall with emulation") Signed-off-by: Chris Mason Signed-off-by: David Hildenbrand (Arm) Signed-off-by: Andrew Morton Cc: Muchun Song Cc: Oscar Salvador Cc: Jinmeng Zhou Cc: Hongfu Li Cc: Andrea Arcangeli Cc: Mike Kravetz Cc: Naoya Horiguchi Cc: Hugh Dickins Cc: Baolin Wang Cc: Dave Airlie Cc: Vivek Kasireddy Cc: Gerd Hoffmann Cc: Mike Rapoport Cc: Mel Gorman Cc: Dave McCracken Cc: Andy Whitcroft Cc: Adam Litke Cc: Lorenzo Stoakes Cc: Rik van Riel Cc: Liam R. Howlett Cc: Vlastimil Babka Cc: Harry Yoo Cc: Jann Horn Cc: Lance Yang Cc: James Houghton Cc: Yang Shi Cc: Suren Baghdasaryan Cc: Shakeel Butt Cc: Pedro Falcato Cc: Gregory Price Cc: Zi Yan Cc: Joshua Hahn Cc: Rakie Kim Cc: Ying Huang Cc: Matthew Brost Cc: Byungchul Park Cc: Alistair Popple Cc: Wanpeng Li Cc: Andi Kleen Cc: Kenneth W Chen Cc: Michal Hocko Cc: David Rientjes Cc: Joern Engel Cc: Jonathan Corbet Cc: Shuah Khan Cc: Randy Dunlap Cc: Aneesh Kumar K.V Cc: KAMEZAWA Hiroyuki Cc: Kiryl Shutsemau Cc: Sasha Levin Cc: Guillaume Morin Cc: Wanpeng Li Cc: Jason Gunthorpe Cc: luojiajun Cc: Josef Bacik Cc: Daehyeon Ko <4ncienth@gmail.com> Cc: Ackerley Tng Cc: "Oscar Salvador (SUSE)" Cc: Jiaqi Yan fs/hugetlbfs/inode.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) --- a/fs/hugetlbfs/inode.c~hugetlbfs-seal-shm_hugetlb-files-against-growth +++ a/fs/hugetlbfs/inode.c @@ -1559,8 +1559,11 @@ struct file *hugetlb_file_setup(const ch S_IFREG | S_IRWXUGO, 0); if (!inode) goto out; - if (creat_flags == HUGETLB_SHMFS_INODE) + if (creat_flags == HUGETLB_SHMFS_INODE) { inode->i_flags |= S_PRIVATE; + /* The size of a segment is fixed at shmget(). */ + HUGETLBFS_I(inode)->seals |= F_SEAL_GROW; + } inode->i_size = size; clear_nlink(inode); _ Patches currently in -mm which might be from mason@kernel.org are mm-swap-fix-large-swap-in-across-swap-file-extents.patch hugetlbfs-do-not-grow-a-sealed-file-in-mmap.patch mm-hugetlb-keep-surplus-folios-that-are-reserved.patch mm-hugetlb-fix-reservation-leak-on-min_size=-mounts.patch mm-cachestat-count-each-page-only-once.patch mm-cachestat-restart-the-walk-after-each-entry.patch percpu-queue-the-balance-work-on-an-unbound-workqueue.patch mm-vma-fix-uncharge-after-failed-stack-relocation.patch mm-mremap-apply-the-mmap-offset-limits-on-expansion.patch mm-mremap-respect-guard-gaps-on-in-place-expansion.patch mm-vma-make-brk-mappings-non-executable-under-mdwe.patch mm-hmm-refuse-secretmem-vmas-in-hmm_range_fault.patch mm-mglru-count-all-generations-as-evictable.patch mm-mglru-test-pg_lru-before-taking-a-folio-reference.patch mm-mglru-report-root-reclaim-to-memorypressure_level.patch kfence-use-a-nofault-store-to-zero-the-guard-page.patch mm-hugetlb-fix-truncated-copy-result-in-uffdio_copy.patch hugetlbfs-fix-deadlock-between-hole-punching-and-memory-failure.patch hugetlbfs-recheck-the-vma-range-after-the-lock-wait.patch mm-hugetlb-dont-zap-non-present-entries-when-unmapping-a-folio.patch mm-hugetlb-unshare-pmds-of-a-split-vma-if-allocating-its-lock-fails.patch mm-hugetlb_cgroup-track-in-use-folios-per-cgroup.patch hugetlbfs-seal-shm_hugetlb-files-against-growth.patch mm-hugetlb-resolve-protnone-faults-without-a-uffd-bit.patch