From nobody Sun Feb 8 23:27:43 2026 Received: from szxga07-in.huawei.com (szxga07-in.huawei.com [45.249.212.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 253DF182D0 for ; Thu, 23 Jan 2025 02:16:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.35 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737598580; cv=none; b=Q3kH93xkCBGshK8XhJnOPztATONFYcYYdul3LYB5PqbzSxQPYjPnu8lFKNmnUgrxSFkzyycFy4DVwi4HwM1xXnZ1PBCA5czglzvv302f5icQ6ZU+fgQ9NwsJIbcHKg90yavbyJ65UdyTxUjSZ7BnXaT5hu+ctJhK0qhOqfWx8Tc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737598580; c=relaxed/simple; bh=vJEGy3UXhia8hMtDK4XSgFU+winEWqB18+P1WEstHKg=; h=From:To:CC:Subject:Date:Message-ID:MIME-Version:Content-Type; b=cROWbWNKTwNATalOjGAiEHeyAvuW7+cfzxdxY3brY3syc91ZhWFc/XjQgnh/nf7/vB0Pi46cUOjDzi3cnJPOOitZZLaKJ44jE9ifhayDRMiL7qoXwhmHGc9PENDd8mQutSxRNdxyCE1RxdEcWhnUbiEHT0955ZMDrP4Ht5Zq74Q= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; arc=none smtp.client-ip=45.249.212.35 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Received: from mail.maildlp.com (unknown [172.19.88.214]) by szxga07-in.huawei.com (SkyGuard) with ESMTP id 4Ydkwz182gz1V5Qy; Thu, 23 Jan 2025 10:12:35 +0800 (CST) Received: from kwepemg200013.china.huawei.com (unknown [7.202.181.64]) by mail.maildlp.com (Postfix) with ESMTPS id BA6921A016C; Thu, 23 Jan 2025 10:15:55 +0800 (CST) Received: from huawei.com (10.175.113.32) by kwepemg200013.china.huawei.com (7.202.181.64) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Thu, 23 Jan 2025 10:15:54 +0800 From: Liu Shixin To: Andrew Morton , Kefeng Wang , Kemeng Shi , Baolin Wang , Mel Gorman , David Hildenbrand , Matthew Wilcox , Nanyong Sun CC: , , Liu Shixin Subject: [PATCH] mm/compaction: fix UBSAN shift-out-of-bounds warning Date: Thu, 23 Jan 2025 10:10:29 +0800 Message-ID: <20250123021029.2826736-1-liushixin2@huawei.com> X-Mailer: git-send-email 2.34.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) To kwepemg200013.china.huawei.com (7.202.181.64) Content-Type: text/plain; charset="utf-8" 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 co= mpound_order in strict mode") Signed-off-by: Liu Shixin Acked-by: David Hildenbrand Reviewed-by: Baolin Wang Reviewed-by: Kemeng Shi Reviewed-by: Oscar Salvador --- 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 com= pact_control *cc, if (PageCompound(page)) { const unsigned int order =3D compound_order(page); =20 - if (blockpfn + (1UL << order) <=3D end_pfn) { + if ((order <=3D MAX_PAGE_ORDER) && + (blockpfn + (1UL << order) <=3D end_pfn)) { blockpfn +=3D (1UL << order) - 1; page +=3D (1UL << order) - 1; nr_scanned +=3D (1UL << order) - 1; --=20 2.34.1