Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp3865014pxv; Mon, 28 Jun 2021 15:06:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzr876up/2bQlTPJhu2n8TNpk3R9KRzycYcyV+NScOAHDu7+TxKmRScWCDK/4iqv2YUUxrG X-Received: by 2002:aa7:d801:: with SMTP id v1mr35959701edq.349.1624917982769; Mon, 28 Jun 2021 15:06:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624917982; cv=none; d=google.com; s=arc-20160816; b=NTWQaJ3Rk46iJwUijxwaj9lgFBdaNTDocMsoDvTOPjdP0uMckm+XTohhEjXoY3PJk8 ZyKWVN2kQU3yGHQ1MzHOJF6HqUunBi7Jzj5qxDDtIBHcgzLn6SPQJcehan8lqrBhEqeC gAjH1gN+c8zvFAyr9HCza1DNQrZ2MeGoJ3NegS5XAtDXQQBByG8aVpPwfPwndvCmAfTG 8NKv5phpU8nJN76aR9mmoQlZPIHBJk50y18Rh0SXTMQcZjPQENQA0eG5cX5Sqp4+kWmt mG3JBFciWpg37i8IO/9HNJYX9B4+HrZa4s3T6k1ML1THxhuBoar211cTlVgRZxQQdJpp D9pw== 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 :dkim-signature; bh=RoTeinxDw0exk+SaJYrEMO2X8DrabMJLwfxC/L/1VLM=; b=FdPJMDm5dmRN672ybSVto4zyiU3TssFP2FrbsUlmL+cxOOVVkH8evGOyaN08w81iRK fbM7bsnrcI8eg+vBOX2H4l2mupNHls1Rnu2I3IJfD/D7Y0bgWy/t8XtY6plT41lqOC89 7Rx1RukEXxs81mV9lkmmuC/JgyE0JEbTdRi1Ktrh+aiMPs1ZNQWq2Aihiuoc/NW2Fv8A pdBr2fUh7BD8kyFO4q6oxy8cgdt+dw1fIiBY24sAaAcDju9ddGec269EZ22Efqb7z1v4 DG/JdkCerBQuYOFDwoQkxKlRZkDvdCyZwBsvdqch4eIaQYKgpj+iOx+CNEJKRCVsMp8k WCUA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ZTQ7xycF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y11si14932566edo.520.2021.06.28.15.05.57; Mon, 28 Jun 2021 15:06:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ZTQ7xycF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235646AbhF1P0N (ORCPT + 99 others); Mon, 28 Jun 2021 11:26:13 -0400 Received: from mail.kernel.org ([198.145.29.99]:36470 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236544AbhF1PCN (ORCPT ); Mon, 28 Jun 2021 11:02:13 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id AB5A661D50; Mon, 28 Jun 2021 14:41:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1624891264; bh=nginFeJUdaq5OmpNrFI5k6cov0zvAHC7DTGvBVi3gLs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZTQ7xycFE2DZCE148KzFoOIarhr7hy+KrrZF57G2QYkHb7f5WQnY6K56j9NL8qYXG 6aqYr8jHgTRXpOUVZqr/5t4zw2+L71CYQgV9bBa3pjMfYPHVSzqSI4jUKS2rdTBha8 +ZtEf6u51U/H4V5KXDDJWGz1D7mdidVJHDyIiDIZ8Jl8DN2Quv/UdW29kO5k9fdDvR Ch5k/1vKGCnXIYtQJEdh7T8rZj6PV0HSOt4/WbFPQauYM21jQ1B5U5+QK58+Sv1q3V t9vMf0vs/twiPRJYzGy0dezQ37mFHQtYKCRKM0p7uAqY+AHnpnCtHjGdqH+VmgfbXN Ef4FyaXgmNJpw== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Pavel Skripkin , Ryusuke Konishi , "Michael L . Semon" , Andrew Morton , Linus Torvalds , Sasha Levin Subject: [PATCH 4.9 69/71] nilfs2: fix memory leak in nilfs_sysfs_delete_device_group Date: Mon, 28 Jun 2021 10:40:01 -0400 Message-Id: <20210628144003.34260-70-sashal@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210628144003.34260-1-sashal@kernel.org> References: <20210628144003.34260-1-sashal@kernel.org> MIME-Version: 1.0 X-KernelTest-Patch: http://kernel.org/pub/linux/kernel/v4.x/stable-review/patch-4.9.274-rc1.gz X-KernelTest-Tree: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git X-KernelTest-Branch: linux-4.9.y X-KernelTest-Patches: git://git.kernel.org/pub/scm/linux/kernel/git/stable/stable-queue.git X-KernelTest-Version: 4.9.274-rc1 X-KernelTest-Deadline: 2021-06-30T14:39+00:00 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Pavel Skripkin [ Upstream commit 8fd0c1b0647a6bda4067ee0cd61e8395954b6f28 ] My local syzbot instance hit memory leak in nilfs2. The problem was in missing kobject_put() in nilfs_sysfs_delete_device_group(). kobject_del() does not call kobject_cleanup() for passed kobject and it leads to leaking duped kobject name if kobject_put() was not called. Fail log: BUG: memory leak unreferenced object 0xffff8880596171e0 (size 8): comm "syz-executor379", pid 8381, jiffies 4294980258 (age 21.100s) hex dump (first 8 bytes): 6c 6f 6f 70 30 00 00 00 loop0... backtrace: kstrdup+0x36/0x70 mm/util.c:60 kstrdup_const+0x53/0x80 mm/util.c:83 kvasprintf_const+0x108/0x190 lib/kasprintf.c:48 kobject_set_name_vargs+0x56/0x150 lib/kobject.c:289 kobject_add_varg lib/kobject.c:384 [inline] kobject_init_and_add+0xc9/0x160 lib/kobject.c:473 nilfs_sysfs_create_device_group+0x150/0x800 fs/nilfs2/sysfs.c:999 init_nilfs+0xe26/0x12b0 fs/nilfs2/the_nilfs.c:637 Link: https://lkml.kernel.org/r/20210612140559.20022-1-paskripkin@gmail.com Fixes: da7141fb78db ("nilfs2: add /sys/fs/nilfs2/ group") Signed-off-by: Pavel Skripkin Acked-by: Ryusuke Konishi Cc: Michael L. Semon Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Sasha Levin --- fs/nilfs2/sysfs.c | 1 + 1 file changed, 1 insertion(+) diff --git a/fs/nilfs2/sysfs.c b/fs/nilfs2/sysfs.c index 490303e3d517..e9903bceb2bf 100644 --- a/fs/nilfs2/sysfs.c +++ b/fs/nilfs2/sysfs.c @@ -1064,6 +1064,7 @@ void nilfs_sysfs_delete_device_group(struct the_nilfs *nilfs) nilfs_sysfs_delete_superblock_group(nilfs); nilfs_sysfs_delete_segctor_group(nilfs); kobject_del(&nilfs->ns_dev_kobj); + kobject_put(&nilfs->ns_dev_kobj); kfree(nilfs->ns_dev_subgroups); } -- 2.30.2