syzbot


KASAN: use-after-free Read in vcs_write

Status: auto-closed as invalid on 2022/07/20 19:30
Reported-by: syzbot+ed170c3a178b7ac59a03@syzkaller.appspotmail.com
First crash: 729d, last: 729d

Sample crash report:
==================================================================
BUG: KASAN: use-after-free in vcs_size drivers/tty/vt/vc_screen.c:215 [inline]
BUG: KASAN: use-after-free in vcs_write+0xed7/0x12e0 drivers/tty/vt/vc_screen.c:663
Read of size 4 at addr ffff88812a2e99d8 by task syz-executor.1/27894

CPU: 0 PID: 27894 Comm: syz-executor.1 Not tainted 5.10.110-syzkaller-01300-ge08dd85cc95e #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
Call Trace:
 __dump_stack lib/dump_stack.c:77 [inline]
 dump_stack_lvl+0x1e2/0x24b lib/dump_stack.c:118
 print_address_description+0x81/0x3c0 mm/kasan/report.c:233
 __kasan_report mm/kasan/report.c:419 [inline]
 kasan_report+0x1a4/0x1f0 mm/kasan/report.c:436
 __asan_report_load4_noabort+0x14/0x20 mm/kasan/report_generic.c:308
 vcs_size drivers/tty/vt/vc_screen.c:215 [inline]
 vcs_write+0xed7/0x12e0 drivers/tty/vt/vc_screen.c:663
 vfs_write+0x369/0xf40 fs/read_write.c:603
 ksys_write+0x198/0x2c0 fs/read_write.c:658
 __do_sys_write fs/read_write.c:670 [inline]
 __se_sys_write fs/read_write.c:667 [inline]
 __x64_sys_write+0x7b/0x90 fs/read_write.c:667
 do_syscall_64+0x34/0x70 arch/x86/entry/common.c:46
 entry_SYSCALL_64_after_hwframe+0x44/0xa9
RIP: 0033:0x7f9237a8c0e9
Code: ff ff c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 40 00 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:00007f9236c02168 EFLAGS: 00000246 ORIG_RAX: 0000000000000001
RAX: ffffffffffffffda RBX: 00007f9237b9ef60 RCX: 00007f9237a8c0e9
RDX: 0000000000000052 RSI: 0000000020000040 RDI: 0000000000000003
RBP: 00007f9237ae608d R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 00007ffec7cf3c8f R14: 00007f9236c02300 R15: 0000000000022000

Allocated by task 3843:
 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:428 [inline]
 ____kasan_kmalloc+0xdc/0x110 mm/kasan/common.c:507
 __kasan_kmalloc+0x9/0x10 mm/kasan/common.c:516
 kasan_kmalloc include/linux/kasan.h:269 [inline]
 kmem_cache_alloc_trace+0x1dd/0x330 mm/slub.c:2983
 kmalloc include/linux/slab.h:552 [inline]
 kzalloc include/linux/slab.h:664 [inline]
 vc_allocate+0x1a9/0x6f0 drivers/tty/vt/vt.c:1129
 con_install+0x9b/0x800 drivers/tty/vt/vt.c:3390
 tty_driver_install_tty drivers/tty/tty_io.c:1308 [inline]
 tty_init_dev+0xcd/0x4f0 drivers/tty/tty_io.c:1422
 tty_open_by_driver drivers/tty/tty_io.c:2065 [inline]
 tty_open+0xbea/0x1200 drivers/tty/tty_io.c:2113
 chrdev_open+0x5fb/0x680 fs/char_dev.c:414
 do_dentry_open+0x7a2/0x1090 fs/open.c:819
 vfs_open+0x73/0x80 fs/open.c:942
 do_open fs/namei.c:3327 [inline]
 path_openat+0x2638/0x2fd0 fs/namei.c:3444
 do_filp_open+0x200/0x440 fs/namei.c:3471
 do_sys_openat2+0x13b/0x470 fs/open.c:1211
 do_sys_open fs/open.c:1227 [inline]
 __do_sys_openat fs/open.c:1243 [inline]
 __se_sys_openat fs/open.c:1238 [inline]
 __x64_sys_openat+0x243/0x290 fs/open.c:1238
 do_syscall_64+0x34/0x70 arch/x86/entry/common.c:46
 entry_SYSCALL_64_after_hwframe+0x44/0xa9

