From patchwork Sun Oct 6 04:47:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "yuan.gao" X-Patchwork-Id: 13823659 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 8F87BCFB43F for ; Sun, 6 Oct 2024 04:48:57 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A56C16B02D3; Sun, 6 Oct 2024 00:48:56 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A05E96B02D4; Sun, 6 Oct 2024 00:48:56 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8F4E66B02D5; Sun, 6 Oct 2024 00:48:56 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 70E1E6B02D3 for ; Sun, 6 Oct 2024 00:48:56 -0400 (EDT) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id F1249120794 for ; Sun, 6 Oct 2024 04:48:55 +0000 (UTC) X-FDA: 82641947430.07.8C87227 Received: from mail-m127164.xmail.ntesmail.com (mail-m127164.xmail.ntesmail.com [115.236.127.164]) by imf27.hostedemail.com (Postfix) with ESMTP id B0BCB4000E for ; Sun, 6 Oct 2024 04:48:52 +0000 (UTC) Authentication-Results: imf27.hostedemail.com; dkim=pass header.d=ucloud.cn header.s=default header.b="FS1/crdh"; spf=pass (imf27.hostedemail.com: domain of yuan.gao@ucloud.cn designates 115.236.127.164 as permitted sender) smtp.mailfrom=yuan.gao@ucloud.cn; dmarc=pass (policy=quarantine) header.from=ucloud.cn ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1728190065; a=rsa-sha256; cv=none; b=BxT/dtyuOEFml1IuQW34YQ0pczIYmPHKs56OnKMtyjnqV0/Q4Lv1aoBE7BcpMMKCTw3DaC ZsoT4BjBOH2Q/V1FzZGwTzEpwq721K2BaV6QN/mMMvKREjcwdCL6TvtSnuZCi9VfD9BSDI tk3XMLSnPkWFFznz4yOehOvyDuMfXjg= ARC-Authentication-Results: i=1; imf27.hostedemail.com; dkim=pass header.d=ucloud.cn header.s=default header.b="FS1/crdh"; spf=pass (imf27.hostedemail.com: domain of yuan.gao@ucloud.cn designates 115.236.127.164 as permitted sender) smtp.mailfrom=yuan.gao@ucloud.cn; dmarc=pass (policy=quarantine) header.from=ucloud.cn ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1728190065; 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:dkim-signature; bh=DzhdTwCRo4j+QO/qhe7Dr6dKo20c/1jja6tB2xBi4bg=; b=yGvHV/AbM33PVc3yH2CSrd+TSIRMY2AO7Hc9o314OcpW4/abKtHxQxAQjk7s8FxapQ7XcH FUPpAllSCMYt4qoj0MeT3p9hAui+C67wQtG/i1DP7c+tw7Oeggpq76CwH/mLXD3nVAvdlE 7vEhfQmbUhgLU8zz2r0u8B8GrZoivu0= DKIM-Signature: a=rsa-sha256; b=FS1/crdhszsPOD4U0Uss+iO4CLjZFoD/D19EL2EMJUBoyrX/MY73xopYsJiXkBCX9prwF7NVn3+D06J4qD4fAiHwkkbJ+AWluqUdsFArteLEtn86wswQq8F/IMgnr9P8BP5uoez0Wb98ZhFMZKDL+eLsKO9ISiMTUwC5IKMxf+s=; s=default; c=relaxed/relaxed; d=ucloud.cn; v=1; bh=DzhdTwCRo4j+QO/qhe7Dr6dKo20c/1jja6tB2xBi4bg=; h=date:mime-version:subject:message-id:from; Received: from localhost.localdomain (unknown [101.93.48.31]) by smtp.qiye.163.com (Hmail) with ESMTPA id 424BD74020E; Sun, 6 Oct 2024 12:47:58 +0800 (CST) From: "yuan.gao" To: cl@linux.com, penberg@kernel.org, rientjes@google.com, iamjoonsoo.kim@lge.com, akpm@linux-foundation.org, vbabka@suse.cz, roman.gushchin@linux.dev, 42.hyeyoo@gmail.com Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, yuan.gao@ucloud.cn Subject: [PATCH] =?utf-8?q?mm/slub=3A_Avoid_list_corruption_when_removing_a_?= =?utf-8?q?slab_from_the_full_list=C2=A0_=C2=A0?= Date: Sun, 6 Oct 2024 12:47:55 +0800 Message-Id: <20241006044755.79634-1-yuan.gao@ucloud.cn> X-Mailer: git-send-email 2.32.0 MIME-Version: 1.0 X-HM-Spam-Status: e1kfGhgUHx5ZQUpXWQgPGg8OCBgUHx5ZQUlOS1dZFg8aDwILHllBWSg2Ly tZV1koWUFJQjdXWS1ZQUlXWQ8JGhUIEh9ZQVlCSBhKVh1NTU5CHU1MSUNCGVYVFAkWGhdVGRETFh oSFyQUDg9ZV1kYEgtZQVlKS0pVQkhVT0NVSEpZV1kWGg8SFR0UWUFZT0tIVUpLSU9PT0hVSktLVU pCS0tZBg++ X-HM-Tid: 0a926027df2d0236kunm424bd74020e X-HM-MType: 1 X-HM-Sender-Digest: e1kMHhlZQR0aFwgeV1kSHx4VD1lBWUc6PS46Gio4CzcjPExLOkwJH0xP Ih0KCx9VSlVKTElDSkJLS0xCSEJPVTMWGhIXVQIOGhVVHBoUOw4YFxQOH1UYFUVZV1kSC1lBWUpL SlVCSFVPQ1VISllXWQgBWUFOSUxONwY+ X-Stat-Signature: f7hh4ygi7gdmamcrge91i499enosq75h X-Rspamd-Queue-Id: B0BCB4000E X-Rspam-User: X-Rspamd-Server: rspam10 X-HE-Tag: 1728190132-854611 X-HE-Meta: U2FsdGVkX19ICj8jMIlrD/yJhpduxnWUFshrOYkKLhM7Xo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NeAKEEY1y+D6lssHdGAXdQHoQU06MslvtAukGi3xs4SbNvPjdLKEF7LxySIg1RSjOqI9F0LVdP1zDRCHR0CN6yeDjEqt1vHLylKEa3VewTQ6GVYJp1CAQfMYWPqb56EEovaKU70zVVr1ir7VZ4lhFt+DoXH0SEH2IVpmcvx4gcV3x5s/52yXOVlnH/D/rcFgbWaURLU94ZZV 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: Boot with slub_debug=UFPZ. If allocated object failed in alloc_consistency_checks, all objects of the slab will be marked as used, and then the slab will be removed from the partial list. When an object belonging to the slab got freed later, the remove_full() function is called. Because the slab is neither on the partial list nor on the full list, it eventually lead to a list corruption. So we need to add the slab to full list in this case. [ 4277.385669] list_del corruption, ffffea00044b3e50->next is LIST_POISON1 (dead000000000100) [ 4277.387023] ------------[ cut here ]------------ [ 4277.387880] kernel BUG at lib/list_debug.c:56! [ 4277.388680] invalid opcode: 0000 [#1] PREEMPT SMP PTI [ 4277.389562] CPU: 5 PID: 90 Comm: kworker/5:1 Kdump: loaded Tainted: G OE 6.6.1-1 #1 [ 4277.392113] Workqueue: xfs-inodegc/vda1 xfs_inodegc_worker [xfs] [ 4277.393551] RIP: 0010:__list_del_entry_valid_or_report+0x7b/0xc0 [ 4277.394518] Code: 48 91 82 e8 37 f9 9a ff 0f 0b 48 89 fe 48 c7 c7 28 49 91 82 e8 26 f9 9a ff 0f 0b 48 89 fe 48 c7 c7 58 49 91 82 e8 15 f9 9a ff <0f> 0b 48 89 fe 48 89 ca 48 c7 c7 90 49 91 82 e8 01 f9 9a ff 0f 0b [ 4277.397292] RSP: 0018:ffffc90000333b38 EFLAGS: 00010082 [ 4277.398202] RAX: 000000000000004e RBX: ffffea00044b3e50 RCX: 0000000000000000 [ 4277.399340] RDX: 0000000000000002 RSI: ffffffff828f8715 RDI: 00000000ffffffff [ 4277.400545] RBP: ffffea00044b3e40 R08: 0000000000000000 R09: ffffc900003339f0 [ 4277.401710] R10: 0000000000000003 R11: ffffffff82d44088 R12: ffff888112cf9910 [ 4277.402887] R13: 0000000000000001 R14: 0000000000000001 R15: ffff8881000424c0 [ 4277.404049] FS: 0000000000000000(0000) GS:ffff88842fd40000(0000) knlGS:0000000000000000 [ 4277.405357] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 4277.406389] CR2: 00007f2ad0b24000 CR3: 0000000102a3a006 CR4: 00000000007706e0 [ 4277.407589] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 [ 4277.408780] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 [ 4277.410000] PKRU: 55555554 [ 4277.410645] Call Trace: [ 4277.411234] [ 4277.411777] ? die+0x32/0x80 [ 4277.412439] ? do_trap+0xd6/0x100 [ 4277.413150] ? __list_del_entry_valid_or_report+0x7b/0xc0 [ 4277.414158] ? do_error_trap+0x6a/0x90 [ 4277.414948] ? __list_del_entry_valid_or_report+0x7b/0xc0 [ 4277.415915] ? exc_invalid_op+0x4c/0x60 [ 4277.416710] ? __list_del_entry_valid_or_report+0x7b/0xc0 [ 4277.417675] ? asm_exc_invalid_op+0x16/0x20 [ 4277.418482] ? __list_del_entry_valid_or_report+0x7b/0xc0 [ 4277.419466] ? __list_del_entry_valid_or_report+0x7b/0xc0 [ 4277.420410] free_to_partial_list+0x515/0x5e0 [ 4277.421242] ? xfs_iext_remove+0x41a/0xa10 [xfs] [ 4277.422298] xfs_iext_remove+0x41a/0xa10 [xfs] [ 4277.423316] ? xfs_inodegc_worker+0xb4/0x1a0 [xfs] [ 4277.424383] xfs_bmap_del_extent_delay+0x4fe/0x7d0 [xfs] [ 4277.425490] __xfs_bunmapi+0x50d/0x840 [xfs] [ 4277.426445] xfs_itruncate_extents_flags+0x13a/0x490 [xfs] [ 4277.427553] xfs_inactive_truncate+0xa3/0x120 [xfs] [ 4277.428567] xfs_inactive+0x22d/0x290 [xfs] [ 4277.429500] xfs_inodegc_worker+0xb4/0x1a0 [xfs] [ 4277.430479] process_one_work+0x171/0x340 [ 4277.431227] worker_thread+0x277/0x390 [ 4277.431962] ? __pfx_worker_thread+0x10/0x10 [ 4277.432752] kthread+0xf0/0x120 [ 4277.433382] ? __pfx_kthread+0x10/0x10 [ 4277.434134] ret_from_fork+0x2d/0x50 [ 4277.434837] ? __pfx_kthread+0x10/0x10 [ 4277.435566] ret_from_fork_asm+0x1b/0x30 [ 4277.436280] Signed-off-by: yuan.gao --- mm/slub.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mm/slub.c b/mm/slub.c index 21f71cb6cc06..a99522b9efc0 100644 --- a/mm/slub.c +++ b/mm/slub.c @@ -2746,6 +2746,8 @@ static void *alloc_single_from_partial(struct kmem_cache *s, if (!alloc_debug_processing(s, slab, object, orig_size)) { remove_partial(n, slab); + if (slab->inuse == slab->objects) + add_full(s, n, slab); return NULL; }