[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250123021029.2826736-1-liushixin2@huawei.com>
Date: Thu, 23 Jan 2025 10:10:29 +0800
From: Liu Shixin <liushixin2@...wei.com>
To: Andrew Morton <akpm@...ux-foundation.org>, Kefeng Wang
<wangkefeng.wang@...wei.com>, Kemeng Shi <shikemeng@...weicloud.com>, Baolin
Wang <baolin.wang@...ux.alibaba.com>, Mel Gorman
<mgorman@...hsingularity.net>, David Hildenbrand <david@...hat.com>, Matthew
Wilcox <willy@...radead.org>, Nanyong Sun <sunnanyong@...wei.com>
CC: <linux-mm@...ck.org>, <linux-kernel@...r.kernel.org>, Liu Shixin
<liushixin2@...wei.com>
Subject: [PATCH] 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.
Fixes: 3da0272a4c7d ("mm/compaction: correctly return failure with bogus compound_order in strict mode")
Signed-off-by: Liu Shixin <liushixin2@...wei.com>
---
mm/compaction.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/mm/compaction.c b/mm/compaction.c
index a2b16b08cbbff..384e4672998e5 100644
--- a/mm/compaction.c
+++ b/mm/compaction.c
@@ -630,7 +630,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;
--
2.34.1
Powered by blists - more mailing lists