md: fix kmemleak of rdev->serial
Subsystems (2)
PATCH 1/1 md: fix kmemleak of rdev->serial
From: Li Nan <[email protected]>
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--- drivers/md/md.c | 1 + 1 file changed, 1 insertion(+)
drivers/md/md.c +1 -0
@@ -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; }
Signature · 1 line
2.45.0.118.g7fe29c98d7-goog
Greg KH
maintainerQuoted 26 lines · Jeremy Bongio
From: Li Nan <[email protected]>
If
kobject_add()is fail inbind_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
Quoted 8 lines
Fixes 963c555e75b0 ("md: introduce mddev_create/destroy_wb_pool for the change of member device")Signed-off-by Li Nan <[email protected]>Signed-off-by Song Liu <[email protected]>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>
Resubmitted with
1. upstream sha1 line
2. explanation for why the backport differs from mainline
3. signoff
Quoted 46 lines · Greg KH
Quoted 26 lines · Jeremy Bongio
From: Li Nan <[email protected]>
If
kobject_add()is fail inbind_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/0x74Quoted 8 lines
Fixes 963c555e75b0 ("md: introduce mddev_create/destroy_wb_pool for the change of member device")Signed-off-by Li Nan <[email protected]>Signed-off-by Song Liu <[email protected]>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>
Quoted 26 lines · Jeremy Bongio
From: Li Nan <[email protected]>
If
kobject_add()is fail inbind_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
Quoted 5 lines
Fixes 963c555e75b0 ("md: introduce mddev_create/destroy_wb_pool for the change of member device")Signed-off-by Li Nan <[email protected]>Signed-off-by Song Liu <[email protected]>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