From patchwork Fri Jan 26 06:58:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miaohe Lin X-Patchwork-Id: 13532145 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id DC9E7C47422 for ; Fri, 26 Jan 2024 06:59:08 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 572886B00C5; Fri, 26 Jan 2024 01:59:08 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 4FB336B00C6; Fri, 26 Jan 2024 01:59:08 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3C24B6B00C7; Fri, 26 Jan 2024 01:59:08 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 29C7C6B00C5 for ; Fri, 26 Jan 2024 01:59:08 -0500 (EST) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id F046A1C0EEE for ; Fri, 26 Jan 2024 06:59:07 +0000 (UTC) X-FDA: 81720560334.14.B5F0767 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by imf21.hostedemail.com (Postfix) with ESMTP id 2DD1D1C0015 for ; Fri, 26 Jan 2024 06:59:03 +0000 (UTC) Authentication-Results: imf21.hostedemail.com; dkim=none; spf=pass (imf21.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.187 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1706252345; a=rsa-sha256; cv=none; b=0ES0tnAiPIxw3JbWFcqyQKPxwqi5nMp9Z9TkxTdIFmCXNi2RboJSTiUuUvQPwax/ydS89S BAPNrB+Bap7MXFpGhH3O/pV4VSWKFvmG7SmYdolsVuxy7YbP97dvYs/+cX6r1UXxMMn2KQ Ffe6B1U8WecbbM61TUqp5FJihaxr8wg= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=none; spf=pass (imf21.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.187 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1706252345; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:in-reply-to: references; bh=CSZzl75EYZ8BzGvUXmYjbybEoQUwyfa4Q1vCeXhzk54=; b=z8kNIemcgXuiIRd5O97gQaxu2RYifEmpIu3Y43EvLgswlw7tvYNAQTuB26s5bYfVVwxH8/ X6Y6LvyawfJ8XWycbTQbf96W9zn5sEPVMZsvtjCXoSxA/I0pxm/ptbPGxqzyqCW+KDx6c2 vEjiclsl1JUnIWZTuxqShFLWBtPfrGk= Received: from mail.maildlp.com (unknown [172.19.163.252]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4TLpR65n7mzvVLj; Fri, 26 Jan 2024 14:57:22 +0800 (CST) Received: from canpemm500002.china.huawei.com (unknown [7.192.104.244]) by mail.maildlp.com (Postfix) with ESMTPS id 05F6618006D; Fri, 26 Jan 2024 14:58:57 +0800 (CST) Received: from huawei.com (10.173.135.154) 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.2507.35; Fri, 26 Jan 2024 14:58:56 +0800 From: Miaohe Lin To: , , CC: , , Subject: [PATCH v3] mm/memory-failure: fix crash in split_huge_page_to_list from soft_offline_page Date: Fri, 26 Jan 2024 14:58:37 +0800 Message-ID: <20240126065837.2100184-1-linmiaohe@huawei.com> X-Mailer: git-send-email 2.33.0 MIME-Version: 1.0 X-Originating-IP: [10.173.135.154] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To canpemm500002.china.huawei.com (7.192.104.244) X-Rspam-User: X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 2DD1D1C0015 X-Stat-Signature: cx99scgdukfpssogpdmnbxk8mf4s6twu X-HE-Tag: 1706252343-553604 X-HE-Meta: U2FsdGVkX19Y3g/VAwLwsFN90QoeYOzWyHof1SoZ0hNI6HemwIQKSqJoPkXaEQC4EfkFdl6uUa2fYhCBqy7F0DqzdZ7loUfTMd8vEDFSwoL4b1FVV7okasa8p5Kn7A1U3GNw0WL4Sd2IzLOTPE1X3smrcuubxaFxG6qFWmqyO9Bt+WkI+YsAWXRZkt6Ixjen+n66F5hkRfSWZuSKe6pRWmFz7+k1SjVeX/6KPKjD2moBSFafcIUqBcsMQAmhdIdqENpMiFaPL+d0DQa8a7jJ+UZoDRHEBz/Irb77J6UIJP+2uHect5FCh/T4q11kQxDmLq9AMpXc/deFpuumcAIUZiFHoUIO0hNHXGSBPvx0BjcKlU1NJCWK6ATfLKIdoVQgHdQfiZaXE7SgLeJ8gewZLjaKX/bLaEz62XHv2nPJXcv20iOQdrl6LjukUN+2YpHIrNzf9pNbpQ/J4SZpS3o8OC8p66MdvcgweMCQlDBVQSgXbeHAe1g4xGXrCdiSHxM1VWd2Fvr0BUinat6KIN/r1DDSnk0ijr6CB4YmSlsSthoihkG000gNoTVNTy5tMH6ZLTa+xBNd/HJ/9AJHPACGwiRoDiAe/11QMuzV6ERK0a+xm4oVwqHBP1jRFNqlTCCtQk9hz6CErvXXpCIdJlCU/O8O1atgZSDlPVElk3072wrssC/+hw+BwZwUf4IN5oSpUiSZSnQj1ip1D2ogiqK63jgicLL5Jf8e9wHazAxEGUd2BFN4ugsk5zdZaLjBRkVB/+bofsk+ACNTautzZRDOEYnz55TDVosufJ7T8KPiyxpuKUNHO3sMed7RRthbdfzMK38kM4KXK7NN1inXUrxZbm19A+d7czMewE2FhMScHP1VzGlK+sXsd53/mGDYZHGJR19nQkTjRdG9Sm0CKwfFjD/mxBC+E9tNW6BacZD0Zazhr0M+I8nV8sbyWFbjMvKnT7XwbpMEW58b9uvsq/Z NOgLU7Cq D3pRnfeA76V4ETdHvkUEVWSquWv/JzMh0pdDSBb8t4sffI5TrKhe9koTfcw6HGcdVoGhTsBrqQCZ7VER1G/oXMOklb9UiBYOJbr1m7sR1Xj4cXjogilZnFqKrDSDpqCLUKBDftJyShYoRaW6+BaxPJBlQ29NakZT6yPdf95gOZbz/1Nf7qcDCQimxXgn8d7Z7czRyCCTDslEifGyzgRJRDNNuajWhtV9PsrZ8PpoFN3afOA27XFytLO6dAb+j027WuCJtaoDpadtyTnwysQWTrEA/ubFBdqvBwZnFnSjvqYN0AOyTbtqraY+QDg== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: When I did soft offline stress test, a machine was observed to crash with the following message: kernel BUG at include/linux/memcontrol.h:554! invalid opcode: 0000 [#1] PREEMPT SMP NOPTI CPU: 5 PID: 3837 Comm: hwpoison.sh Not tainted 6.7.0-next-20240112-00001-g8ecf3e7fb7c8-dirty #97 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.14.0-0-g155821a1990b-prebuilt.qemu.org 04/01/2014 RIP: 0010:folio_memcg+0xaf/0xd0 Code: 10 5b 5d c3 cc cc cc cc 48 c7 c6 08 b1 f2 b2 48 89 ef e8 b4 c5 f8 ff 90 0f 0b 48 c7 c6 d0 b0 f2 b2 48 89 ef e8 a2 c5 f8 ff 90 <0f> 0b 48 c7 c6 08 b1 f2 b2 48 89 ef e8 90 c5 f8 ff 90 0f 0b 66 66 RSP: 0018:ffffb6c043657c98 EFLAGS: 00000296 RAX: 000000000000004b RBX: ffff932bc1d1e401 RCX: ffff933abfb5c908 RDX: 0000000000000000 RSI: 0000000000000027 RDI: ffff933abfb5c900 RBP: ffffea6f04019080 R08: ffffffffb3338ce8 R09: 0000000000009ffb R10: 00000000000004dd R11: ffffffffb3308d00 R12: ffffea6f04019080 R13: ffffea6f04019080 R14: 0000000000000001 R15: ffffb6c043657da0 FS: 00007f6c60f6b740(0000) GS:ffff933abfb40000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 0000559c3bc8b980 CR3: 0000000107f1c000 CR4: 00000000000006f0 Call Trace: split_huge_page_to_list+0x4d/0x1380 try_to_split_thp_page+0x3a/0xf0 soft_offline_page+0x1ea/0x8a0 soft_offline_page_store+0x52/0x90 kernfs_fop_write_iter+0x118/0x1b0 vfs_write+0x30b/0x430 ksys_write+0x5e/0xe0 do_syscall_64+0xb0/0x1b0 entry_SYSCALL_64_after_hwframe+0x6d/0x75 RIP: 0033:0x7f6c60d14697 Code: 10 00 f7 d8 64 89 02 48 c7 c0 ff ff ff ff eb b7 0f 1f 00 f3 0f 1e fa 64 8b 04 25 18 00 00 00 85 c0 75 10 b8 01 00 00 00 0f 05 <48> 3d 00 f0 ff ff 77 51 c3 48 83 ec 28 48 89 54 24 18 48 89 74 24 RSP: 002b:00007ffe9b72b8d8 EFLAGS: 00000246 ORIG_RAX: 0000000000000001 RAX: ffffffffffffffda RBX: 000000000000000c RCX: 00007f6c60d14697 RDX: 000000000000000c RSI: 0000559c3bc8b980 RDI: 0000000000000001 RBP: 0000559c3bc8b980 R08: 00007f6c60dd1460 R09: 000000007fffffff R10: 0000000000000000 R11: 0000000000000246 R12: 000000000000000c R13: 00007f6c60e1a780 R14: 00007f6c60e16600 R15: 00007f6c60e15a00 The problem is that page->mapping is overloaded with slab->slab_list or slabs fields now, so slab pages could be taken as non-LRU movable pages if field slabs contains PAGE_MAPPING_MOVABLE or slab_list->prev is set to LIST_POISON2. These slab pages will be treated as thp later leading to crash in split_huge_page_to_list(). Fixes: 130d4df57390 ("mm/sl[au]b: rearrange struct slab fields to allow larger rcu_head") Signed-off-by: Miaohe Lin Reviewed-by: Matthew Wilcox (Oracle) --- v3: Trim those '?' lines out of the backtrace per Matthew. Collect Reviewed-by tag from Matthew. Thanks. v2: Check PageSlab() first to leave the rest code alone per Matthew. --- mm/memory-failure.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/mm/memory-failure.c b/mm/memory-failure.c index 636280d04008..9349948f1abf 100644 --- a/mm/memory-failure.c +++ b/mm/memory-failure.c @@ -1377,6 +1377,9 @@ void ClearPageHWPoisonTakenOff(struct page *page) */ static inline bool HWPoisonHandlable(struct page *page, unsigned long flags) { + if (PageSlab(page)) + return false; + /* Soft offline could migrate non-LRU movable pages */ if ((flags & MF_SOFT_OFFLINE) && __PageMovable(page)) return true;