Last potentially related work creation:
 kasan_save_stack+0x36/0x60 mm/kasan/common.c:38
 kasan_record_aux_stack+0xca/0xf0 mm/kasan/generic.c:345
 insert_work+0x56/0x330 kernel/workqueue.c:1348
 __queue_work+0x971/0xd30 kernel/workqueue.c:1514
 queue_work_on+0xf2/0x150 kernel/workqueue.c:1541
 queue_work include/linux/workqueue.h:513 [inline]
 schedule_work include/linux/workqueue.h:574 [inline]
 queue_release_one_tty drivers/tty/tty_io.c:1559 [inline]
 kref_put include/linux/kref.h:65 [inline]
 tty_kref_put drivers/tty/tty_io.c:1573 [inline]
 release_tty+0x710/0x830 drivers/tty/tty_io.c:1608
 tty_release_struct+0xc1/0xe0 drivers/tty/tty_io.c:1707
 tty_release+0xdf8/0x1070 drivers/tty/tty_io.c:1867
 __fput+0x348/0x7c0 fs/file_table.c:281
 ____fput+0x15/0x20 fs/file_table.c:314
 task_work_run+0x147/0x1b0 kernel/task_work.c:154
 tracehook_notify_resume include/linux/tracehook.h:188 [inline]
 exit_to_user_mode_loop+0xc8/0xe0 kernel/entry/common.c:164
 exit_to_user_mode_prepare kernel/entry/common.c:191 [inline]
 syscall_exit_to_user_mode+0x77/0xa0 kernel/entry/common.c:266
 do_syscall_64+0x40/0x70 arch/x86/entry/common.c:56
 entry_SYSCALL_64_after_hwframe+0x44/0xa9

Second to last potentially related work creation:
 kasan_save_stack+0x36/0x60 mm/kasan/common.c:38
 kasan_record_aux_stack+0xca/0xf0 mm/kasan/generic.c:345
 insert_work+0x56/0x330 kernel/workqueue.c:1348
 __queue_work+0x971/0xd30 kernel/workqueue.c:1514
 queue_work_on+0xf2/0x150 kernel/workqueue.c:1541
 queue_work include/linux/workqueue.h:513 [inline]
 schedule_work include/linux/workqueue.h:574 [inline]
 queue_release_one_tty drivers/tty/tty_io.c:1559 [inline]
 kref_put include/linux/kref.h:65 [inline]
 tty_kref_put drivers/tty/tty_io.c:1573 [inline]
 release_tty+0x710/0x830 drivers/tty/tty_io.c:1608
 tty_release_struct+0xc1/0xe0 drivers/tty/tty_io.c:1707
 tty_release+0xdf8/0x1070 drivers/tty/tty_io.c:1867
 __fput+0x348/0x7c0 fs/file_table.c:281
 ____fput+0x15/0x20 fs/file_table.c:314
 task_work_run+0x147/0x1b0 kernel/task_work.c:154
 exit_task_work include/linux/task_work.h:30 [inline]
 do_exit+0x65e/0x2360 kernel/exit.c:813
 do_group_exit+0x13a/0x300 kernel/exit.c:910
 get_signal+0xe17/0x1440 kernel/signal.c:2780
 arch_do_signal+0x8e/0x650 arch/x86/kernel/signal.c:805
 exit_to_user_mode_loop+0xa3/0xe0 kernel/entry/common.c:161
 exit_to_user_mode_prepare kernel/entry/common.c:191 [inline]
 syscall_exit_to_user_mode+0x77/0xa0 kernel/entry/common.c:266
 do_syscall_64+0x40/0x70 arch/x86/entry/common.c:56
 entry_SYSCALL_64_after_hwframe+0x44/0xa9

