syzbot


KASAN: use-after-free Read in __netif_napi_del

Status: auto-closed as invalid on 2022/03/02 04:36
Reported-by: syzbot+@syzkaller.appspotmail.com
First crash: 394d, last: 366d
similar bugs (2):
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
upstream BUG: corrupted list in __netif_napi_del (3) 1 16d 15d 0/24 upstream: reported on 2022/11/18 10:38
upstream BUG: corrupted list in __netif_napi_del (2) 3 565d 611d 0/24 auto-closed as invalid on 2021/08/14 18:06

Sample crash report:
==================================================================
BUG: KASAN: use-after-free in __list_del_entry_valid+0x98/0x100 lib/list_debug.c:54
Read of size 8 at addr ffff888081b7c780 by task syz-executor.5/21195

CPU: 0 PID: 21195 Comm: syz-executor.5 Not tainted 5.15.0-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
Call Trace:
 <TASK>
 __dump_stack lib/dump_stack.c:88 [inline]
 dump_stack_lvl+0x1dc/0x2d8 lib/dump_stack.c:106
 print_address_description+0x66/0x3e0 mm/kasan/report.c:256
 __kasan_report mm/kasan/report.c:442 [inline]
 kasan_report+0x19a/0x1f0 mm/kasan/report.c:459
 __list_del_entry_valid+0x98/0x100 lib/list_debug.c:54
 __list_del_entry include/linux/list.h:132 [inline]
 list_del_rcu include/linux/rculist.h:157 [inline]
 __netif_napi_del+0x11f/0x7d0 net/core/dev.c:6990
 netif_napi_del include/linux/netdevice.h:2519 [inline]
 tun_napi_del drivers/net/tun.c:280 [inline]
 __tun_detach+0x145/0x1d40 drivers/net/tun.c:633
 tun_detach drivers/net/tun.c:687 [inline]
 tun_chr_close+0xed/0x130 drivers/net/tun.c:3397
 __fput+0x3fc/0x870 fs/file_table.c:280
 task_work_run+0x146/0x1c0 kernel/task_work.c:164
 tracehook_notify_resume include/linux/tracehook.h:189 [inline]
 exit_to_user_mode_loop kernel/entry/common.c:175 [inline]
 exit_to_user_mode_prepare+0x209/0x220 kernel/entry/common.c:207
 __syscall_exit_to_user_mode_work kernel/entry/common.c:289 [inline]
 syscall_exit_to_user_mode+0x2e/0x70 kernel/entry/common.c:300
 do_syscall_64+0x53/0xd0 arch/x86/entry/common.c:86
 entry_SYSCALL_64_after_hwframe+0x44/0xae
RIP: 0033:0x7fc976aa872b
Code: 0f 05 48 3d 00 f0 ff ff 77 45 c3 0f 1f 40 00 48 83 ec 18 89 7c 24 0c e8 63 fc ff ff 8b 7c 24 0c 41 89 c0 b8 03 00 00 00 0f 05 <48> 3d 00 f0 ff ff 77 35 44 89 c7 89 44 24 0c e8 a1 fc ff ff 8b 44
RSP: 002b:00007ffe2bbe8df0 EFLAGS: 00000293 ORIG_RAX: 0000000000000003
RAX: 0000000000000000 RBX: 0000000000000005 RCX: 00007fc976aa872b
RDX: 0000000000000000 RSI: ffffffff81b90156 RDI: 0000000000000004
RBP: 0000000000000001 R08: 0000000000000000 R09: 0000001b33a23edc
R10: 0000000000000a24 R11: 0000000000000293 R12: 00007fc976c09b60
R13: 00007fc976c09b60 R14: 00007fc976c08f60 R15: 000000000007179d
 </TASK>

