Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp3008437pxm; Mon, 28 Feb 2022 10:11:21 -0800 (PST) X-Google-Smtp-Source: ABdhPJy5pCVdKX0bfSB1zJAn+4/uM4X447LSPI9U9k2RRwsupEwyiCmu/OPzxkrgef+XGGsxBkib X-Received: by 2002:a17:906:2ad3:b0:6ce:3662:8d68 with SMTP id m19-20020a1709062ad300b006ce36628d68mr16132572eje.71.1646071880655; Mon, 28 Feb 2022 10:11:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646071880; cv=none; d=google.com; s=arc-20160816; b=wyW94+T+mrDYdhlcw9u8bohrNXAoyd7LeIPGL4EMKDQCyShCtcqKh/2pKWEDsxcqD6 IamQ+l02tEagELuawegsvGlK2mW2AEJo1BsKfVVQMMKQoXwT83WgvE8mL20qmgMBOc88 Lgafkfi2Av5ihGFIP7DvGyhsHAHAVLk1tX5l4+rT2fsCz7QTtrJX0Cu8hjeTPo/XlVX4 k1SnmSY9cv+/R04E18uv2x/QTA88IMIdk1h9WCXWW8kB7pHCflbaUq348IhZahZjqEB9 rnNMu6F8Noo74pTSgI7N63Df1+Bh5I6QPPZM7CouIENNJPMNSAjweENMl+3vKwItRMkb eccA== 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 :references:in-reply-to:message-id:date:subject:cc:to:from; bh=f1dH+wSlsYbLyKmRPniboC8xF1FBjFpb3YacBKIq+5w=; b=0wfWvczi3MLJMzz5+hbQ1PWBJmQs2QZUOvmy4ozsBA9TOqiu79dESWF9/ZiOFJRj6g qone5Xnxw2XyaHxT74AkEZzj9UdWVlOTE2zc1RqFjnGFrGl+pehNQF7G74Ux+uW43wzk VRVQLFlS6mMsZq87xca/lkj5iSUF9tToRwukThdbjhpSUzySHjqwarBGgN3LfYrS8AOI B8WXWwZinBHL+RPDFB2BiyOZREsKR4VkMEen4YSBHlkYQwxuObyKxPm1+biwBm0O77OP b6vXBaCfxQodyG4tORSPmlsdAxqrwH8kBgqRfDJH8GqvtXibHXP2t2q7G2Ty390+svbE qYCw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i7-20020a1709061e4700b006b5b09a0cf8si6470889ejj.384.2022.02.28.10.10.58; Mon, 28 Feb 2022 10:11:20 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236908AbiB1OEY (ORCPT + 99 others); Mon, 28 Feb 2022 09:04:24 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42840 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232334AbiB1OEO (ORCPT ); Mon, 28 Feb 2022 09:04:14 -0500 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0B3FB49F31 for ; Mon, 28 Feb 2022 06:03:35 -0800 (PST) Received: from canpemm500002.china.huawei.com (unknown [172.30.72.56]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4K6hs526PWzdfkJ; Mon, 28 Feb 2022 22:02:17 +0800 (CST) Received: from huawei.com (10.175.124.27) by canpemm500002.china.huawei.com (7.192.104.244) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.21; Mon, 28 Feb 2022 22:03:32 +0800 From: Miaohe Lin To: , CC: , , Subject: [PATCH 4/4] mm/memory-failure.c: fix potential VM_BUG_ON_PAGE in split_huge_page_to_list Date: Mon, 28 Feb 2022 22:02:45 +0800 Message-ID: <20220228140245.24552-5-linmiaohe@huawei.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20220228140245.24552-1-linmiaohe@huawei.com> References: <20220228140245.24552-1-linmiaohe@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.175.124.27] X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) To canpemm500002.china.huawei.com (7.192.104.244) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham 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 The huge zero page could reach here and if we ever try to split it, the VM_BUG_ON_PAGE will be triggered in split_huge_page_to_list(). Also the non-lru compound movable pages could be taken for transhuge pages. Skip these pages by checking PageLRU because huge zero page isn't lru page as non-lru compound movable pages. Signed-off-by: Miaohe Lin --- mm/memory-failure.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/mm/memory-failure.c b/mm/memory-failure.c index 23bfd809dc8c..ac6492e36978 100644 --- a/mm/memory-failure.c +++ b/mm/memory-failure.c @@ -1792,6 +1792,20 @@ int memory_failure(unsigned long pfn, int flags) } if (PageTransHuge(hpage)) { + /* + * The non-lru compound movable pages could be taken for + * transhuge pages. Also huge zero page could reach here + * and if we ever try to split it, the VM_BUG_ON_PAGE will + * be triggered in split_huge_page_to_list(). Skip these + * pages by checking PageLRU because huge zero page isn't + * lru page as non-lru compound movable pages. + */ + if (!PageLRU(hpage)) { + put_page(p); + action_result(pfn, MF_MSG_UNSPLIT_THP, MF_IGNORED); + res = -EBUSY; + goto unlock_mutex; + } /* * The flag must be set after the refcount is bumped * otherwise it may race with THP split. -- 2.23.0