From mboxrd@z Thu Jan 1 00:00:00 1970 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 ADE56FA375B for ; Fri, 13 Sep 2024 15:01:04 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3D2A98D000A; Fri, 13 Sep 2024 11:01:04 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3836A8D0001; Fri, 13 Sep 2024 11:01:04 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1FD068D000A; Fri, 13 Sep 2024 11:01:04 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id F22B28D0001 for ; Fri, 13 Sep 2024 11:01:03 -0400 (EDT) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 71F69803C1 for ; Fri, 13 Sep 2024 15:01:03 +0000 (UTC) X-FDA: 82560027606.13.37188E9 Received: from mail-pg1-f175.google.com (mail-pg1-f175.google.com [209.85.215.175]) by imf18.hostedemail.com (Postfix) with ESMTP id 60C421C0008 for ; Fri, 13 Sep 2024 15:01:00 +0000 (UTC) Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=Bhp9h30X; spf=pass (imf18.hostedemail.com: domain of 42.hyeyoo@gmail.com designates 209.85.215.175 as permitted sender) smtp.mailfrom=42.hyeyoo@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1726239519; 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:in-reply-to:references:references:dkim-signature; bh=Y3Mppbi6m7S/7tZ1+dZD34mmp/ZIrHqDzlLOK34QtX4=; b=gqiCbz5OUq2tNnRc5ZZtrDxc5Fc+QcNuai+WaMdAb+EGyCBk88hDcfMPq7D2ECbyW62FSa M6oF+AM9CHXBkPlX6LhHIsNwS7vgk4CH0L7iZkbTB4Qb9TMLxHMJCt3mHoiI8zVZR7C5z+ GVPx3mtfb1Byjy8HaN9k55gJ0jsg09c= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=Bhp9h30X; spf=pass (imf18.hostedemail.com: domain of 42.hyeyoo@gmail.com designates 209.85.215.175 as permitted sender) smtp.mailfrom=42.hyeyoo@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1726239519; a=rsa-sha256; cv=none; b=BMwbTS9KDOVSG0NnOBCv9YvqFaeDxbuAa50S5V8cYBPOv/NQgESqPMbhXpLrL53wtjA6mM ADizORFut2U59X56A5iXT4opgn03bv1xUUWwEiNf93B87SB8B4WJND7/0LXCIoYSbuIqR8 wRIVQSNnWQUAlXSAfYLfcRQXT0dYee0= Received: by mail-pg1-f175.google.com with SMTP id 41be03b00d2f7-656d8b346d2so675094a12.2 for ; Fri, 13 Sep 2024 08:01:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1726239659; x=1726844459; darn=kvack.org; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=Y3Mppbi6m7S/7tZ1+dZD34mmp/ZIrHqDzlLOK34QtX4=; b=Bhp9h30XGsrOdGVc+sj9wz8D0vU4K40ZehmkdAOuaLdowwn0h02V9/vff4BBxcTrCC UWOv7+9rcvYQk/L2BDWd08ZQ9Ciu8kwMwqlYISECzIhlU+FAklgurcV6/UNdlXDMwlgd s4uaYutNbdsHyN34NLdY9gMSZfC42IM6xtZWjSTt6q3kYVoutJ9AhIYjsOKD6HidZH5/ JJgRHlbApNtuznwNIKkxqY04+UCaIlk/htm1TceA/iM/dVAGbrt7/UTublUklQPqtkhG +R9R3qvXsEQYB7m8c/62ttIOZ+TPfspGaliCkUKQ997ZLAhomQczIPqmZD6a+56E42aO mf7A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726239659; x=1726844459; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Y3Mppbi6m7S/7tZ1+dZD34mmp/ZIrHqDzlLOK34QtX4=; b=ujLLasfyPnsoDzPxw4RhLUFzDIN4vPSuZBYJCAr/Ti6j2j3BrVmHNMmH2wm/J9h7Rv WihLQB7+h1pluGgvebracLPC2r0qZBQmDgxfBGYqRvT/yPAkcAuxJWaqoQ2Gq6Bhh3Bk NVKHhBWBlCeZaw6uL/bfoSLv6OLNdoZdul9v62SYEfN8fE9nqnKWKWgI66VEJp5F270t OwI9Xxhq2vDLajQA8/e3NCyPM07W+V1d6AwrHPywVYSdBpgO7tpbEqf6dpY6sRx7rzX4 7iPu1Q54bNIDok7iAjyCVD6mgzYU9OZfEzsZF0WPScMk429MjztuZpDEEaRKwA+mLst2 FzuA== X-Forwarded-Encrypted: i=1; AJvYcCUw5GCD/Z8fOBrrbZTEFbL/4xIaoBDciBlRtQE2vo71KT1XioEc7F3fDbwVKBtkneRgXcgyeiJUiA==@kvack.org X-Gm-Message-State: AOJu0Yy3DW9XquHtZsJ51BoKW5ZeTwIZjzNmmDXiZJ6rik/fZiTy6GcL bBkx37q8VzRbh2mwhr/UDmJQmLvuZFDI/Ta7fqldW2N3uof+1iJM X-Google-Smtp-Source: AGHT+IGM3XnVTc2vJfX07FmlXZSJzOFVd3e3Zszr5uh21tUMVvFkskiIYylTVNjdU7ivL37Ac9CLQw== X-Received: by 2002:a05:6a21:3482:b0:1cf:489a:52c1 with SMTP id adf61e73a8af0-1d112b68d47mr5130543637.18.1726239658677; Fri, 13 Sep 2024 08:00:58 -0700 (PDT) Received: from smtpclient.apple ([114.29.21.112]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-719090ad428sm6408659b3a.142.2024.09.13.08.00.54 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 13 Sep 2024 08:00:57 -0700 (PDT) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3826.200.46\)) Subject: Re: [PATCH v4 3/3] mm/slub: Fix memory leak of kobj->name in sysfs_slab_add() From: Hyeonggon Yoo <42.hyeyoo@gmail.com> In-Reply-To: <02820eb8-0b8f-4aa8-9315-85368e9c331e@suse.cz> Date: Sat, 14 Sep 2024 00:00:40 +0900 Cc: Jinjie Ruan , Liu Shixin , Christoph Lameter , Pekka Enberg , David Rientjes , Joonsoo Kim , Andrew Morton , Roman Gushchin , Linux Memory Management List , LKML Content-Transfer-Encoding: quoted-printable Message-Id: <0F94364A-F0C8-4C0A-B38D-3DDEA653B6B7@gmail.com> References: <20221112114602.1268989-1-liushixin2@huawei.com> <20221112114602.1268989-4-liushixin2@huawei.com> <3780a622-03f2-4cfe-5705-0e9d0be61d57@huawei.com> <68b86f66-cd00-bb7d-b8bb-5a94e8dd1ea2@huawei.com> <02820eb8-0b8f-4aa8-9315-85368e9c331e@suse.cz> To: Vlastimil Babka X-Mailer: Apple Mail (2.3826.200.46) X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 60C421C0008 X-Stat-Signature: yhpk861d568qpkkix7wcanynxcxeuowb X-Rspam-User: X-HE-Tag: 1726239660-390213 X-HE-Meta: U2FsdGVkX19nsRhHJF9QCTQ8rsHqUXlND5Q4brrvL0Amtt+ttczPMeSU8myNeiSOhjKJkioJKGEmF0hKk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SkDpF8+WCvkOibphvwUFpB+Zhieaqq3hN2wxk30cqQcedgglEJTQ6IHdNUm4qMyks4wj+2WIGtsgyB+hz7FoISsYKRjtfxIV8+YPCE/kEfgDdlnBUXobv5qJsrcEACn2ybKSFASxFJQsllEpGgiiqwW94LAlzPFg3zIDmpD/2NRkyg2zy96Vh1qfZTYRD6kE4uRk+utqWpLdL3SjdLwKrqY6/C9nuwS4oNMjUxFyGXg11pNfKuj2XBruterRZrvXcGYuRvwCiiF34LDrkhI6k6GSyeGBL9tD2ouviWLzP8/bncJBCmX5Yr+Jf3yANGUD6sdyg16YhIM0uN524EhbRCGtH8Hxr3FdfR8SxVpT6X0epLniB6tM6A== 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: > On Sep 13, 2024, at 11:10=E2=80=AFPM, Vlastimil Babka = wrote: >=20 > On 9/6/24 10:10, Jinjie Ruan wrote: >>=20 >>=20 >> On 2024/9/5 21:59, Hyeonggon Yoo wrote: >>> On Thu, Sep 5, 2024 at 12:41=E2=80=AFPM Jinjie Ruan = wrote: >>>>=20 >>>>=20 >>>>=20 >>>> On 2022/11/12 19:46, Liu Shixin wrote: >>>>> There is a memory leak of kobj->name in sysfs_slab_add(): >>>>>=20 >>>>> unreferenced object 0xffff88817e446440 (size 32): >>>>> comm "insmod", pid 4085, jiffies 4296564501 (age 126.272s) >>>>> hex dump (first 32 bytes): >>>>> 75 62 69 66 73 5f 69 6e 6f 64 65 5f 73 6c 61 62 = ubifs_inode_slab >>>>> 00 65 44 7e 81 88 ff ff 00 00 00 00 00 00 00 00 = .eD~............ >>>>> backtrace: >>>>> [<000000005b30fbbd>] __kmalloc_node_track_caller+0x4e/0x150 >>>>> [<000000002f70da0c>] kstrdup_const+0x4b/0x80 >>>>> [<00000000c6712c61>] kobject_set_name_vargs+0x2f/0xb0 >>>>> [<00000000b151218e>] kobject_init_and_add+0xb0/0x120 >>>>> [<00000000e56a4cf5>] sysfs_slab_add+0x17d/0x220 >>>>> [<000000009326fd57>] __kmem_cache_create+0x406/0x590 >>>>> [<00000000dde33cff>] kmem_cache_create_usercopy+0x1fc/0x300 >>>>> [<00000000fe90cedb>] kmem_cache_create+0x12/0x20 >>>>> [<000000007a6531c8>] 0xffffffffa02d802d >>>>> [<000000000e3b13c7>] do_one_initcall+0x87/0x2a0 >>>>> [<00000000995ecdcf>] do_init_module+0xdf/0x320 >>>>> [<000000008821941f>] load_module+0x2f98/0x3330 >>>>> [<00000000ef51efa4>] __do_sys_finit_module+0x113/0x1b0 >>>>> [<000000009339fbce>] do_syscall_64+0x35/0x80 >>>>> [<000000006b7f2033>] entry_SYSCALL_64_after_hwframe+0x46/0xb0 >>>>=20 >>>>=20 >>>> Hi=EF=BC=8Cevery one, >>>=20 >>> Hi. >>>=20 >>>> I found the same problem and it solve this problem with the patch, = is >>>> there any plan to update the patch and solve it. >=20 > Hmm looks like back in 2022, Hyeonggon had some feedback to the series = which > was not answered and then it got forgotten. Feel free to take over and = send > an updated version. I was thinking of what the fix would be with my feedback, and I still think passing different kobj_type (with a dummy release = function) for early kmem_caches will be a more appropriate approach. However, there is one concern: people that wrote kobject.rst might not = like it :( in Documentation/core-api/kobject.rst: > One important point cannot be overstated: every kobject must have a = release() method, > and the kobject must persist (in a consistent state) until that method = is called. If these constraints are not met, > the code is flawed. Note that the kernel will warn you if you forget = to provide a release() method. > Do not try to get rid of this warning by providing an "empty" release = function. But obviously we don't want to release caches just because the kernel = failed to add it to sysfs. >>> What kernel version do you use, >>=20 >> 6.11.0-rc6 >>=20 >>> and when do you encounter it or how do you reproduce it? >>=20 >> Hi, Hyeonggon, >>=20 >> Thank you, I encounter it when doing inject fault test while modprobe >> amdgpu.ko. >=20 > So I wonder where's the problem that results in kobject_init_and_add() > failing. If it's genuinely duplicate name as commit 80da026a8e5d = suggests, > 6.12-rc1 will have a warning to prevent that. Delayed destruction of > SLAB_TYPESAFE_BY_RCU caches should also no longer happen with = 6.12-rc1. So > worth retrying with that and if it's still failing, we should look at = the > root cause perhaps. I thought it was because the memory allocation for a name string failed = due to fault injection? >=20 >>>=20 >>> -- >>> Hyeonggon