Skip to content

Commit da6a789

Browse files
committed
mm/compaction: fix UBSAN shift-out-of-bounds warning
commit d1366e7 Author: Liu Shixin <[email protected]> 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/[email protected] Fixes: 3da0272 ("mm/compaction: correctly return failure with bogus compound_order in strict mode") Signed-off-by: Liu Shixin <[email protected]> Reviewed-by: Kemeng Shi <[email protected]> Acked-by: David Hildenbrand <[email protected]> Reviewed-by: Oscar Salvador <[email protected]> Cc: Baolin Wang <[email protected]> Cc: David Hildenbrand <[email protected]> Cc: Kemeng Shi <[email protected]> Cc: Matthew Wilcox <[email protected]> Cc: Mel Gorman <[email protected]> Cc: Nanyong Sun <[email protected]> Cc: <[email protected]> Signed-off-by: Andrew Morton <[email protected]> CVE: CVE-2025-21815 JIRA: https://issues.redhat.com/browse/RHEL-77742 Signed-off-by: Nico Pache <[email protected]>
1 parent 1a5b6f1 commit da6a789

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
@@ -630,7 +630,8 @@ static unsigned long isolate_freepages_block(struct compact_control *cc,
630630
if (PageCompound(page)) {
631631
const unsigned int order = compound_order(page);
632632

633-
if (blockpfn + (1UL << order) <= end_pfn) {
633+
if ((order <= MAX_PAGE_ORDER) &&
634+
(blockpfn + (1UL << order) <= end_pfn)) {
634635
blockpfn += (1UL << order) - 1;
635636
page += (1UL << order) - 1;
636637
nr_scanned += (1UL << order) - 1;

0 commit comments

Comments
 (0)