Skip to content

Commit d7c46ee

Browse files
author
Rafael Aquini
committed
mm/compaction: fix UBSAN shift-out-of-bounds warning
JIRA: https://issues.redhat.com/browse/RHEL-84184 CVE: CVE-2025-21815 This patch is a backport of the following upstream commit: commit d1366e7 Author: Liu Shixin <liushixin2@huawei.com> Date: Thu Jan 23 10:10:29 2025 +0800 mm/compaction: fix UBSAN shift-out-of-bounds warning syzkaller reported a UBSAN shift-out-of-bounds warning of (1UL << order) in isolate_freepages_block(). The bogus compound_order can be any value because it is union with flags. Add back the MAX_PAGE_ORDER check to fix the warning. Link: https://lkml.kernel.org/r/20250123021029.2826736-1-liushixin2@huawei.com Fixes: 3da0272 ("mm/compaction: correctly return failure with bogus compound_order in strict mode") Signed-off-by: Liu Shixin <liushixin2@huawei.com> Reviewed-by: Kemeng Shi <shikemeng@huaweicloud.com> Acked-by: David Hildenbrand <david@redhat.com> Reviewed-by: Oscar Salvador <osalvador@suse.de> Cc: Baolin Wang <baolin.wang@linux.alibaba.com> Cc: David Hildenbrand <david@redhat.com> Cc: Kemeng Shi <shikemeng@huaweicloud.com> Cc: Matthew Wilcox <willy@infradead.org> Cc: Mel Gorman <mgorman@techsingularity.net> Cc: Nanyong Sun <sunnanyong@huawei.com> Cc: <stable@vger.kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Rafael Aquini <raquini@redhat.com>
1 parent 683fe65 commit d7c46ee

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

mm/compaction.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -625,7 +625,8 @@ static unsigned long isolate_freepages_block(struct compact_control *cc,
625625
if (PageCompound(page)) {
626626
const unsigned int order = compound_order(page);
627627

628-
if (blockpfn + (1UL << order) <= end_pfn) {
628+
if ((order <= MAX_PAGE_ORDER) &&
629+
(blockpfn + (1UL << order) <= end_pfn)) {
629630
blockpfn += (1UL << order) - 1;
630631
page += (1UL << order) - 1;
631632
nr_scanned += (1UL << order) - 1;

0 commit comments

Comments
 (0)