From patchwork Thu Sep 16 16:02:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 513594 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5D391C28CDB for ; Thu, 16 Sep 2021 17:44:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5389461246 for ; Thu, 16 Sep 2021 17:44:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1356119AbhIPRpK (ORCPT ); Thu, 16 Sep 2021 13:45:10 -0400 Received: from mail.kernel.org ([198.145.29.99]:57132 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1355674AbhIPRl6 (ORCPT ); Thu, 16 Sep 2021 13:41:58 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id A096563267; Thu, 16 Sep 2021 16:53:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1631811239; bh=EObLiataOvbQcj55DmyNT+KFM8W4ZbUPxC/+b6lQ3eM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nl5sRdD8n98VuDDsumBh5Z0vLe1Zef2FDlxELa7kVKDJ+Zi+Y9RCV9ZXSyn6OIFay u+30B+/HzyOlPMQlD77V9oNvWkC377xkMJ8asK+QSAaY7MPxyMqsnCnbg0XD+LVW+X zCOLrNRuBabFhaOIH5PZS7x1/UFWWRxNw2NwI30A= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Miaohe Lin , Mel Gorman , Vlastimil Babka , David Hildenbrand , Andrew Morton , Linus Torvalds Subject: [PATCH 5.14 408/432] mm/page_alloc.c: avoid accessing uninitialized pcp page migratetype Date: Thu, 16 Sep 2021 18:02:37 +0200 Message-Id: <20210916155824.677773169@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210916155810.813340753@linuxfoundation.org> References: <20210916155810.813340753@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Miaohe Lin commit 053cfda102306a3394012f9fe2594811c34925e4 upstream. If it's not prepared to free unref page, the pcp page migratetype is unset. Thus we will get rubbish from get_pcppage_migratetype() and might list_del(&page->lru) again after it's already deleted from the list leading to grumble about data corruption. Link: https://lkml.kernel.org/r/20210902115447.57050-1-linmiaohe@huawei.com Fixes: df1acc856923 ("mm/page_alloc: avoid conflating IRQs disabled with zone->lock") Signed-off-by: Miaohe Lin Acked-by: Mel Gorman Acked-by: Vlastimil Babka Reviewed-by: David Hildenbrand Cc: Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Greg Kroah-Hartman --- mm/page_alloc.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -3445,8 +3445,10 @@ void free_unref_page_list(struct list_he /* Prepare pages for freeing */ list_for_each_entry_safe(page, next, list, lru) { pfn = page_to_pfn(page); - if (!free_unref_page_prepare(page, pfn, 0)) + if (!free_unref_page_prepare(page, pfn, 0)) { list_del(&page->lru); + continue; + } /* * Free isolated pages directly to the allocator, see