Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp14271pxb; Wed, 30 Mar 2022 21:29:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwMVdxaKW5o4aiUtdhA5juQ3lX7/njAeltGnWw2Z10atXJvKbmJWYbueIpiEcIGLZveaOzY X-Received: by 2002:a17:90a:638b:b0:1ca:1a28:ae4b with SMTP id f11-20020a17090a638b00b001ca1a28ae4bmr1462250pjj.12.1648700941591; Wed, 30 Mar 2022 21:29:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648700941; cv=none; d=google.com; s=arc-20160816; b=jQJAmbu59o35RP6qspDPrO5Gh9rzXsoR/kzXgiekKqXLMXFqVvFLD8wMpKMrpMLw/8 LlKig/Swt+c4FuSbnwyq4QIZwJCyOolO2OqeEuqHy/5NINLFeQiXvUUU31Yuu8HjpcrO pt6D5sCcVUfD3IePFX8XH2o5hP0p0eVFdjWJXEwkfQQ8pKln21gKPGZ78uHNfgHeW6FM 1fXcXxHsvfio4brGbe+f78BmzIgGN1oSab6mNZ3BOyQmae0px5OCCXoqMcaNdGQzfwRL OZMTF6d6kz9UIiajQI2vZ72l2ISxWQeVME/0GPchedkEW/241VF/kbywY1px4vIk7znF k/0g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version:reply-to :message-id:date:subject:cc:to:from:dkim-signature:dkim-signature; bh=VafuHBoZUzeSxeYTXUmAINKRMraZTcsVMF+kik9kRS8=; b=M6+T2GGJj+AyRfG3GBjCFQSXS/nCAhkWNcWVp/E0JF7OO+gp7SUJTo5JREloQ8OFvY qS+0BYpfX5w9tEJAth40cAJ/P9Ma7krF0pgqHJAeHBZdtL/M6lgehqnd+y4DfPBfZPOH vJiqgDFU/b191EmKhhCck3CAjN45UyyV9/tSkzxzs9artaRioK5zc18cLXAX+QnBGoqC gp9wF/9xZ9QSjH324hAzri17PLnXWnijhNNYqJIc4hxUjhRhJUybdXC+n6rkDG0/EskY 7Js3OEM0VwJ3xlzs5yMYNK7fE4V4k5ZMJNzFJ55lP8rLn3C+sHZCXQRNURNS8RFyrTFB QvJw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sent.com header.s=fm3 header.b=D48d5msT; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b=i85FOJef; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=sent.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id z2-20020a17090acb0200b001bf5531ee72si1981313pjt.15.2022.03.30.21.29.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 30 Mar 2022 21:29:01 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@sent.com header.s=fm3 header.b=D48d5msT; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b=i85FOJef; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=sent.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 489011DE5B8; Wed, 30 Mar 2022 20:25:41 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1351477AbiC3WOm (ORCPT + 99 others); Wed, 30 Mar 2022 18:14:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34032 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1351475AbiC3WOl (ORCPT ); Wed, 30 Mar 2022 18:14:41 -0400 Received: from wout1-smtp.messagingengine.com (wout1-smtp.messagingengine.com [64.147.123.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9A209427FD for ; Wed, 30 Mar 2022 15:12:55 -0700 (PDT) Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailout.west.internal (Postfix) with ESMTP id AB3A23200D98; Wed, 30 Mar 2022 18:12:52 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute2.internal (MEProxy); Wed, 30 Mar 2022 18:12:53 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sent.com; h=cc :cc:content-transfer-encoding:date:date:from:from:in-reply-to :message-id:mime-version:reply-to:reply-to:sender:subject :subject:to:to; s=fm3; bh=VafuHBoZUzeSxeYTXUmAINKRMraZTcsVMF+kik 9kRS8=; b=D48d5msTfHW2+sZdc2uTI4B2sz6GNQT1thu8W6z0+/qRf/SlHg/t7f se1yGjjdHLGvpCRO1s00lt9/UtUODmENcVimzrg2oEbW8unmhZHbQga+UEQHtqKm dOLFquqqulEpBA33ByjSKPL3JVGBTQ5dQqIiYxd1/ajWvxsC7WRMJk4Txc/Niv10 a0tKF0pV3tZrhailrjmg9NpOAho95yeCk8kuMZT0kBBxKLmxunehb/Zkd8s61w5c YWNc+BhBaW7QrKLwmzzg2bUezDo1UUPJoQvh48CbDt68MjMsni5LRHz8Z3t4+Li4 NzmKf8GAM4xK7/xIB3QFgZia/TdzDxsA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding:date:date :from:from:in-reply-to:message-id:mime-version:reply-to:reply-to :sender:subject:subject:to:to:x-me-proxy:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm3; bh=VafuHBoZUzeSxeYTXUmAINKRMraZT csVMF+kik9kRS8=; b=i85FOJef4YHfcyIo37PzgfhHuMaNe1MmPiroCz/ADhnFI gLsFQUpkOkaDwksKTYTMQv4BuGydKSbdPjH9hqp7pFIOKms1bxcC7oG6Qed+OeMZ Tpqhlb4RLHIV6kEju2K+Ug7HK+wsxLvVbjLXmnTvqrD9Co2qoKCrSOvgTgvsPF7b C4zpkhoCYq543FsB6lNDXsatm+cqJiil8xk+MJF5qYMLomgIiS/e9EWfdRdxs55q nWksVR/Wli38Jq56r5aSeVEGPlGcQfBwKShCeqZIHuWqGSaKrN5uebTxuAcQjXgL gULoKf3aTd3bII3Ya4OitzU4Ge7L5ay/+Y1x1hOyA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvvddrudeifedgtddvucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvufffkfforhgggfestdhqredtredttdenucfhrhhomhepkghiucgjrghn uceoiihirdihrghnsehsvghnthdrtghomheqnecuggftrfgrthhtvghrnhepleetvddtvd dttdetffdvkeehffdtjefhkedtheffjeehvdejueektedukedufeffnecuvehluhhsthgv rhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepiihirdihrghnsehsvghnth drtghomh X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 30 Mar 2022 18:12:51 -0400 (EDT) From: Zi Yan To: Linus Torvalds , Steven Rostedt Cc: David Hildenbrand , Vlastimil Babka , Mel Gorman , Mike Rapoport , Oscar Salvador , Andrew Morton , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Zi Yan Subject: [PATCH] mm: page_alloc: validate buddy before check its migratetype. Date: Wed, 30 Mar 2022 18:12:38 -0400 Message-Id: <20220330221238.396357-1-zi.yan@sent.com> X-Mailer: git-send-email 2.35.1 Reply-To: Zi Yan MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Zi Yan Whenever a buddy page is found, page_is_buddy() should be called to check its validity. Add the missing check during pageblock merge check. Fixes: 1dd214b8f21c ("mm: page_alloc: avoid merging non-fallbackable pagebl= ocks with others") Reported-by: Steven Rostedt Signed-off-by: Zi Yan --- mm/page_alloc.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/mm/page_alloc.c b/mm/page_alloc.c index bdc8f60ae462..6c6af8658775 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -1108,6 +1108,9 @@ static inline void __free_one_page(struct page *page, =20 buddy_pfn =3D __find_buddy_pfn(pfn, order); buddy =3D page + (buddy_pfn - pfn); + + if (!page_is_buddy(page, buddy, order)) + goto done_merging; buddy_mt =3D get_pageblock_migratetype(buddy); =20 if (migratetype !=3D buddy_mt --=20 2.35.1