aboutsummaryrefslogtreecommitdiffstats
path: root/mm/compaction.c
diff options
context:
space:
mode:
authorLiu Shixin <[email protected]>2025-01-23 02:10:29 +0000
committerAndrew Morton <[email protected]>2025-01-26 04:42:30 +0000
commitd1366e74342e75555af2648a2964deb2d5c92200 (patch)
tree4f61c69609b06ec356bbdadca947855d198942fe /mm/compaction.c
parents390/mm: add missing ctor/dtor on page table upgrade (diff)
downloadkernel-d1366e74342e75555af2648a2964deb2d5c92200.tar.gz
kernel-d1366e74342e75555af2648a2964deb2d5c92200.zip
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: 3da0272a4c7d ("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]>
Diffstat (limited to 'mm/compaction.c')
-rw-r--r--mm/compaction.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/mm/compaction.c b/mm/compaction.c
index 07bd22789f07..0f49f060d251 100644
--- a/mm/compaction.c
+++ b/mm/compaction.c
@@ -631,7 +631,8 @@ static unsigned long isolate_freepages_block(struct compact_control *cc,
if (PageCompound(page)) {
const unsigned int order = compound_order(page);
- if (blockpfn + (1UL << order) <= end_pfn) {
+ if ((order <= MAX_PAGE_ORDER) &&
+ (blockpfn + (1UL << order) <= end_pfn)) {
blockpfn += (1UL << order) - 1;
page += (1UL << order) - 1;
nr_scanned += (1UL << order) - 1;