Allocated by task 21197:
 kasan_save_stack mm/kasan/common.c:38 [inline]
 kasan_set_track mm/kasan/common.c:46 [inline]
 set_alloc_info mm/kasan/common.c:434 [inline]
 ____kasan_kmalloc+0xdc/0x110 mm/kasan/common.c:513
 kasan_kmalloc include/linux/kasan.h:269 [inline]
 __kmalloc+0x24b/0x370 mm/slub.c:4400
 kmalloc include/linux/slab.h:596 [inline]
 sk_prot_alloc+0xf4/0x230 net/core/sock.c:1920
 sk_alloc+0x35/0x300 net/core/sock.c:1973
 tun_chr_open+0x77/0x470 drivers/net/tun.c:3361
 misc_open+0x346/0x3c0 drivers/char/misc.c:141
 chrdev_open+0x5fb/0x680 fs/char_dev.c:414
 do_dentry_open+0x7cb/0x1020 fs/open.c:822
 do_open fs/namei.c:3426 [inline]
 path_openat+0x28b4/0x3670 fs/namei.c:3559
 do_filp_open+0x277/0x4f0 fs/namei.c:3586
 do_sys_openat2+0x13b/0x500 fs/open.c:1200
 do_sys_open fs/open.c:1216 [inline]
 __do_sys_openat fs/open.c:1232 [inline]
 __se_sys_openat fs/open.c:1227 [inline]
 __x64_sys_openat+0x243/0x290 fs/open.c:1227
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x44/0xd0 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x44/0xae

Freed by task 21201:
 kasan_save_stack mm/kasan/common.c:38 [inline]
 kasan_set_track+0x4c/0x80 mm/kasan/common.c:46
 kasan_set_free_info+0x1f/0x40 mm/kasan/generic.c:360
 ____kasan_slab_free+0x10d/0x150 mm/kasan/common.c:366
 kasan_slab_free include/linux/kasan.h:235 [inline]
 slab_free_hook mm/slub.c:1700 [inline]
 slab_free_freelist_hook+0x12e/0x1a0 mm/slub.c:1726
 slab_free mm/slub.c:3492 [inline]
 kfree+0xe1/0x310 mm/slub.c:4552
 sk_prot_free net/core/sock.c:1956 [inline]
 __sk_destruct+0x575/0x820 net/core/sock.c:2042
 tun_detach drivers/net/tun.c:687 [inline]
 tun_chr_close+0xed/0x130 drivers/net/tun.c:3397
 __fput+0x3fc/0x870 fs/file_table.c:280
 task_work_run+0x146/0x1c0 kernel/task_work.c:164
 tracehook_notify_resume include/linux/tracehook.h:189 [inline]
 exit_to_user_mode_loop kernel/entry/common.c:175 [inline]
 exit_to_user_mode_prepare+0x209/0x220 kernel/entry/common.c:207
 __syscall_exit_to_user_mode_work kernel/entry/common.c:289 [inline]
 syscall_exit_to_user_mode+0x2e/0x70 kernel/entry/common.c:300
 do_syscall_64+0x53/0xd0 arch/x86/entry/common.c:86
 entry_SYSCALL_64_after_hwframe+0x44/0xae

The buggy address belongs to the object at ffff888081b7c000
 which belongs to the cache kmalloc-4k of size 4096
The buggy address is located 1920 bytes inside of
 4096-byte region [ffff888081b7c000, ffff888081b7d000)