The buggy address belongs to the object at ffff88812a2e9800
 which belongs to the cache kmalloc-1k of size 1024
The buggy address is located 472 bytes inside of
 1024-byte region [ffff88812a2e9800, ffff88812a2e9c00)
The buggy address belongs to the page:
page:ffffea0004a8ba00 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x12a2e8
head:ffffea0004a8ba00 order:3 compound_mapcount:0 compound_pincount:0
flags: 0x8000000000010200(slab|head)
raw: 8000000000010200 ffffea0004ad0e00 0000000300000003 ffff888100042f00
raw: 0000000000000000 0000000000100010 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 378, ts 21655795417, free_ts 0
 set_page_owner include/linux/page_owner.h:35 [inline]
 post_alloc_hook mm/page_alloc.c:2385 [inline]
 prep_new_page mm/page_alloc.c:2391 [inline]
 get_page_from_freelist+0x745/0x760 mm/page_alloc.c:4063
 __alloc_pages_nodemask+0x3b6/0x890 mm/page_alloc.c:5113
 alloc_slab_page mm/slub.c:1815 [inline]
 allocate_slab+0x78/0x540 mm/slub.c:1817
 new_slab mm/slub.c:1878 [inline]
 new_slab_objects mm/slub.c:2637 [inline]
 ___slab_alloc+0x131/0x2e0 mm/slub.c:2800
 __slab_alloc+0x63/0xa0 mm/slub.c:2840
 slab_alloc_node mm/slub.c:2922 [inline]
 slab_alloc mm/slub.c:2964 [inline]
 __kmalloc_track_caller+0x23e/0x350 mm/slub.c:4545
 __kmalloc_reserve net/core/skbuff.c:143 [inline]
 __alloc_skb+0xbe/0x580 net/core/skbuff.c:211
 alloc_skb include/linux/skbuff.h:1101 [inline]
 nlmsg_new include/net/netlink.h:953 [inline]
 genlmsg_new include/net/genetlink.h:413 [inline]
 ethnl_default_notify+0x215/0x600 net/ethtool/netlink.c:595
 ethtool_notify+0xbc/0x1a0 net/ethtool/netlink.c:657
 ethnl_notify_features net/ethtool/netlink.c:668 [inline]
 ethnl_netdev_event+0x58/0x70 net/ethtool/netlink.c:676
 notifier_call_chain kernel/notifier.c:83 [inline]
 raw_notifier_call_chain+0x9e/0x110 kernel/notifier.c:410
 call_netdevice_notifiers_info net/core/dev.c:2054 [inline]
 call_netdevice_notifiers_extack net/core/dev.c:2066 [inline]
 call_netdevice_notifiers net/core/dev.c:2080 [inline]
 netdev_features_change net/core/dev.c:1465 [inline]
 netdev_update_features+0x150/0x1c0 net/core/dev.c:9843
 br_add_if+0x73a/0xf00 net/bridge/br_if.c:669
 br_add_slave+0x2c/0x40 net/bridge/br_device.c:391
 do_set_master net/core/rtnetlink.c:2519 [inline]
 do_setlink+0xdcb/0x3b50 net/core/rtnetlink.c:2716
 __rtnl_newlink net/core/rtnetlink.c:3379 [inline]
 rtnl_newlink+0x16fc/0x2090 net/core/rtnetlink.c:3505
page_owner free stack trace missing

Memory state around the buggy address:
 ffff88812a2e9880: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff88812a2e9900: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff88812a2e9980: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                                                    ^
 ffff88812a2e9a00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff88812a2e9a80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================

Crashes (1):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2022/04/21 19:20 android12-5.10-lts e08dd85cc95e 2738b391 .config console log report info ci2-android-5-10 KASAN: use-after-free Read in vcs_write
* Struck through repros no longer work on HEAD.