* [PATCH] md: fix kmemleak of rdev->serial
@ 2024-05-13 21:39 Jeremy Bongio
2024-05-13 22:24 ` Greg KH
0 siblings, 1 reply; 14+ messages in thread
From: Jeremy Bongio @ 2024-05-13 21:39 UTC (permalink / raw)
To: stable; +Cc: Li Nan, Song Liu, Jeremy Bongio
From: Li Nan <linan122@huawei.com>
commit 6cf350658736681b9d6b0b6e58c5c76b235bb4c4 upstream.
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
backport change:
mddev_destroy_serial_pool third parameter was removed in mainline,
where there is no need to suspend within this function anymore.
Fixes: 963c555e75b0 ("md: introduce mddev_create/destroy_wb_pool for the change of member device")
Signed-off-by: Li Nan <linan122@huawei.com>
Signed-off-by: Song Liu <song@kernel.org>
Link: https://lore.kernel.org/r/20240208085556.2412922-1-linan666@huaweicloud.com
Change-Id: Icc4960dcaffedc663797e2d8b18a24c23e201932
Signed-off-by: Jeremy Bongio <jbongio@google.com>
---
drivers/md/md.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/md/md.c b/drivers/md/md.c
index 09c7f52156f3f..67ceab4573be4 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -2532,6 +2532,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, false);
return err;
}
--
2.45.0.118.g7fe29c98d7-goog
^ permalink raw reply related [flat|nested] 14+ messages in thread* Re: [PATCH] md: fix kmemleak of rdev->serial
2024-05-13 21:39 [PATCH] md: fix kmemleak of rdev->serial Jeremy Bongio
@ 2024-05-13 22:24 ` Greg KH
2024-05-13 23:31 ` Jeremy Bongio
0 siblings, 1 reply; 14+ messages in thread
From: Greg KH @ 2024-05-13 22:24 UTC (permalink / raw)
To: Jeremy Bongio; +Cc: stable, Li Nan, Song Liu, Jeremy Bongio
On Mon, May 13, 2024 at 02:39:38PM -0700, Jeremy Bongio wrote:
> From: Li Nan <linan122@huawei.com>
>
> commit 6cf350658736681b9d6b0b6e58c5c76b235bb4c4 upstream.
>
> 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
>
> backport change:
> mddev_destroy_serial_pool third parameter was removed in mainline,
> where there is no need to suspend within this function anymore.
>
> Fixes: 963c555e75b0 ("md: introduce mddev_create/destroy_wb_pool for the change of member device")
> Signed-off-by: Li Nan <linan122@huawei.com>
> Signed-off-by: Song Liu <song@kernel.org>
> Link: https://lore.kernel.org/r/20240208085556.2412922-1-linan666@huaweicloud.com
> Change-Id: Icc4960dcaffedc663797e2d8b18a24c23e201932
Why the change-id?
And what kernel tree(s) is this backport for?
> Signed-off-by: Jeremy Bongio <jbongio@google.com>
This doesn't match the From: line of your email :(
thanks,
greg k-h
^ permalink raw reply [flat|nested] 14+ messages in thread* Re: [PATCH] md: fix kmemleak of rdev->serial
2024-05-13 22:24 ` Greg KH
@ 2024-05-13 23:31 ` Jeremy Bongio
0 siblings, 0 replies; 14+ messages in thread
From: Jeremy Bongio @ 2024-05-13 23:31 UTC (permalink / raw)
To: Greg KH; +Cc: stable, Li Nan, Song Liu, Jeremy Bongio
Change-id is an artifact from gerrit. I didn't realize I left it in.
I was using my personal email for sending patches.
I will send and sign with the same email if that's less confusing.
On Mon, May 13, 2024 at 3:24 PM Greg KH <gregkh@linuxfoundation.org> wrote:
>
> On Mon, May 13, 2024 at 02:39:38PM -0700, Jeremy Bongio wrote:
> > From: Li Nan <linan122@huawei.com>
> >
> > commit 6cf350658736681b9d6b0b6e58c5c76b235bb4c4 upstream.
> >
> > 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
> >
> > backport change:
> > mddev_destroy_serial_pool third parameter was removed in mainline,
> > where there is no need to suspend within this function anymore.
> >
> > Fixes: 963c555e75b0 ("md: introduce mddev_create/destroy_wb_pool for the change of member device")
> > Signed-off-by: Li Nan <linan122@huawei.com>
> > Signed-off-by: Song Liu <song@kernel.org>
> > Link: https://lore.kernel.org/r/20240208085556.2412922-1-linan666@huaweicloud.com
> > Change-Id: Icc4960dcaffedc663797e2d8b18a24c23e201932
>
> Why the change-id?
>
> And what kernel tree(s) is this backport for?
>
> > Signed-off-by: Jeremy Bongio <jbongio@google.com>
>
> This doesn't match the From: line of your email :(
>
> thanks,
>
> greg k-h
^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH] md: fix kmemleak of rdev->serial
@ 2024-05-13 23:30 Jeremy Bongio
2024-05-15 7:33 ` Greg KH
0 siblings, 1 reply; 14+ messages in thread
From: Jeremy Bongio @ 2024-05-13 23:30 UTC (permalink / raw)
To: stable; +Cc: Li Nan, Song Liu, Jeremy Bongio
From: Li Nan <linan122@huawei.com>
commit 6cf350658736681b9d6b0b6e58c5c76b235bb4c4 upstream.
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
backport change:
mddev_destroy_serial_pool third parameter was removed in mainline,
where there is no need to suspend within this function anymore.
Fixes: 963c555e75b0 ("md: introduce mddev_create/destroy_wb_pool for the change of member device")
Signed-off-by: Li Nan <linan122@huawei.com>
Signed-off-by: Song Liu <song@kernel.org>
Link: https://lore.kernel.org/r/20240208085556.2412922-1-linan666@huaweicloud.com
Signed-off-by: Jeremy Bongio <jbongio@google.com>
---
This backport is tested on LTS 5.10, 6.1, 6.6
drivers/md/md.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/md/md.c b/drivers/md/md.c
index 09c7f52156f3f..67ceab4573be4 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -2532,6 +2532,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, false);
return err;
}
--
2.45.0.118.g7fe29c98d7-goog
^ permalink raw reply related [flat|nested] 14+ messages in thread* Re: [PATCH] md: fix kmemleak of rdev->serial
2024-05-13 23:30 Jeremy Bongio
@ 2024-05-15 7:33 ` Greg KH
2024-05-15 16:31 ` Jeremy Bongio
0 siblings, 1 reply; 14+ messages in thread
From: Greg KH @ 2024-05-15 7:33 UTC (permalink / raw)
To: Jeremy Bongio; +Cc: stable, Li Nan, Song Liu
On Mon, May 13, 2024 at 11:30:58PM +0000, Jeremy Bongio wrote:
> From: Li Nan <linan122@huawei.com>
>
> commit 6cf350658736681b9d6b0b6e58c5c76b235bb4c4 upstream.
>
> 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
>
> backport change:
> mddev_destroy_serial_pool third parameter was removed in mainline,
> where there is no need to suspend within this function anymore.
>
> Fixes: 963c555e75b0 ("md: introduce mddev_create/destroy_wb_pool for the change of member device")
> Signed-off-by: Li Nan <linan122@huawei.com>
> Signed-off-by: Song Liu <song@kernel.org>
> Link: https://lore.kernel.org/r/20240208085556.2412922-1-linan666@huaweicloud.com
> Signed-off-by: Jeremy Bongio <jbongio@google.com>
> ---
>
> This backport is tested on LTS 5.10, 6.1, 6.6
So this is not needed in 5.15.y or 5.4.y? Why not?
thanks,
greg k-h
^ permalink raw reply [flat|nested] 14+ messages in thread* Re: [PATCH] md: fix kmemleak of rdev->serial
2024-05-15 7:33 ` Greg KH
@ 2024-05-15 16:31 ` Jeremy Bongio
2024-05-16 6:54 ` Greg KH
0 siblings, 1 reply; 14+ messages in thread
From: Jeremy Bongio @ 2024-05-15 16:31 UTC (permalink / raw)
To: Greg KH; +Cc: stable, Li Nan, Song Liu
5.4 doesn't have "mddev_destroy_serial_pool" ... More work would be
needed to figure out if the vulnerability exists and how to fix it.
The patch also applies to 5.15, but I haven't tested it.
On Wed, May 15, 2024 at 12:33 AM Greg KH <greg@kroah.com> wrote:
>
> On Mon, May 13, 2024 at 11:30:58PM +0000, Jeremy Bongio wrote:
> > From: Li Nan <linan122@huawei.com>
> >
> > commit 6cf350658736681b9d6b0b6e58c5c76b235bb4c4 upstream.
> >
> > 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
> >
> > backport change:
> > mddev_destroy_serial_pool third parameter was removed in mainline,
> > where there is no need to suspend within this function anymore.
> >
> > Fixes: 963c555e75b0 ("md: introduce mddev_create/destroy_wb_pool for the change of member device")
> > Signed-off-by: Li Nan <linan122@huawei.com>
> > Signed-off-by: Song Liu <song@kernel.org>
> > Link: https://lore.kernel.org/r/20240208085556.2412922-1-linan666@huaweicloud.com
> > Signed-off-by: Jeremy Bongio <jbongio@google.com>
> > ---
> >
> > This backport is tested on LTS 5.10, 6.1, 6.6
>
> So this is not needed in 5.15.y or 5.4.y? Why not?
>
> thanks,
>
> greg k-h
^ permalink raw reply [flat|nested] 14+ messages in thread* Re: [PATCH] md: fix kmemleak of rdev->serial
2024-05-15 16:31 ` Jeremy Bongio
@ 2024-05-16 6:54 ` Greg KH
2024-05-20 22:18 ` Jeremy Bongio
0 siblings, 1 reply; 14+ messages in thread
From: Greg KH @ 2024-05-16 6:54 UTC (permalink / raw)
To: Jeremy Bongio; +Cc: stable, Li Nan, Song Liu
A: http://en.wikipedia.org/wiki/Top_post
Q: Were do I find info about this thing called top-posting?
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing in e-mail?
A: No.
Q: Should I include quotations after my reply?
http://daringfireball.net/2007/07/on_top
On Wed, May 15, 2024 at 09:31:07AM -0700, Jeremy Bongio wrote:
> 5.4 doesn't have "mddev_destroy_serial_pool" ... More work would be
> needed to figure out if the vulnerability exists and how to fix it.
Can you do that please? I know Google still cares about 5.4 kernel
trees :)
> The patch also applies to 5.15, but I haven't tested it.
I took it there as we can't take a patch for an older kernel and not a
newer one, as that would cause a regression when people upgrade.
thanks,
greg k-h
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH] md: fix kmemleak of rdev->serial
2024-05-16 6:54 ` Greg KH
@ 2024-05-20 22:18 ` Jeremy Bongio
0 siblings, 0 replies; 14+ messages in thread
From: Jeremy Bongio @ 2024-05-20 22:18 UTC (permalink / raw)
To: Greg KH; +Cc: stable, Li Nan, Song Liu
On Wed, May 15, 2024 at 11:54 PM Greg KH <gregkh@linuxfoundation.org> wrote:
>
>
> A: http://en.wikipedia.org/wiki/Top_post
> Q: Were do I find info about this thing called top-posting?
> A: Because it messes up the order in which people normally read text.
> Q: Why is top-posting such a bad thing?
> A: Top-posting.
> Q: What is the most annoying thing in e-mail?
>
> A: No.
> Q: Should I include quotations after my reply?
>
> http://daringfireball.net/2007/07/on_top
Got it.
>
> On Wed, May 15, 2024 at 09:31:07AM -0700, Jeremy Bongio wrote:
> > 5.4 doesn't have "mddev_destroy_serial_pool" ... More work would be
> > needed to figure out if the vulnerability exists and how to fix it.
>
> Can you do that please? I know Google still cares about 5.4 kernel
> trees :)
For 5.4 renaming mddev_destroy_serial_pool() to
mddev_destroy_wb_pool() should be good.
I notified the Android security team to test.
>
> > The patch also applies to 5.15, but I haven't tested it.
>
> I took it there as we can't take a patch for an older kernel and not a
> newer one, as that would cause a regression when people upgrade.
Makes sense.
>
> thanks,
>
> greg k-h
^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH] md: fix kmemleak of rdev->serial
@ 2024-05-13 19:20 Jeremy Bongio
2024-05-13 20:53 ` Greg KH
0 siblings, 1 reply; 14+ messages in thread
From: Jeremy Bongio @ 2024-05-13 19:20 UTC (permalink / raw)
To: stable; +Cc: Li Nan, Song Liu
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>
Signed-off-by: Song Liu <song@kernel.org>
Link: https://lore.kernel.org/r/20240208085556.2412922-1-linan666@huaweicloud.com
Change-Id: Icc4960dcaffedc663797e2d8b18a24c23e201932
---
drivers/md/md.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/md/md.c b/drivers/md/md.c
index 09c7f52156f3f..67ceab4573be4 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -2532,6 +2532,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, false);
return err;
}
--
2.45.0.118.g7fe29c98d7-goog
^ permalink raw reply related [flat|nested] 14+ messages in thread* Re: [PATCH] md: fix kmemleak of rdev->serial
2024-05-13 19:20 Jeremy Bongio
@ 2024-05-13 20:53 ` Greg KH
0 siblings, 0 replies; 14+ messages in thread
From: Greg KH @ 2024-05-13 20:53 UTC (permalink / raw)
To: Jeremy Bongio; +Cc: stable, Li Nan, Song Liu
On Mon, May 13, 2024 at 12:20:30PM -0700, Jeremy Bongio 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>
> Signed-off-by: Song Liu <song@kernel.org>
> Link: https://lore.kernel.org/r/20240208085556.2412922-1-linan666@huaweicloud.com
> Change-Id: Icc4960dcaffedc663797e2d8b18a24c23e201932
> ---
> drivers/md/md.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/drivers/md/md.c b/drivers/md/md.c
> index 09c7f52156f3f..67ceab4573be4 100644
> --- a/drivers/md/md.c
> +++ b/drivers/md/md.c
> @@ -2532,6 +2532,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, false);
> return err;
> }
>
> --
> 2.45.0.118.g7fe29c98d7-goog
>
>
<formletter>
This is not the correct way to submit patches for inclusion in the
stable kernel tree. Please read:
https://www.kernel.org/doc/html/latest/process/stable-kernel-rules.html
for how to do this properly.
</formletter>
^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH] md: fix kmemleak of rdev->serial
@ 2024-05-13 19:20 Jeremy Bongio
2024-05-13 20:53 ` Greg KH
2024-05-13 20:53 ` Greg KH
0 siblings, 2 replies; 14+ messages in thread
From: Jeremy Bongio @ 2024-05-13 19:20 UTC (permalink / raw)
To: stable; +Cc: Li Nan, Song Liu
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>
Signed-off-by: Song Liu <song@kernel.org>
Link: https://lore.kernel.org/r/20240208085556.2412922-1-linan666@huaweicloud.com
Change-Id: Icc4960dcaffedc663797e2d8b18a24c23e201932
---
drivers/md/md.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/md/md.c b/drivers/md/md.c
index 09c7f52156f3f..67ceab4573be4 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -2532,6 +2532,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, false);
return err;
}
--
2.45.0.118.g7fe29c98d7-goog
^ permalink raw reply related [flat|nested] 14+ messages in thread* Re: [PATCH] md: fix kmemleak of rdev->serial
2024-05-13 19:20 Jeremy Bongio
@ 2024-05-13 20:53 ` Greg KH
2024-05-13 21:40 ` Jeremy Bongio
2024-05-13 20:53 ` Greg KH
1 sibling, 1 reply; 14+ messages in thread
From: Greg KH @ 2024-05-13 20:53 UTC (permalink / raw)
To: Jeremy Bongio; +Cc: stable, Li Nan, Song Liu
On Mon, May 13, 2024 at 12:20:24PM -0700, Jeremy Bongio 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>
> Signed-off-by: Song Liu <song@kernel.org>
> Link: https://lore.kernel.org/r/20240208085556.2412922-1-linan666@huaweicloud.com
> Change-Id: Icc4960dcaffedc663797e2d8b18a24c23e201932
> ---
> drivers/md/md.c | 1 +
> 1 file changed, 1 insertion(+)
<formletter>
This is not the correct way to submit patches for inclusion in the
stable kernel tree. Please read:
https://www.kernel.org/doc/html/latest/process/stable-kernel-rules.html
for how to do this properly.
</formletter>
^ permalink raw reply [flat|nested] 14+ messages in thread* Re: [PATCH] md: fix kmemleak of rdev->serial
2024-05-13 20:53 ` Greg KH
@ 2024-05-13 21:40 ` Jeremy Bongio
0 siblings, 0 replies; 14+ messages in thread
From: Jeremy Bongio @ 2024-05-13 21:40 UTC (permalink / raw)
To: Greg KH; +Cc: stable, Li Nan, Song Liu
Resubmitted with
1. upstream sha1 line
2. explanation for why the backport differs from mainline
3. signoff
On Mon, May 13, 2024 at 1:53 PM Greg KH <gregkh@linuxfoundation.org> wrote:
>
> On Mon, May 13, 2024 at 12:20:24PM -0700, Jeremy Bongio 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>
> > Signed-off-by: Song Liu <song@kernel.org>
> > Link: https://lore.kernel.org/r/20240208085556.2412922-1-linan666@huaweicloud.com
> > Change-Id: Icc4960dcaffedc663797e2d8b18a24c23e201932
> > ---
> > drivers/md/md.c | 1 +
> > 1 file changed, 1 insertion(+)
>
>
> <formletter>
>
> This is not the correct way to submit patches for inclusion in the
> stable kernel tree. Please read:
> https://www.kernel.org/doc/html/latest/process/stable-kernel-rules.html
> for how to do this properly.
>
> </formletter>
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH] md: fix kmemleak of rdev->serial
2024-05-13 19:20 Jeremy Bongio
2024-05-13 20:53 ` Greg KH
@ 2024-05-13 20:53 ` Greg KH
1 sibling, 0 replies; 14+ messages in thread
From: Greg KH @ 2024-05-13 20:53 UTC (permalink / raw)
To: Jeremy Bongio; +Cc: stable, Li Nan, Song Liu
On Mon, May 13, 2024 at 12:20:24PM -0700, Jeremy Bongio 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>
> Signed-off-by: Song Liu <song@kernel.org>
> Link: https://lore.kernel.org/r/20240208085556.2412922-1-linan666@huaweicloud.com
> Change-Id: Icc4960dcaffedc663797e2d8b18a24c23e201932
Any specific reason you are not using your google.com email address to
properly sign off on commits?
confused,
greg k-h
^ permalink raw reply [flat|nested] 14+ messages in thread
end of thread, other threads:[~2024-05-20 22:18 UTC | newest]
Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-05-13 21:39 [PATCH] md: fix kmemleak of rdev->serial Jeremy Bongio
2024-05-13 22:24 ` Greg KH
2024-05-13 23:31 ` Jeremy Bongio
-- strict thread matches above, loose matches on Subject: below --
2024-05-13 23:30 Jeremy Bongio
2024-05-15 7:33 ` Greg KH
2024-05-15 16:31 ` Jeremy Bongio
2024-05-16 6:54 ` Greg KH
2024-05-20 22:18 ` Jeremy Bongio
2024-05-13 19:20 Jeremy Bongio
2024-05-13 20:53 ` Greg KH
2024-05-13 19:20 Jeremy Bongio
2024-05-13 20:53 ` Greg KH
2024-05-13 21:40 ` Jeremy Bongio
2024-05-13 20:53 ` Greg KH
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox