George Kennedy
3cb5ae7779
tun: avoid double free in tun_free_netdev
...
commit 158b515f703e75e7d68289bf4d98c664e1d632df upstream.
Avoid double free in tun_free_netdev() by moving the
dev->tstats and tun->security allocs to a new ndo_init routine
(tun_net_init()) that will be called by register_netdevice().
ndo_init is paired with the desctructor (tun_free_netdev()),
so if there's an error in register_netdevice() the destructor
will handle the frees.
BUG: KASAN: double-free or invalid-free in selinux_tun_dev_free_security+0x1a/0x20 security/selinux/hooks.c:5605
CPU: 0 PID: 25750 Comm: syz-executor416 Not tainted 5.16.0-rc2-syzk #1
Hardware name: Red Hat KVM, BIOS
Call Trace:
<TASK>
__dump_stack lib/dump_stack.c:88 [inline]
dump_stack_lvl+0x89/0xb5 lib/dump_stack.c:106
print_address_description.constprop.9+0x28/0x160 mm/kasan/report.c:247
kasan_report_invalid_free+0x55/0x80 mm/kasan/report.c:372
____kasan_slab_free mm/kasan/common.c:346 [inline]
__kasan_slab_free+0x107/0x120 mm/kasan/common.c:374
kasan_slab_free include/linux/kasan.h:235 [inline]
slab_free_hook mm/slub.c:1723 [inline]
slab_free_freelist_hook mm/slub.c:1749 [inline]
slab_free mm/slub.c:3513 [inline]
kfree+0xac/0x2d0 mm/slub.c:4561
selinux_tun_dev_free_security+0x1a/0x20 security/selinux/hooks.c:5605
security_tun_dev_free_security+0x4f/0x90 security/security.c:2342
tun_free_netdev+0xe6/0x150 drivers/net/tun.c:2215
netdev_run_todo+0x4df/0x840 net/core/dev.c:10627
rtnl_unlock+0x13/0x20 net/core/rtnetlink.c:112
__tun_chr_ioctl+0x80c/0x2870 drivers/net/tun.c:3302
tun_chr_ioctl+0x2f/0x40 drivers/net/tun.c:3311
vfs_ioctl fs/ioctl.c:51 [inline]
__do_sys_ioctl fs/ioctl.c:874 [inline]
__se_sys_ioctl fs/ioctl.c:860 [inline]
__x64_sys_ioctl+0x19d/0x220 fs/ioctl.c:860
do_syscall_x64 arch/x86/entry/common.c:50 [inline]
do_syscall_64+0x3a/0x80 arch/x86/entry/common.c:80
entry_SYSCALL_64_after_hwframe+0x44/0xae
Reported-by: syzkaller <syzkaller@googlegroups.com>
Signed-off-by: George Kennedy <george.kennedy@oracle.com>
Suggested-by: Jakub Kicinski <kuba@kernel.org>
Link: https://lore.kernel.org/r/1639679132-19884-1-git-send-email-george.kennedy@oracle.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-12-29 12:29:03 +01:00
..
2021-12-01 09:04:38 +01:00
2021-11-06 14:13:31 +01:00
2021-12-14 10:57:15 +01:00
2021-12-22 09:32:49 +01:00
2021-11-18 19:17:02 +01:00
2021-12-29 12:28:38 +01:00
2021-09-01 08:44:42 -07:00
2021-12-22 09:32:51 +01:00
2021-11-21 13:44:13 +01:00
2021-12-29 12:28:38 +01:00
2021-12-29 12:28:53 +01:00
2021-12-22 09:32:39 +01:00
2021-12-14 10:57:23 +01:00
2021-11-12 15:05:51 +01:00
2021-12-08 09:04:42 +01:00
2021-11-18 19:16:29 +01:00
2021-11-18 19:16:33 +01:00
2021-11-18 19:16:04 +01:00
2021-09-09 11:39:57 -07:00
2021-09-08 11:50:26 -07:00
2021-12-22 09:32:41 +01:00
2021-12-08 09:04:42 +01:00
2021-11-18 19:16:30 +01:00
2021-09-11 09:47:33 -07:00
2021-12-22 09:32:35 +01:00
2021-09-27 14:00:41 -07:00
2021-12-29 12:28:56 +01:00
2021-12-29 12:28:39 +01:00
2021-12-29 12:28:37 +01:00
2021-11-25 09:48:46 +01:00
2021-12-29 12:29:02 +01:00
2021-11-18 19:16:06 +01:00
2021-12-17 10:30:15 +01:00
2021-12-14 10:57:21 +01:00
2021-12-29 12:28:40 +01:00
2021-12-29 12:29:00 +01:00
2021-09-13 15:49:55 +03:00
2021-12-01 09:04:55 +01:00
2021-09-27 17:38:49 +02:00
2021-12-14 10:57:23 +01:00
2021-10-19 13:09:28 +01:00
2021-08-20 11:00:08 +02:00
2021-09-14 13:23:22 -07:00
2021-11-18 19:16:35 +01:00
2021-09-14 11:22:26 +02:00
2021-12-22 09:32:36 +01:00
2021-12-22 09:32:50 +01:00
2021-11-25 09:48:30 +01:00
2021-11-18 19:16:32 +01:00
2021-11-18 19:17:17 +01:00
2021-12-14 10:57:23 +01:00
2021-12-29 12:28:57 +01:00
2021-11-18 19:16:08 +01:00
2021-12-17 10:30:13 +01:00
2021-12-29 12:29:03 +01:00
2021-11-18 19:17:10 +01:00
2021-09-07 13:05:02 -07:00
2021-11-18 19:17:07 +01:00
2021-12-01 09:04:52 +01:00
2021-10-13 15:09:58 +02:00
2021-11-18 19:16:45 +01:00
2021-11-18 19:17:00 +01:00
2021-09-09 12:44:31 +02:00
2021-09-02 13:16:00 -07:00
2021-12-22 09:32:46 +01:00
2021-09-20 12:43:34 +01:00
2021-11-18 19:16:56 +01:00
2021-12-29 12:29:01 +01:00
2021-12-29 12:28:54 +01:00
2021-11-18 19:16:58 +01:00
2021-08-25 20:12:16 +02:00
2021-11-25 09:48:40 +01:00
2021-09-02 22:27:46 +02:00
2021-11-18 19:15:57 +01:00
2021-11-18 19:17:18 +01:00
2021-12-22 09:32:33 +01:00
2021-11-18 19:17:01 +01:00
2021-11-18 19:17:18 +01:00
2021-12-22 09:32:51 +01:00
2021-11-25 09:48:31 +01:00
2021-09-01 08:44:42 -07:00
2021-12-22 09:32:43 +01:00
2021-11-18 19:16:54 +01:00
2021-12-29 12:28:39 +01:00
2021-12-17 10:30:16 +01:00
2021-11-25 09:48:29 +01:00
2021-12-29 12:28:59 +01:00
2021-12-14 10:57:14 +01:00
2021-10-06 17:53:49 -06:00
2021-12-22 09:32:52 +01:00
2021-12-22 09:32:50 +01:00
2021-12-22 09:32:39 +01:00
2021-09-23 14:12:36 -06:00
2021-12-22 09:32:36 +01:00
2021-12-08 09:04:55 +01:00
2021-12-22 09:32:36 +01:00
2021-11-18 19:17:03 +01:00
2021-12-22 09:32:52 +01:00
2021-10-07 16:51:26 +02:00
2021-12-22 09:32:39 +01:00