syzbot


KASAN: use-after-free Read in free_netdev (3)

Status: upstream: reported C repro on 2022/06/22 01:01
Reported-by: syzbot+b75c138e9286ac742647@syzkaller.appspotmail.com
First crash: 7d09h, last: 8h44m

Cause bisection: the issue happens on the oldest tested release (bisect log)
Crash: KASAN: use-after-free Read in free_netdev (log)
Repro: C syz .config
similar bugs (6):
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
android-5-10 KASAN: use-after-free Read in free_netdev C error 1 7d10h 7d10h 0/3 upstream: reported C repro on 2022/06/18 00:20
linux-4.19 KASAN: use-after-free Read in free_netdev C error 135 5d18h 840d 0/1 upstream: reported C repro on 2020/03/07 10:14
upstream KASAN: use-after-free Read in free_netdev (2) C done done 1715 206d 840d 22/22 fixed on 2022/03/08 16:11
android-54 KASAN: use-after-free Read in free_netdev C 420 2d18h 840d 0/2 upstream: reported C repro on 2020/03/06 20:14
upstream KASAN: use-after-free Read in free_netdev C 42 1687d 1711d 3/22 fixed on 2017/11/28 03:36
upstream general protection fault in free_netdev (2) 1 367d 367d 0/22 auto-closed as invalid on 2021/09/20 23:14
Patch testing requests:
Created Duration User Patch Repo Result
2022/06/24 23:08 15m hdanton@sina.com patch https://git.kernel.org/pub/scm/linux/kernel/git/netdev/net.git b4a028c4d031 OK log
2022/06/24 12:44 9m hdanton@sina.com patch https://git.kernel.org/pub/scm/linux/kernel/git/netdev/net.git b4a028c4d031 report log
2022/06/23 12:21 9m hdanton@sina.com patch https://git.kernel.org/pub/scm/linux/kernel/git/netdev/net.git b4a028c4d031 report log

