Yang Yingliang
814152a89e
net: fix memleak in register_netdevice()
...
I got a memleak report when doing some fuzz test:
unreferenced object 0xffff888112584000 (size 13599):
comm "ip", pid 3048, jiffies 4294911734 (age 343.491s)
hex dump (first 32 bytes):
74 61 70 30 00 00 00 00 00 00 00 00 00 00 00 00 tap0............
00 ee d9 19 81 88 ff ff 00 00 00 00 00 00 00 00 ................
backtrace:
[<000000002f60ba65>] __kmalloc_node+0x309/0x3a0
[<0000000075b211ec>] kvmalloc_node+0x7f/0xc0
[<00000000d3a97396>] alloc_netdev_mqs+0x76/0xfc0
[<00000000609c3655>] __tun_chr_ioctl+0x1456/0x3d70
[<000000001127ca24>] ksys_ioctl+0xe5/0x130
[<00000000b7d5e66a>] __x64_sys_ioctl+0x6f/0xb0
[<00000000e1023498>] do_syscall_64+0x56/0xa0
[<000000009ec0eb12>] entry_SYSCALL_64_after_hwframe+0x44/0xa9
unreferenced object 0xffff888111845cc0 (size 8):
comm "ip", pid 3048, jiffies 4294911734 (age 343.491s)
hex dump (first 8 bytes):
74 61 70 30 00 88 ff ff tap0....
backtrace:
[<000000004c159777>] kstrdup+0x35/0x70
[<00000000d8b496ad>] kstrdup_const+0x3d/0x50
[<00000000494e884a>] kvasprintf_const+0xf1/0x180
[<0000000097880a2b>] kobject_set_name_vargs+0x56/0x140
[<000000008fbdfc7b>] dev_set_name+0xab/0xe0
[<000000005b99e3b4>] netdev_register_kobject+0xc0/0x390
[<00000000602704fe>] register_netdevice+0xb61/0x1250
[<000000002b7ca244>] __tun_chr_ioctl+0x1cd1/0x3d70
[<000000001127ca24>] ksys_ioctl+0xe5/0x130
[<00000000b7d5e66a>] __x64_sys_ioctl+0x6f/0xb0
[<00000000e1023498>] do_syscall_64+0x56/0xa0
[<000000009ec0eb12>] entry_SYSCALL_64_after_hwframe+0x44/0xa9
unreferenced object 0xffff88811886d800 (size 512):
comm "ip", pid 3048, jiffies 4294911734 (age 343.491s)
hex dump (first 32 bytes):
00 00 00 00 ad 4e ad de ff ff ff ff 00 00 00 00 .....N..........
ff ff ff ff ff ff ff ff c0 66 3d a3 ff ff ff ff .........f=.....
backtrace:
[<0000000050315800>] device_add+0x61e/0x1950
[<0000000021008dfb>] netdev_register_kobject+0x17e/0x390
[<00000000602704fe>] register_netdevice+0xb61/0x1250
[<000000002b7ca244>] __tun_chr_ioctl+0x1cd1/0x3d70
[<000000001127ca24>] ksys_ioctl+0xe5/0x130
[<00000000b7d5e66a>] __x64_sys_ioctl+0x6f/0xb0
[<00000000e1023498>] do_syscall_64+0x56/0xa0
[<000000009ec0eb12>] entry_SYSCALL_64_after_hwframe+0x44/0xa9
If call_netdevice_notifiers() failed, then rollback_registered()
calls netdev_unregister_kobject() which holds the kobject. The
reference cannot be put because the netdev won't be add to todo
list, so it will leads a memleak, we need put the reference to
avoid memleak.
Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2020-06-18 20:05:54 -07:00
..
2020-05-15 17:29:41 +02:00
2020-03-25 11:30:40 -07:00
2019-03-27 13:49:44 -07:00
2020-06-09 12:59:45 -07:00
2020-03-29 22:32:36 -07:00
2020-06-18 20:05:54 -07:00
2020-06-01 11:49:23 -07:00
2020-05-01 15:45:16 -07:00
2019-05-30 11:26:32 -07:00
2020-05-08 21:33:33 -07:00
2019-04-10 22:12:26 -07:00
2019-10-04 11:10:56 -07:00
2020-02-16 18:38:24 -08:00
2020-06-13 15:28:08 -07:00
2020-06-01 15:21:02 -07:00
2020-06-01 11:41:50 -07:00
2019-11-06 21:51:36 -08:00
2020-04-28 14:39:46 -07:00
2019-03-10 11:07:14 -07:00
2019-06-09 19:40:10 -07:00
2020-04-20 12:43:24 -07:00
2020-03-29 22:30:57 -07:00
2020-03-29 22:30:57 -07:00
2019-12-12 17:07:05 -08:00
2020-05-31 17:48:46 -07:00
2020-05-09 13:57:12 +02:00
2019-10-01 14:47:19 -07:00
2020-05-15 10:18:49 -07:00
2020-02-26 20:07:25 -08:00
2019-06-19 11:23:13 -04:00
2020-04-21 15:44:30 -07:00
2019-05-30 11:26:32 -07:00
2020-05-07 18:11:07 -07:00
2020-05-09 20:59:21 -07:00
2020-03-29 21:49:20 -07:00
2020-04-30 12:56:37 -07:00
2019-06-05 17:36:38 +02:00
2019-10-13 10:13:08 -07:00
2020-06-09 12:59:45 -07:00
2020-05-13 12:30:54 -07:00
2020-05-08 15:32:17 +10:00
2020-05-19 19:55:36 -07:00
2020-06-01 14:48:32 -07:00
2019-08-09 13:14:46 -07:00
2020-06-12 15:21:29 -07:00
2020-02-21 22:29:45 +01:00
2020-06-01 14:57:14 -07:00
2019-08-19 13:07:43 -07:00
2020-06-10 16:05:54 -07:00
2019-12-25 19:51:33 -08:00
2019-07-22 20:47:56 -07:00
2020-01-24 20:54:30 +01:00
2020-06-17 09:58:15 -07:00