Message ID | 20240208085556.2412922-1-linan666@huaweicloud.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel+bounces-57684-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:50ea:b0:106:860b:bbdd with SMTP id r10csp34721dyd; Thu, 8 Feb 2024 01:02:20 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVdXk583LKvwmsCK/lCqaTtbuasJkDl8VfXwH4H7wZABSQjgrpEP4u+zuvaCpcagtXdGc89UNKie/C98nnlm8y6H3UtWA== X-Google-Smtp-Source: AGHT+IFNBo9wVZUgXuJYcNY+RWUyKn1yPqDlFeRVCkXvVD4BQweONfef8ufMt0pZV6hERWPh5afU X-Received: by 2002:a05:6214:1c4b:b0:68c:8669:cddd with SMTP id if11-20020a0562141c4b00b0068c8669cdddmr10687806qvb.44.1707382940726; Thu, 08 Feb 2024 01:02:20 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707382940; cv=pass; d=google.com; s=arc-20160816; b=N+wmC7IGQZdPwT11U4OOORLtJnjM0kWieomQSKmlk2R7J3AaD9Xdil7VhaHnzR83T8 6HH2Lg7rltufBOz/DOXV3YpTWYvV+pQ75OOEyC+FuI2mRQUaxOgZaRoHLZVolZHWcPVy WgVsBKANGRHQb2aVpD6F5fZG2eVok74vPGhOAGe7eqtb225zqfBlLcytQWTJ52FdUCFy 4PbkNhogy9nSix3dDtdX/JGQt+HmtkbpIjnu4KTjNHlxVNZNEuuEccotWA5ZgTBKwTJX NVhdqn8tPpFoGr0ENuYSzp96O/pULSR7ov8prQw6nJjX1u0ycGtB3IbflSqpM6PocjpE OK2A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from; bh=1l5ySoEOfgEE0u56cKDkzGrJsxIZU39zG1VwCc4Qq/k=; fh=//DNIIpCE2voUBERJMpMMHRc39OQzFXyW2E48/KbOdI=; b=mB3phskUWbmzNzLww1rj0y+B7KYP3M7HMxNsZITbia1n2kM+5U7d097IWihrZrjqk/ bMV9JNvBKuWqa0gl9d4s/Mp05Cw6ifM2KxAYGAaRMMdBuRZdkqkLFpozl14NQDqZtTch 7YAAJFXwU9XKs5wtZxdOD9DoRr6AAo9MeIOGgf+VvKTgkTOfRdoUZ5bXKZbSuZTvZx+O tObsTPgm6XODM/wZHzyp880XVqvDzUyte25nBQODpmQk5t1ZhUmxQDyNu/hPMq4kR7gc YyedzYEb56Tkw3NaLLlawC9oGYlj/MCoC/DuRODNla3yOI/BlmGoWbmWpSmaeJ7xibsF U3LA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=huaweicloud.com); spf=pass (google.com: domain of linux-kernel+bounces-57684-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-57684-ouuuleilei=gmail.com@vger.kernel.org" X-Forwarded-Encrypted: i=2; AJvYcCVJwFaDJo9WXVo1JBdR3ToqNV00DzdV+FtJNPcXBXZ/OYBvpUuBDzlVqEGtEM2MUNDW304MBKbZw9jGkOneiwz4DJJphA== Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id 15-20020a0562140d6f00b0068cb8048a34si3076411qvs.263.2024.02.08.01.02.20 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Feb 2024 01:02:20 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-57684-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=huaweicloud.com); spf=pass (google.com: domain of linux-kernel+bounces-57684-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-57684-ouuuleilei=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 83A9B1C263D4 for <ouuuleilei@gmail.com>; Thu, 8 Feb 2024 09:01:37 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 234FA6BFC9; Thu, 8 Feb 2024 09:00:58 +0000 (UTC) Received: from dggsgout11.his.huawei.com (unknown [45.249.212.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 22E8769E1E; Thu, 8 Feb 2024 09:00:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707382856; cv=none; b=exCGmNuhFSauOg5UvCt4TfFzvz4qZTL9eV5+toH1UbMS38n7/CEnRq1WMW4CZVcpMxx6tMev8d7Cho4TNBB8/f2iIfns3Pb/oeNOCMre4VH2np4Qwsf1O0L8zubOpfoG+15kWF+Uief2Y8yQ+y6t3vPGpOLRBHF4N85OBqiMf5Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707382856; c=relaxed/simple; bh=H+qUPJmjoRQhkp66tJctkwJt2DRMYRDyaMT0SHclQNE=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=BMlGq8nY41mo3rsAQWHNmcr645z1stX0+tx0jdpOkje7g9/pBtDuMn8o9qJzMGRd7qNYIAi1l8FTQE6U6VDU4vX2iFXRNXPAsrT16+BuHP9uFGnrdMeEx5Nuibg98rVwTnRGm1Tcq5x3/aM/y0WmwXejDLRAVVmaK1o8M7sNExY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=huaweicloud.com; spf=pass smtp.mailfrom=huaweicloud.com; arc=none smtp.client-ip=45.249.212.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=huaweicloud.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huaweicloud.com Received: from mail.maildlp.com (unknown [172.19.163.216]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4TVrYP3nrjz4f3kjf; Thu, 8 Feb 2024 17:00:41 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.112]) by mail.maildlp.com (Postfix) with ESMTP id 599FE1A08FA; Thu, 8 Feb 2024 17:00:44 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.104.67]) by APP1 (Coremail) with SMTP id cCh0CgBXKBE6mMRlGKFjDQ--.1368S4; Thu, 08 Feb 2024 17:00:44 +0800 (CST) From: linan666@huaweicloud.com To: song@kernel.org, gqjiang@suse.com, neilb@suse.com Cc: linux-raid@vger.kernel.org, linux-kernel@vger.kernel.org, linan666@huaweicloud.com, yukuai3@huawei.com, yi.zhang@huawei.com, houtao1@huawei.com, yangerkun@huawei.com Subject: [PATCH] md: fix kmemleak of rdev->serial Date: Thu, 8 Feb 2024 16:55:56 +0800 Message-Id: <20240208085556.2412922-1-linan666@huaweicloud.com> X-Mailer: git-send-email 2.39.2 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: <linux-kernel.vger.kernel.org> List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID: cCh0CgBXKBE6mMRlGKFjDQ--.1368S4 X-Coremail-Antispam: 1UD129KBjvJXoW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qx5xdzvxpfor3voofrz/ X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790320774411645548 X-GMAIL-MSGID: 1790320774411645548 |
Series |
md: fix kmemleak of rdev->serial
|
|
Commit Message
Li Nan
Feb. 8, 2024, 8:55 a.m. UTC
From: Li Nan <linan122@huawei.com> If kobject_add() is fail in bind_rdev_to_array(), 'rdev->serial' will be alloc not be freed, and kmemleak occurs. unreferenced object 0xffff88815a350000 (size 49152): comm "mdadm", pid 789, jiffies 4294716910 hex dump (first 32 bytes): 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ backtrace (crc f773277a): [<0000000058b0a453>] kmemleak_alloc+0x61/0xe0 [<00000000366adf14>] __kmalloc_large_node+0x15e/0x270 [<000000002e82961b>] __kmalloc_node.cold+0x11/0x7f [<00000000f206d60a>] kvmalloc_node+0x74/0x150 [<0000000034bf3363>] rdev_init_serial+0x67/0x170 [<0000000010e08fe9>] mddev_create_serial_pool+0x62/0x220 [<00000000c3837bf0>] bind_rdev_to_array+0x2af/0x630 [<0000000073c28560>] md_add_new_disk+0x400/0x9f0 [<00000000770e30ff>] md_ioctl+0x15bf/0x1c10 [<000000006cfab718>] blkdev_ioctl+0x191/0x3f0 [<0000000085086a11>] vfs_ioctl+0x22/0x60 [<0000000018b656fe>] __x64_sys_ioctl+0xba/0xe0 [<00000000e54e675e>] do_syscall_64+0x71/0x150 [<000000008b0ad622>] entry_SYSCALL_64_after_hwframe+0x6c/0x74 Fixes: 963c555e75b0 ("md: introduce mddev_create/destroy_wb_pool for the change of member device") Signed-off-by: Li Nan <linan122@huawei.com> --- drivers/md/md.c | 1 + 1 file changed, 1 insertion(+)
Comments
On Thu, Feb 8, 2024 at 1:00 AM <linan666@huaweicloud.com> wrote: > > From: Li Nan <linan122@huawei.com> > > If kobject_add() is fail in bind_rdev_to_array(), 'rdev->serial' will be > alloc not be freed, and kmemleak occurs. > > unreferenced object 0xffff88815a350000 (size 49152): > comm "mdadm", pid 789, jiffies 4294716910 > hex dump (first 32 bytes): > 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ > 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ > backtrace (crc f773277a): > [<0000000058b0a453>] kmemleak_alloc+0x61/0xe0 > [<00000000366adf14>] __kmalloc_large_node+0x15e/0x270 > [<000000002e82961b>] __kmalloc_node.cold+0x11/0x7f > [<00000000f206d60a>] kvmalloc_node+0x74/0x150 > [<0000000034bf3363>] rdev_init_serial+0x67/0x170 > [<0000000010e08fe9>] mddev_create_serial_pool+0x62/0x220 > [<00000000c3837bf0>] bind_rdev_to_array+0x2af/0x630 > [<0000000073c28560>] md_add_new_disk+0x400/0x9f0 > [<00000000770e30ff>] md_ioctl+0x15bf/0x1c10 > [<000000006cfab718>] blkdev_ioctl+0x191/0x3f0 > [<0000000085086a11>] vfs_ioctl+0x22/0x60 > [<0000000018b656fe>] __x64_sys_ioctl+0xba/0xe0 > [<00000000e54e675e>] do_syscall_64+0x71/0x150 > [<000000008b0ad622>] entry_SYSCALL_64_after_hwframe+0x6c/0x74 > > Fixes: 963c555e75b0 ("md: introduce mddev_create/destroy_wb_pool for the change of member device") > Signed-off-by: Li Nan <linan122@huawei.com> LGTM. Applied to md-6.9. Thanks, Song
diff --git a/drivers/md/md.c b/drivers/md/md.c index e05858653a41..350f5b22ba6f 100644 --- a/drivers/md/md.c +++ b/drivers/md/md.c @@ -2536,6 +2536,7 @@ static int bind_rdev_to_array(struct md_rdev *rdev, struct mddev *mddev) fail: pr_warn("md: failed to register dev-%s for %s\n", b, mdname(mddev)); + mddev_destroy_serial_pool(mddev, rdev); return err; }