The buggy address belongs to the page:
page:ffffea000206de00 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x81b78
head:ffffea000206de00 order:3 compound_mapcount:0 compound_pincount:0
flags: 0xfff00000010200(slab|head|node=0|zone=1|lastcpupid=0x7ff)
raw: 00fff00000010200 0000000000000000 0000000100000001 ffff888011442140
raw: 0000000000000000 0000000000040004 00000001ffffffff 0000000000000000
page dumped because: kasan: bad access detected
page_owner tracks the page as allocated
page last allocated via order 3, migratetype Unmovable, gfp_mask 0xd2040(__GFP_IO|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP|__GFP_NOMEMALLOC), pid 2938, ts 180427880078, free_ts 180392188534
 prep_new_page mm/page_alloc.c:2426 [inline]
 get_page_from_freelist+0x779/0xa30 mm/page_alloc.c:4155
 __alloc_pages+0x255/0x580 mm/page_alloc.c:5381
 alloc_slab_page mm/slub.c:1770 [inline]
 allocate_slab+0xcc/0x4d0 mm/slub.c:1907
 new_slab mm/slub.c:1970 [inline]
 ___slab_alloc+0x41e/0xc40 mm/slub.c:3001
 __slab_alloc mm/slub.c:3088 [inline]
 slab_alloc_node mm/slub.c:3179 [inline]
 slab_alloc mm/slub.c:3221 [inline]
 __kmalloc+0x2e7/0x370 mm/slub.c:4396
 kmalloc include/linux/slab.h:596 [inline]
 tomoyo_realpath_from_path+0xd8/0x610 security/tomoyo/realpath.c:254
 tomoyo_get_realpath security/tomoyo/file.c:151 [inline]
 tomoyo_path_perm+0x238/0x660 security/tomoyo/file.c:822
 security_inode_getattr+0xc0/0x140 security/security.c:1334
 vfs_getattr fs/stat.c:157 [inline]
 vfs_statx+0x168/0x3f0 fs/stat.c:225
 vfs_fstatat fs/stat.c:243 [inline]
 vfs_lstat include/linux/fs.h:3356 [inline]
 __do_sys_newlstat fs/stat.c:398 [inline]
 __se_sys_newlstat+0xba/0x750 fs/stat.c:392
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x44/0xd0 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x44/0xae
page last free stack trace:
 reset_page_owner include/linux/page_owner.h:24 [inline]
 free_pages_prepare mm/page_alloc.c:1340 [inline]
 free_pcp_prepare+0xd5a/0xe50 mm/page_alloc.c:1391
 free_unref_page_prepare mm/page_alloc.c:3317 [inline]
 free_unref_page+0x7d/0x580 mm/page_alloc.c:3396
 free_slab mm/slub.c:2010 [inline]
 discard_slab mm/slub.c:2016 [inline]
 __unfreeze_partials+0x1ab/0x200 mm/slub.c:2502
 put_cpu_partial+0x132/0x1a0 mm/slub.c:2582
 do_slab_free mm/slub.c:3480 [inline]
 ___cache_free+0xe6/0x120 mm/slub.c:3499
 qlist_free_all mm/kasan/quarantine.c:165 [inline]
 kasan_quarantine_reduce+0x151/0x1c0 mm/kasan/quarantine.c:272
 __kasan_slab_alloc+0x2f/0xe0 mm/kasan/common.c:444
 kasan_slab_alloc include/linux/kasan.h:259 [inline]
 slab_post_alloc_hook mm/slab.h:519 [inline]
 slab_alloc_node mm/slub.c:3213 [inline]
 slab_alloc mm/slub.c:3221 [inline]
 kmem_cache_alloc+0x1c1/0x300 mm/slub.c:3226
 kmem_cache_zalloc include/linux/slab.h:711 [inline]
 ext4_init_io_end+0x25/0x120 fs/ext4/page-io.c:276
 ext4_writepages+0xd2d/0x4080 fs/ext4/inode.c:2764
 do_writepages+0x3a9/0x670 mm/page-writeback.c:2364
 filemap_fdatawrite_wbc+0x11e/0x170 mm/filemap.c:399
 __filemap_fdatawrite_range mm/filemap.c:432 [inline]
 filemap_write_and_wait_range+0x1b2/0x2a0 mm/filemap.c:703
 filemap_write_and_wait include/linux/fs.h:2865 [inline]
 swap_inode_boot_loader fs/ext4/ioctl.c:152 [inline]
 __ext4_ioctl fs/ext4/ioctl.c:1054 [inline]
 ext4_ioctl+0x385b/0x5520 fs/ext4/ioctl.c:1279
 vfs_ioctl fs/ioctl.c:51 [inline]
 __do_sys_ioctl fs/ioctl.c:874 [inline]
 __se_sys_ioctl+0xfb/0x170 fs/ioctl.c:860
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x44/0xd0 arch/x86/entry/common.c:80

Memory state around the buggy address:
 ffff888081b7c680: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff888081b7c700: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff888081b7c780: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                   ^
 ffff888081b7c800: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff888081b7c880: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================

Crashes (5):
Manager Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Title
ci-upstream-kasan-gce-smack-root 2021/11/03 15:20 upstream dcd68326d29b 4c1be0be .config log report info KASAN: use-after-free Read in __netif_napi_del
ci-upstream-kasan-gce-root 2021/12/02 04:28 upstream 58e1100fdc59 61f86278 .config log report info general protection fault in __netif_napi_del
ci-upstream-net-this-kasan-gce 2021/11/30 18:52 net 1a59c9c55585 80270552 .config log report info general protection fault in __netif_napi_del
ci-upstream-bpf-kasan-gce 2021/11/06 22:40 bpf 70bf363d7adb 4c1be0be .config log report info BUG: unable to handle kernel paging request in __netif_napi_del
ci-upstream-net-kasan-gce 2021/11/30 22:38 net-next 72a2ff567fc3 80270552 .config log report info general protection fault in __netif_napi_del
* Struck through repros no longer work on HEAD.