syzbot


KASAN: use-after-free Read in __napi_schedule

Status: auto-closed as invalid on 2022/01/19 12:57
Reported-by: syzbot+@syzkaller.appspotmail.com
First crash: 407d, last: 407d

Sample crash report:
==================================================================
BUG: KASAN: use-after-free in __list_add_valid+0x93/0xa0 lib/list_debug.c:26
Read of size 8 at addr ffff88807e8d45d8 by task syz-fuzzer/3788

CPU: 0 PID: 3788 Comm: syz-fuzzer Not tainted 5.15.0-rc5-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
Call Trace:
 <IRQ>
 __dump_stack lib/dump_stack.c:88 [inline]
 dump_stack_lvl+0xcd/0x134 lib/dump_stack.c:106
 print_address_description.constprop.0.cold+0x6c/0x309 mm/kasan/report.c:256
 __kasan_report mm/kasan/report.c:442 [inline]
 kasan_report.cold+0x83/0xdf mm/kasan/report.c:459
 __list_add_valid+0x93/0xa0 lib/list_debug.c:26
 __list_add include/linux/list.h:67 [inline]
 list_add_tail include/linux/list.h:100 [inline]
 ____napi_schedule net/core/dev.c:4346 [inline]
 ____napi_schedule net/core/dev.c:4320 [inline]
 __napi_schedule+0x186/0x360 net/core/dev.c:6489
 virtqueue_napi_schedule drivers/net/virtio_net.c:329 [inline]
 skb_xmit_done+0x1d5/0x240 drivers/net/virtio_net.c:356
 vring_interrupt drivers/virtio/virtio_ring.c:2155 [inline]
 vring_interrupt+0x279/0x400 drivers/virtio/virtio_ring.c:2137
 __handle_irq_event_percpu+0x303/0x8f0 kernel/irq/handle.c:156
 handle_irq_event_percpu kernel/irq/handle.c:196 [inline]
 handle_irq_event+0x102/0x280 kernel/irq/handle.c:213
 handle_edge_irq+0x25f/0xd00 kernel/irq/chip.c:822
 generic_handle_irq_desc include/linux/irqdesc.h:158 [inline]
 handle_irq arch/x86/kernel/irq.c:231 [inline]
 __common_interrupt+0x9d/0x210 arch/x86/kernel/irq.c:250
 common_interrupt+0x9f/0xd0 arch/x86/kernel/irq.c:240
 </IRQ>
 asm_common_interrupt+0x1e/0x40 arch/x86/include/asm/idtentry.h:629
RIP: 0010:__raw_spin_unlock_irqrestore include/linux/spinlock_api_smp.h:161 [inline]
RIP: 0010:_raw_spin_unlock_irqrestore+0x38/0x70 kernel/locking/spinlock.c:194
Code: 74 24 10 e8 fa 05 21 f8 48 89 ef e8 42 7c 21 f8 81 e3 00 02 00 00 75 25 9c 58 f6 c4 02 75 2d 48 85 db 74 01 fb bf 01 00 00 00 <e8> 83 67 14 f8 65 8b 05 7c be c6 76 85 c0 74 0a 5b 5d c3 e8 90 dd
RSP: 0018:ffffc900067bf5e8 EFLAGS: 00000206
RAX: 0000000000000002 RBX: 0000000000000200 RCX: 1ffffffff1faa502
RDX: 0000000000000000 RSI: 0000000000000001 RDI: 0000000000000001
RBP: ffffffff9045d508 R08: 0000000000000001 R09: ffffffff8fd0ca9f
R10: 0000000000000001 R11: 000000000000003f R12: 0000000000000006
R13: 0000000000000006 R14: dead000000000100 R15: dffffc0000000000
 __debug_check_no_obj_freed lib/debugobjects.c:1002 [inline]
 debug_check_no_obj_freed+0x20c/0x420 lib/debugobjects.c:1023
 slab_free_hook mm/slub.c:1675 [inline]
 slab_free_freelist_hook+0xde/0x190 mm/slub.c:1725
 slab_free mm/slub.c:3483 [inline]
 kmem_cache_free+0x8a/0x5b0 mm/slub.c:3499
 kfree_skbmem+0xef/0x1b0 net/core/skbuff.c:698
 __kfree_skb net/core/skbuff.c:755 [inline]
 kfree_skb_partial+0x8b/0xa0 net/core/skbuff.c:5340
 tcp_data_queue+0x2371/0x4b90 net/ipv4/tcp_input.c:5045
 tcp_rcv_established+0x8ad/0x2130 net/ipv4/tcp_input.c:5945
 tcp_v4_do_rcv+0x5d4/0x880 net/ipv4/tcp_ipv4.c:1694
 sk_backlog_rcv include/net/sock.h:1025 [inline]
 __release_sock+0x134/0x3b0 net/core/sock.c:2768
 release_sock+0x54/0x1b0 net/core/sock.c:3300
 tcp_recvmsg+0x136/0x550 net/ipv4/tcp.c:2537
 inet_recvmsg+0x11b/0x5e0 net/ipv4/af_inet.c:848
 sock_recvmsg_nosec net/socket.c:944 [inline]
 sock_recvmsg net/socket.c:962 [inline]
 sock_recvmsg net/socket.c:958 [inline]
 sock_read_iter+0x33c/0x470 net/socket.c:1035
 call_read_iter include/linux/fs.h:2157 [inline]
 new_sync_read+0x5ba/0x6e0 fs/read_write.c:404
 vfs_read+0x35c/0x600 fs/read_write.c:485
 ksys_read+0x1ee/0x250 fs/read_write.c:623
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x44/0xae
RIP: 0033:0x4b129b
Code: fb ff eb bd e8 46 96 fb ff e9 61 ff ff ff cc e8 3b 62 fb ff 48 8b 7c 24 10 48 8b 74 24 18 48 8b 54 24 20 48 8b 44 24 08 0f 05 <48> 3d 01 f0 ff ff 76 20 48 c7 44 24 28 ff ff ff ff 48 c7 44 24 30
RSP: 002b:000000c00031b8b8 EFLAGS: 00000212 ORIG_RAX: 0000000000000000
RAX: ffffffffffffffda RBX: 000000c00001e800 RCX: 00000000004b129b
RDX: 0000000000001000 RSI: 000000c00010e000 RDI: 0000000000000006
RBP: 000000c00031b908 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000212 R12: 0000000000000003
R13: 000000c005d3aa80 R14: 000000c005ca0900 R15: 0000000000000000

Allocated by task 20918:
 kasan_save_stack+0x1b/0x40 mm/kasan/common.c:38
 kasan_set_track mm/kasan/common.c:46 [inline]
 set_alloc_info mm/kasan/common.c:434 [inline]
 ____kasan_kmalloc mm/kasan/common.c:513 [inline]
 ____kasan_kmalloc mm/kasan/common.c:472 [inline]
 __kasan_kmalloc+0xa4/0xd0 mm/kasan/common.c:522
 kmalloc include/linux/slab.h:596 [inline]
 sk_prot_alloc+0x110/0x290 net/core/sock.c:1920
 sk_alloc+0x30/0xa60 net/core/sock.c:1973
 tun_chr_open+0x7b/0x540 drivers/net/tun.c:3361
 misc_open+0x372/0x4a0 drivers/char/misc.c:141
 chrdev_open+0x266/0x770 fs/char_dev.c:414
 do_dentry_open+0x4c8/0x11d0 fs/open.c:822
 do_open fs/namei.c:3428 [inline]
 path_openat+0x1c9a/0x2740 fs/namei.c:3561
 do_filp_open+0x1aa/0x400 fs/namei.c:3588
 do_sys_openat2+0x16d/0x4d0 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+0x13f/0x1f0 fs/open.c:1227
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x44/0xae

Freed by task 20915:
 kasan_save_stack+0x1b/0x40 mm/kasan/common.c:38
 kasan_set_track+0x1c/0x30 mm/kasan/common.c:46
 kasan_set_free_info+0x20/0x30 mm/kasan/generic.c:360
 ____kasan_slab_free mm/kasan/common.c:366 [inline]
 ____kasan_slab_free mm/kasan/common.c:328 [inline]
 __kasan_slab_free+0xff/0x130 mm/kasan/common.c:374
 kasan_slab_free include/linux/kasan.h:230 [inline]
 slab_free_hook mm/slub.c:1700 [inline]
 slab_free_freelist_hook+0x81/0x190 mm/slub.c:1725
 slab_free mm/slub.c:3483 [inline]
 kfree+0xe4/0x530 mm/slub.c:4543
 sk_prot_free net/core/sock.c:1956 [inline]
 __sk_destruct+0x6a8/0x900 net/core/sock.c:2042
 sk_destruct+0xbd/0xe0 net/core/sock.c:2057
 __sk_free+0xef/0x3d0 net/core/sock.c:2068
 sk_free+0x78/0xa0 net/core/sock.c:2079
 sock_put include/net/sock.h:1870 [inline]
 __tun_detach+0xdb2/0x13d0 drivers/net/tun.c:675
 tun_detach drivers/net/tun.c:687 [inline]
 tun_chr_close+0xc4/0x180 drivers/net/tun.c:3397
 __fput+0x288/0x9f0 fs/file_table.c:280
 task_work_run+0xdd/0x1a0 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+0x27e/0x290 kernel/entry/common.c:207
 __syscall_exit_to_user_mode_work kernel/entry/common.c:289 [inline]
 syscall_exit_to_user_mode+0x19/0x60 kernel/entry/common.c:300
 do_syscall_64+0x42/0xb0 arch/x86/entry/common.c:86
 entry_SYSCALL_64_after_hwframe+0x44/0xae

The buggy address belongs to the object at ffff88807e8d4000
 which belongs to the cache kmalloc-4k of size 4096
The buggy address is located 1496 bytes inside of
 4096-byte region [ffff88807e8d4000, ffff88807e8d5000)
The buggy address belongs to the page:
page:ffffea0001fa3400 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x7e8d0
head:ffffea0001fa3400 order:3 compound_mapcount:0 compound_pincount:0
flags: 0xfff00000010200(slab|head|node=0|zone=1|lastcpupid=0x7ff)
raw: 00fff00000010200 dead000000000100 dead000000000122 ffff888010c42140
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 0xd20c0(__GFP_IO|__GFP_FS|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP|__GFP_NOMEMALLOC), pid 1, ts 15085499407, free_ts 13424996726
 prep_new_page mm/page_alloc.c:2424 [inline]
 get_page_from_freelist+0xa72/0x2f80 mm/page_alloc.c:4153
 __alloc_pages+0x1b2/0x500 mm/page_alloc.c:5375
 alloc_pages+0x1a7/0x300 mm/mempolicy.c:2197
 alloc_slab_page mm/slub.c:1763 [inline]
 allocate_slab mm/slub.c:1900 [inline]
 new_slab+0x319/0x490 mm/slub.c:1963
 ___slab_alloc+0x921/0xfe0 mm/slub.c:2994
 __slab_alloc.constprop.0+0x4d/0xa0 mm/slub.c:3081
 slab_alloc_node mm/slub.c:3172 [inline]
 slab_alloc mm/slub.c:3214 [inline]
 kmem_cache_alloc_trace+0x293/0x2b0 mm/slub.c:3231
 kmalloc include/linux/slab.h:591 [inline]
 copy_mount_options+0x55/0x180 fs/namespace.c:3196
 __do_sys_mount fs/namespace.c:3534 [inline]
 __se_sys_mount fs/namespace.c:3516 [inline]
 __x64_sys_mount+0x1a9/0x300 fs/namespace.c:3516
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x35/0xb0 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:1338 [inline]
 free_pcp_prepare+0x2c5/0x780 mm/page_alloc.c:1389
 free_unref_page_prepare mm/page_alloc.c:3315 [inline]
 free_unref_page+0x19/0x690 mm/page_alloc.c:3394
 free_contig_range+0xa8/0xf0 mm/page_alloc.c:9254
 destroy_args+0xa8/0x646 mm/debug_vm_pgtable.c:1016
 debug_vm_pgtable+0x295b/0x29ed mm/debug_vm_pgtable.c:1329
 do_one_initcall+0x103/0x650 init/main.c:1303
 do_initcall_level init/main.c:1376 [inline]
 do_initcalls init/main.c:1392 [inline]
 do_basic_setup init/main.c:1411 [inline]
 kernel_init_freeable+0x6b1/0x73a init/main.c:1614
 kernel_init+0x1a/0x1d0 init/main.c:1505
 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:295

Memory state around the buggy address:
 ffff88807e8d4480: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff88807e8d4500: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff88807e8d4580: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                                                    ^
 ffff88807e8d4600: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff88807e8d4680: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================
----------------
Code disassembly (best guess):
   0:	74 24                	je     0x26
   2:	10 e8                	adc    %ch,%al
   4:	fa                   	cli
   5:	05 21 f8 48 89       	add    $0x8948f821,%eax
   a:	ef                   	out    %eax,(%dx)
   b:	e8 42 7c 21 f8       	callq  0xf8217c52
  10:	81 e3 00 02 00 00    	and    $0x200,%ebx
  16:	75 25                	jne    0x3d
  18:	9c                   	pushfq
  19:	58                   	pop    %rax
  1a:	f6 c4 02             	test   $0x2,%ah
  1d:	75 2d                	jne    0x4c
  1f:	48 85 db             	test   %rbx,%rbx
  22:	74 01                	je     0x25
  24:	fb                   	sti
  25:	bf 01 00 00 00       	mov    $0x1,%edi
* 2a:	e8 83 67 14 f8       	callq  0xf81467b2 <-- trapping instruction
  2f:	65 8b 05 7c be c6 76 	mov    %gs:0x76c6be7c(%rip),%eax        # 0x76c6beb2
  36:	85 c0                	test   %eax,%eax
  38:	74 0a                	je     0x44
  3a:	5b                   	pop    %rbx
  3b:	5d                   	pop    %rbp
  3c:	c3                   	retq
  3d:	e8                   	.byte 0xe8
  3e:	90                   	nop
  3f:	dd                   	.byte 0xdd

Crashes (1):
Manager Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Title
ci-upstream-net-kasan-gce 2021/10/21 12:56 net-next dfcb63ce1de6 f111d03b .config log report info KASAN: use-after-free Read in __napi_schedule
* Struck through repros no longer work on HEAD.