Sample crash report:
netlink: 20 bytes leftover after parsing attributes in process `syz-executor649'.
==================================================================
BUG: KASAN: use-after-free in free_netdev+0x58c/0x620 net/core/dev.c:10700
Read of size 8 at addr ffff888021c8e738 by task syz-executor649/3616

CPU: 1 PID: 3616 Comm: syz-executor649 Not tainted 5.19.0-rc3-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+0xcd/0x134 lib/dump_stack.c:106
 print_address_description.constprop.0.cold+0xeb/0x495 mm/kasan/report.c:313
 print_report mm/kasan/report.c:429 [inline]
 kasan_report.cold+0xf4/0x1c6 mm/kasan/report.c:491
 free_netdev+0x58c/0x620 net/core/dev.c:10700
 netdev_run_todo+0xb18/0x10b0 net/core/dev.c:10352
 rtnl_unlock net/core/rtnetlink.c:147 [inline]
 rtnetlink_rcv_msg+0x447/0xc90 net/core/rtnetlink.c:6090
 netlink_rcv_skb+0x153/0x420 net/netlink/af_netlink.c:2501
 netlink_unicast_kernel net/netlink/af_netlink.c:1319 [inline]
 netlink_unicast+0x543/0x7f0 net/netlink/af_netlink.c:1345
 netlink_sendmsg+0x917/0xe10 net/netlink/af_netlink.c:1921
 sock_sendmsg_nosec net/socket.c:714 [inline]
 sock_sendmsg+0xcf/0x120 net/socket.c:734
 ____sys_sendmsg+0x6eb/0x810 net/socket.c:2492
 ___sys_sendmsg+0xf3/0x170 net/socket.c:2546
 __sys_sendmsg net/socket.c:2575 [inline]
 __do_sys_sendmsg net/socket.c:2584 [inline]
 __se_sys_sendmsg net/socket.c:2582 [inline]
 __x64_sys_sendmsg+0x132/0x220 net/socket.c:2582
 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+0x46/0xb0
RIP: 0033:0x7f312a93ceb9
Code: 28 00 00 00 75 05 48 83 c4 28 c3 e8 91 18 00 00 90 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 b8 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007f312a8e6208 EFLAGS: 00000246 ORIG_RAX: 000000000000002e
RAX: ffffffffffffffda RBX: 00007f312a9be408 RCX: 00007f312a93ceb9
RDX: 0000000000000000 RSI: 0000000020000180 RDI: 0000000000000004
RBP: 00007f312a9be400 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 00007f312a9be40c
R13: 00007ffe8081178f R14: 00007f312a8e6300 R15: 0000000000022000
 </TASK>

Allocated by task 3616:
 kasan_save_stack+0x1e/0x40 mm/kasan/common.c:38
 kasan_set_track mm/kasan/common.c:45 [inline]
 set_alloc_info mm/kasan/common.c:436 [inline]
 ____kasan_kmalloc mm/kasan/common.c:515 [inline]
 ____kasan_kmalloc mm/kasan/common.c:474 [inline]
 __kasan_kmalloc+0xa9/0xd0 mm/kasan/common.c:524
 kmalloc include/linux/slab.h:605 [inline]
 sk_prot_alloc+0x110/0x290 net/core/sock.c:1975
 sk_alloc+0x36/0x770 net/core/sock.c:2028
 tun_chr_open+0x7b/0x540 drivers/net/tun.c:3408
 misc_open+0x376/0x4a0 drivers/char/misc.c:143
 chrdev_open+0x266/0x770 fs/char_dev.c:414
 do_dentry_open+0x4a1/0x11f0 fs/open.c:848
 do_open fs/namei.c:3520 [inline]
 path_openat+0x1c71/0x2910 fs/namei.c:3653
 do_filp_open+0x1aa/0x400 fs/namei.c:3680
 do_sys_openat2+0x16d/0x4c0 fs/open.c:1278
 do_sys_open fs/open.c:1294 [inline]
 __do_sys_openat fs/open.c:1310 [inline]
 __se_sys_openat fs/open.c:1305 [inline]
 __x64_sys_openat+0x13f/0x1f0 fs/open.c:1305
 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+0x46/0xb0

Freed by task 3617:
 kasan_save_stack+0x1e/0x40 mm/kasan/common.c:38
 kasan_set_track+0x21/0x30 mm/kasan/common.c:45
 kasan_set_free_info+0x20/0x30 mm/kasan/generic.c:370
 ____kasan_slab_free mm/kasan/common.c:366 [inline]
 ____kasan_slab_free+0x166/0x1a0 mm/kasan/common.c:328
 kasan_slab_free include/linux/kasan.h:200 [inline]
 slab_free_hook mm/slub.c:1727 [inline]
 slab_free_freelist_hook+0x8b/0x1c0 mm/slub.c:1753
 slab_free mm/slub.c:3507 [inline]
 kfree+0xd6/0x4d0 mm/slub.c:4555
 sk_prot_free net/core/sock.c:2011 [inline]
 __sk_destruct+0x5e5/0x710 net/core/sock.c:2097
 sk_destruct net/core/sock.c:2112 [inline]
 __sk_free+0x1a4/0x4a0 net/core/sock.c:2123
 sk_free+0x78/0xa0 net/core/sock.c:2134
 sock_put include/net/sock.h:1927 [inline]
 __tun_detach+0xdb7/0x13e0 drivers/net/tun.c:680
 tun_detach drivers/net/tun.c:692 [inline]
 tun_chr_close+0x15c/0x180 drivers/net/tun.c:3444
 __fput+0x277/0x9d0 fs/file_table.c:317
 task_work_run+0xdd/0x1a0 kernel/task_work.c:177
 ptrace_notify+0x114/0x140 kernel/signal.c:2353
 ptrace_report_syscall include/linux/ptrace.h:420 [inline]
 ptrace_report_syscall_exit include/linux/ptrace.h:482 [inline]
 syscall_exit_work kernel/entry/common.c:249 [inline]
 syscall_exit_to_user_mode_prepare+0xdb/0x230 kernel/entry/common.c:276
 __syscall_exit_to_user_mode_work kernel/entry/common.c:281 [inline]
 syscall_exit_to_user_mode+0x9/0x50 kernel/entry/common.c:294
 do_syscall_64+0x42/0xb0 arch/x86/entry/common.c:86
 entry_SYSCALL_64_after_hwframe+0x46/0xb0

The buggy address belongs to the object at ffff888021c8e000
 which belongs to the cache kmalloc-4k of size 4096
The buggy address is located 1848 bytes inside of
 4096-byte region [ffff888021c8e000, ffff888021c8f000)

The buggy address belongs to the physical page:
page:ffffea0000872200 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x21c88
head:ffffea0000872200 order:3 compound_mapcount:0 compound_pincount:0
flags: 0xfff00000010200(slab|head|node=0|zone=1|lastcpupid=0x7ff)
raw: 00fff00000010200 0000000000000000 dead000000000122 ffff888011842140
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 3615, tgid 3615 (syz-executor649), ts 49399578044, free_ts 43764171577
 prep_new_page mm/page_alloc.c:2456 [inline]
 get_page_from_freelist+0x1290/0x3b70 mm/page_alloc.c:4198
 __alloc_pages+0x1c7/0x510 mm/page_alloc.c:5426
 alloc_pages+0x1aa/0x310 mm/mempolicy.c:2272
 alloc_slab_page mm/slub.c:1797 [inline]
 allocate_slab+0x26c/0x3c0 mm/slub.c:1942
 new_slab mm/slub.c:2002 [inline]
 ___slab_alloc+0x985/0xd90 mm/slub.c:3002
 __slab_alloc.constprop.0+0x4d/0xa0 mm/slub.c:3089
 slab_alloc_node mm/slub.c:3180 [inline]
 slab_alloc mm/slub.c:3222 [inline]
 kmem_cache_alloc_trace+0x310/0x3f0 mm/slub.c:3253
 kmalloc include/linux/slab.h:600 [inline]
 tomoyo_print_header security/tomoyo/audit.c:156 [inline]
 tomoyo_init_log+0x18a/0x1ed0 security/tomoyo/audit.c:255
 tomoyo_supervisor+0x34d/0xf00 security/tomoyo/common.c:2088
 tomoyo_audit_path_log security/tomoyo/file.c:168 [inline]
 tomoyo_path_permission security/tomoyo/file.c:587 [inline]
 tomoyo_path_permission+0x270/0x3a0 security/tomoyo/file.c:573
 tomoyo_path_perm+0x39e/0x400 security/tomoyo/file.c:838
 tomoyo_path_symlink+0x94/0xe0 security/tomoyo/tomoyo.c:199
 security_path_symlink+0xdf/0x150 security/security.c:1182
 do_symlinkat+0x106/0x2e0 fs/namei.c:4365
 __do_sys_symlink fs/namei.c:4392 [inline]
 __se_sys_symlink fs/namei.c:4390 [inline]
 __x64_sys_symlink+0x75/0x90 fs/namei.c:4390
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80
page last free stack trace:
 reset_page_owner include/linux/page_owner.h:24 [inline]
 free_pages_prepare mm/page_alloc.c:1371 [inline]
 free_pcp_prepare+0x549/0xd20 mm/page_alloc.c:1421
 free_unref_page_prepare mm/page_alloc.c:3343 [inline]
 free_unref_page+0x19/0x6a0 mm/page_alloc.c:3438
 __unfreeze_partials+0x17c/0x1a0 mm/slub.c:2521
 qlink_free mm/kasan/quarantine.c:168 [inline]
 qlist_free_all+0x6a/0x170 mm/kasan/quarantine.c:187
 kasan_quarantine_reduce+0x180/0x200 mm/kasan/quarantine.c:294
 __kasan_slab_alloc+0xa2/0xc0 mm/kasan/common.c:446
 kasan_slab_alloc include/linux/kasan.h:224 [inline]
 slab_post_alloc_hook mm/slab.h:750 [inline]
 slab_alloc_node mm/slub.c:3214 [inline]
 kmem_cache_alloc_node+0x255/0x3f0 mm/slub.c:3264
 __alloc_skb+0x215/0x340 net/core/skbuff.c:414
 alloc_skb_fclone include/linux/skbuff.h:1476 [inline]
 tcp_stream_alloc_skb+0x66/0x900 net/ipv4/tcp.c:862
 tcp_sendmsg_locked+0xad1/0x2fc0 net/ipv4/tcp.c:1297
 tcp_sendmsg+0x2b/0x40 net/ipv4/tcp.c:1448
 inet_sendmsg+0x99/0xe0 net/ipv4/af_inet.c:819
 sock_sendmsg_nosec net/socket.c:714 [inline]
 sock_sendmsg+0xcf/0x120 net/socket.c:734
 sock_write_iter+0x284/0x3c0 net/socket.c:1108
 call_write_iter include/linux/fs.h:2058 [inline]
 new_sync_write+0x38a/0x560 fs/read_write.c:504
 vfs_write+0x7c0/0xac0 fs/read_write.c:591

Memory state around the buggy address:
 ffff888021c8e600: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff888021c8e680: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff888021c8e700: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                                        ^
 ffff888021c8e780: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff888021c8e800: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================

Crashes (7):
Manager Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Title
ci-upstream-kasan-gce 2022/06/20 10:10 upstream a111daf0c53a 8f633d84 .config log report syz C KASAN: use-after-free Read in free_netdev
ci-upstream-net-this-kasan-gce 2022/06/18 01:30 net b4a028c4d031 cb58b3b2 .config log report syz C KASAN: use-after-free Read in free_netdev
ci-upstream-net-kasan-gce 2022/06/18 00:50 net-next 4875d94c69d5 cb58b3b2 .config log report syz C KASAN: use-after-free Read in free_netdev
ci-upstream-kasan-gce-selinux-root 2022/06/20 15:04 upstream a111daf0c53a 8d15e28d .config log report info KASAN: use-after-free Read in free_netdev
ci-upstream-net-kasan-gce 2022/06/25 01:55 net-next 5d04b0b634bb a371c43c .config log report info KASAN: use-after-free Read in free_netdev
ci-upstream-net-kasan-gce 2022/06/24 15:37 net-next 93817be8b62c a5dbd430 .config log report info KASAN: use-after-free Read in free_netdev
ci-upstream-net-kasan-gce 2022/06/19 16:03 net-next 9776fe0f424b 8f633d84 .config log report info KASAN: use-after-free Read in free_netdev