* [merged mm-hotfixes-stable] hugetlbfs-fix-integer-overflow-in-fallocate.patch removed from -mm tree
[not found] <20261116-fixes_hugetlb-v2-1-4dd9e94ea9ac@kernel.org>
@ 2026-11-23 6:25 ` Andrew Morton
0 siblings, 0 replies; only message in thread
From: Andrew Morton @ 2026-11-23 6:25 UTC (permalink / raw)
To: mm-commits, will, vivek.kasireddy, vbabka, svens, surenb, stable,
skhan, rppt, riel, rdunlap, peterz, peterx, osalvador, osalavador,
npiggin, nao.horiguchi, muchun.song, mhocko, mgorman, mason,
luojiajun3, ljs, linmiaohe, liam, leitao, kraxel, josef, jgg,
hughd, hca, gourry, gor, corbet, borntraeger, baolin.wang, arnd,
apw, aneesh.kumar, airlied, agordeev, ackerleytng, 4ncienth,
david, akpm
The quilt patch titled
Subject: hugetlbfs: fix integer overflow in fallocate()
has been removed from the -mm tree. Its filename was
hugetlbfs-fix-integer-overflow-in-fallocate.patch
This patch was dropped because it was merged into the mm-hotfixes-stable branch
of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
------------------------------------------------------
From: "David Hildenbrand (Arm)" <david@kernel.org>
Subject: hugetlbfs: fix integer overflow in fallocate()
Date: Mon, 16 Nov 2026 19:29:22 +0100
hugetlbfs_fallocate() rounds the range end up by adding hpage_size - 1
to offset + len. vfs_fallocate()'s existing overflow check only makes
sure that offset + len does not overflow.
Once we overflow for valid endpoints near LLONG_MAX, we can get a
negative temporary result that is then converted to a very large
huge page index.
A one-byte allocation ending at LLONG_MAX can therefore consume all
available huge pages. Pages added beyond LLONG_MAX are skipped during
inode eviction, leaking them and triggering the BUG_ON() in clear_inode().
To fix it, calculate the end index in a simpler way that cannot
overflow. This also fixes the signed overflow reported by luojiajun in
2019.
Backporting notes: without commit a08c7193e4f18 ("mm/filemap: remove
hugetlb special casing in filemap.c"), remove_inode_hugepages() must
include the final huge page during truncate and eviction.
Link: https://lore.kernel.org/20261116-fixes_hugetlb-v2-0-4dd9e94ea9ac@kernel.org
Link: https://patch.msgid.link/20261116-fixes_hugetlb-v2-1-4dd9e94ea9ac@kernel.org
Fixes: 70c3547e36f5 ("hugetlbfs: add hugetlbfs_fallocate()")
Signed-off-by: David Hildenbrand (Arm) <david@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Reported-by: luojiajun <luojiajun3@huawei.com>
Closes: https://lore.kernel.org/all/1554775226-67213-1-git-send-email-luojiajun3@huawei.com/
Reported-by: Josef Bacik <josef@toxicpanda.com>
Acked-by: Muchun Song <muchun.song@linux.dev>
Reviewed-by: Ackerley Tng <ackerleytng@google.com>
Tested-by: Gregory Price (Meta) <gourry@gourry.net>
Link: https://lore.kernel.org/20261116-fixes_hugetlb-v2-1-4dd9e94ea9ac@kernel.org
Reviewed-by: Gregory Price (Meta) <gourry@gourry.net>
Acked-by: Oscar Salvador <osalvador@suse.de>
Cc: Naoya Horiguchi <nao.horiguchi@gmail.com>
Cc: Mel Gorman <mgorman@suse.de>
Cc: Andy Whitcroft <apw@canonical.com>
Cc: Miaohe Lin <linmiaohe@huawei.com>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Rik van Riel <riel@surriel.com>
Cc: Hugh Dickins <hughd@google.com>
Cc: Baolin Wang <baolin.wang@linux.alibaba.com>
Cc: Vivek Kasireddy <vivek.kasireddy@intel.com>
Cc: Dave Airlie <airlied@redhat.com>
Cc: Jason Gunthorpe <jgg@ziepe.ca>
Cc: Lorenzo Stoakes <ljs@kernel.org>
Cc: Liam R. Howlett <liam@infradead.org>
Cc: Vlastimil Babka <vbabka@kernel.org>
Cc: Mike Rapoport <rppt@kernel.org>
Cc: Suren Baghdasaryan <surenb@google.com>
Cc: Jonathan Corbet <corbet@lwn.net>
Cc: Shuah Khan <skhan@linuxfoundation.org>
Cc: Randy Dunlap <rdunlap@infradead.org>
Cc: Peter Xu <peterx@redhat.com>
Cc: Breno Leitao <leitao@debian.org>
Cc: Will Deacon <will@kernel.org>
Cc: Aneesh Kumar K.V <aneesh.kumar@kernel.org>
Cc: Nicholas Piggin <npiggin@gmail.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Heiko Carstens <hca@linux.ibm.com>
Cc: Vasily Gorbik <gor@linux.ibm.com>
Cc: Alexander Gordeev <agordeev@linux.ibm.com>
Cc: Christian Borntraeger <borntraeger@linux.ibm.com>
Cc: Sven Schnelle <svens@linux.ibm.com>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Cc: Chris Mason <mason@kernel.org>
Cc: Daehyeon Ko <4ncienth@gmail.com>
Cc: Oscar Salvador <osalavador@suse.de>
Cc: <stable@vger.kernel.org>
fs/hugetlbfs/inode.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
--- a/fs/hugetlbfs/inode.c~hugetlbfs-fix-integer-overflow-in-fallocate
+++ a/fs/hugetlbfs/inode.c
@@ -722,11 +722,13 @@ static long hugetlbfs_fallocate(struct f
/*
* Default preallocate case.
- * For this range, start is rounded down and end is rounded up
- * as well as being converted to page offsets.
+ * vfs_fallocate() guarantees that offset + len is positive and does
+ * not overflow. Avoid overflows when calculating the end huge page
+ * index: set it to one past the index of the huge page containing the
+ * last byte.
*/
start = offset >> hpage_shift;
- end = (offset + len + hpage_size - 1) >> hpage_shift;
+ end = ((offset + len - 1) >> hpage_shift) + 1;
inode_lock(inode);
_
Patches currently in -mm which might be from david@kernel.org are
mm-mprotect-dont-skip-uffd-marker-install-when-racing-with-pte-table-reclaim.patch
mm-khugepaged-free-unused-page-table-when-setting-a-huge-pmd-fails.patch
mm-userfaultfd-prevent-poison-marker-loss.patch
mm-hugetlb-compare-against-persistent-count-when-freeing-lowmem-folios.patch
mm-hugetlb-preserve-reservations-when-shrinking-on-highmem.patch
mm-hugetlb-account-temporary-folios-separately.patch
mm-hugetlb-account-temporary-folios-separately-fix.patch
mm-hugetlb-serialize-page-cache-allocations-with-truncation.patch
mm-memfd-recheck-the-page-cache-before-allocating-a-hugetlb-folio.patch
mm-hugetlb-count-again-if-the-reserve-map-shrank.patch
mm-hugetlb-account-restored-reservations-before-freeing-folios.patch
mm-hugetlb-delay-anon-folio-rmap-removal-until-after-the-tlb-flush.patch
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2026-11-23 6:25 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <20261116-fixes_hugetlb-v2-1-4dd9e94ea9ac@kernel.org>
2026-11-23 6:25 ` [merged mm-hotfixes-stable] hugetlbfs-fix-integer-overflow-in-fallocate.patch removed from -mm tree Andrew Morton
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox