syzbot


KASAN: use-after-free Read in slip_open (2)

Status: upstream: reported on 2022/05/14 07:35
Reported-by: syzbot+9d130534f0d300732a3a@syzkaller.appspotmail.com
First crash: 267d, last: 109d
similar bugs (3):
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
linux-4.19 KASAN: use-after-free Read in slip_open C done done 7 1156d 1167d 1/1 fixed on 2020/01/03 09:37
upstream KASAN: use-after-free Read in slip_open C done 3 1164d 1166d 16/24 fixed on 2019/12/13 00:31
linux-4.14 KASAN: use-after-free Read in slip_open C done done 2 1163d 1163d 1/1 fixed on 2019/12/28 10:32

Sample crash report:
==================================================================
BUG: KASAN: use-after-free in sl_sync drivers/net/slip/slip.c:730 [inline]
BUG: KASAN: use-after-free in slip_open+0xed2/0x1210 drivers/net/slip/slip.c:806
Read of size 8 at addr ffff888074dcec88 by task syz-executor.0/25364

CPU: 0 PID: 25364 Comm: syz-executor.0 Not tainted 6.0.0-syzkaller-06205-gffb39098bf87 #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 09/22/2022
Call Trace:
 <TASK>
 __dump_stack lib/dump_stack.c:88 [inline]
 dump_stack_lvl+0xcd/0x134 lib/dump_stack.c:106
 print_address_description mm/kasan/report.c:317 [inline]
 print_report.cold+0x2ba/0x6e9 mm/kasan/report.c:433
 kasan_report+0xb1/0x1e0 mm/kasan/report.c:495
 sl_sync drivers/net/slip/slip.c:730 [inline]
 slip_open+0xed2/0x1210 drivers/net/slip/slip.c:806
 tty_ldisc_open+0x9b/0x110 drivers/tty/tty_ldisc.c:433
 tty_set_ldisc+0x2f1/0x680 drivers/tty/tty_ldisc.c:558
 tiocsetd drivers/tty/tty_io.c:2433 [inline]
 tty_ioctl+0xe20/0x15d0 drivers/tty/tty_io.c:2714
 vfs_ioctl fs/ioctl.c:51 [inline]
 __do_sys_ioctl fs/ioctl.c:870 [inline]
 __se_sys_ioctl fs/ioctl.c:856 [inline]
 __x64_sys_ioctl+0x193/0x200 fs/ioctl.c:856
 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+0x63/0xcd
RIP: 0033:0x7fc3f088a5a9
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:00007fc3f1aa1168 EFLAGS: 00000246 ORIG_RAX: 0000000000000010
RAX: ffffffffffffffda RBX: 00007fc3f09abf80 RCX: 00007fc3f088a5a9
RDX: 0000000020000080 RSI: 0000000000005423 RDI: 0000000000000003
RBP: 00007fc3f08e5580 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 00007ffe7e67a87f R14: 00007fc3f1aa1300 R15: 0000000000022000
 </TASK>

Allocated by task 25344:
 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:437 [inline]
 ____kasan_kmalloc mm/kasan/common.c:516 [inline]
 ____kasan_kmalloc mm/kasan/common.c:475 [inline]
 __kasan_kmalloc+0xa6/0xd0 mm/kasan/common.c:525
 kmalloc_node include/linux/slab.h:623 [inline]
 kvmalloc_node+0x3f/0x1b0 mm/util.c:613
 kvmalloc include/linux/slab.h:750 [inline]
 kvzalloc include/linux/slab.h:758 [inline]
 alloc_netdev_mqs+0x98/0x1180 net/core/dev.c:10584
 sl_alloc drivers/net/slip/slip.c:756 [inline]
 slip_open+0x36d/0x1210 drivers/net/slip/slip.c:817
 tty_ldisc_open+0x9b/0x110 drivers/tty/tty_ldisc.c:433
 tty_set_ldisc+0x2f1/0x680 drivers/tty/tty_ldisc.c:558
 tiocsetd drivers/tty/tty_io.c:2433 [inline]
 tty_ioctl+0xe20/0x15d0 drivers/tty/tty_io.c:2714
 vfs_ioctl fs/ioctl.c:51 [inline]
 __do_sys_ioctl fs/ioctl.c:870 [inline]
 __se_sys_ioctl fs/ioctl.c:856 [inline]
 __x64_sys_ioctl+0x193/0x200 fs/ioctl.c:856
 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+0x63/0xcd

Freed by task 25338:
 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:367 [inline]
 ____kasan_slab_free+0x13d/0x1a0 mm/kasan/common.c:329
 kasan_slab_free include/linux/kasan.h:200 [inline]
 __cache_free mm/slab.c:3418 [inline]
 kfree+0x173/0x390 mm/slab.c:3786
 kvfree+0x42/0x50 mm/util.c:659
 device_release+0x9f/0x240 drivers/base/core.c:2330
 kobject_cleanup lib/kobject.c:673 [inline]
 kobject_release lib/kobject.c:704 [inline]
 kref_put include/linux/kref.h:65 [inline]
 kobject_put+0x1be/0x4c0 lib/kobject.c:721
 netdev_run_todo+0x75e/0x1100 net/core/dev.c:10366
 slip_close+0x161/0x1c0 drivers/net/slip/slip.c:906
 tty_ldisc_close+0x110/0x190 drivers/tty/tty_ldisc.c:456
 tty_ldisc_kill+0x94/0x150 drivers/tty/tty_ldisc.c:608
 tty_ldisc_release+0x1ef/0x2a0 drivers/tty/tty_ldisc.c:776
 tty_release_struct+0x20/0xe0 drivers/tty/tty_io.c:1694
 tty_release+0xc70/0x1200 drivers/tty/tty_io.c:1865
 __fput+0x277/0x9d0 fs/file_table.c:320
 task_work_run+0xdd/0x1a0 kernel/task_work.c:177
 resume_user_mode_work include/linux/resume_user_mode.h:49 [inline]
 exit_to_user_mode_loop kernel/entry/common.c:169 [inline]
 exit_to_user_mode_prepare+0x23c/0x250 kernel/entry/common.c:201
 __syscall_exit_to_user_mode_work kernel/entry/common.c:283 [inline]
 syscall_exit_to_user_mode+0x19/0x50 kernel/entry/common.c:294
 do_syscall_64+0x42/0xb0 arch/x86/entry/common.c:86
 entry_SYSCALL_64_after_hwframe+0x63/0xcd

The buggy address belongs to the object at ffff888074dce000
 which belongs to the cache kmalloc-cg-4k of size 4096
The buggy address is located 3208 bytes inside of
 4096-byte region [ffff888074dce000, ffff888074dcf000)

The buggy address belongs to the physical page:
page:ffffea0001d37380 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x74dce
head:ffffea0001d37380 order:1 compound_mapcount:0 compound_pincount:0
memcg:ffff88801f8ec781
flags: 0xfff00000010200(slab|head|node=0|zone=1|lastcpupid=0x7ff)
raw: 00fff00000010200 ffffea0002099888 ffffea0000e53e08 ffff888011843d00
raw: 0000000000000000 ffff888074dce000 0000000100000001 ffff88801f8ec781
page dumped because: kasan: bad access detected
page_owner tracks the page as allocated
page last allocated via order 1, migratetype Unmovable, gfp_mask 0x3420c0(__GFP_IO|__GFP_FS|__GFP_NOWARN|__GFP_COMP|__GFP_HARDWALL|__GFP_THISNODE), pid 9054, tgid 9054 (udevd), ts 720634196190, free_ts 717719667047
 prep_new_page mm/page_alloc.c:2532 [inline]
 get_page_from_freelist+0x109b/0x2ce0 mm/page_alloc.c:4283
 __alloc_pages+0x1c7/0x510 mm/page_alloc.c:5549
 __alloc_pages_node include/linux/gfp.h:243 [inline]
 kmem_getpages mm/slab.c:1363 [inline]
 cache_grow_begin+0x75/0x360 mm/slab.c:2569
 cache_alloc_refill+0x27f/0x380 mm/slab.c:2942
 ____cache_alloc mm/slab.c:3018 [inline]
 ____cache_alloc mm/slab.c:3001 [inline]
 slab_alloc_node mm/slab.c:3220 [inline]
 kmem_cache_alloc_node_trace+0x50a/0x570 mm/slab.c:3601
 __do_kmalloc_node mm/slab.c:3623 [inline]
 __kmalloc_node+0x38/0x60 mm/slab.c:3631
 kmalloc_node include/linux/slab.h:623 [inline]
 kvmalloc_node+0x3f/0x1b0 mm/util.c:613
 kvmalloc include/linux/slab.h:750 [inline]
 seq_buf_alloc fs/seq_file.c:38 [inline]
 seq_read_iter+0x7f7/0x1280 fs/seq_file.c:210
 kernfs_fop_read_iter+0x523/0x710 fs/kernfs/file.c:299
 call_read_iter include/linux/fs.h:2181 [inline]
 new_sync_read fs/read_write.c:389 [inline]
 vfs_read+0x67d/0x930 fs/read_write.c:470
 ksys_read+0x127/0x250 fs/read_write.c:613
 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+0x63/0xcd
page last free stack trace:
 reset_page_owner include/linux/page_owner.h:24 [inline]
 free_pages_prepare mm/page_alloc.c:1449 [inline]
 free_pcp_prepare+0x5e4/0xd20 mm/page_alloc.c:1499
 free_unref_page_prepare mm/page_alloc.c:3380 [inline]
 free_unref_page+0x19/0x4d0 mm/page_alloc.c:3476
 slab_destroy mm/slab.c:1615 [inline]
 slabs_destroy+0x89/0xc0 mm/slab.c:1635
 cache_flusharray mm/slab.c:3389 [inline]
 ___cache_free+0x2a8/0x3d0 mm/slab.c:3452
 qlink_free mm/kasan/quarantine.c:168 [inline]
 qlist_free_all+0x4f/0x1b0 mm/kasan/quarantine.c:187
 kasan_quarantine_reduce+0x180/0x200 mm/kasan/quarantine.c:294
 __kasan_slab_alloc+0x97/0xb0 mm/kasan/common.c:447
 kasan_slab_alloc include/linux/kasan.h:224 [inline]
 slab_post_alloc_hook mm/slab.h:727 [inline]
 slab_alloc mm/slab.c:3294 [inline]
 __kmem_cache_alloc_lru mm/slab.c:3471 [inline]
 kmem_cache_alloc+0x214/0x520 mm/slab.c:3491
 getname_flags.part.0+0x50/0x4f0 fs/namei.c:139
 getname_flags include/linux/audit.h:320 [inline]
 getname+0x8e/0xd0 fs/namei.c:218
 do_sys_openat2+0xf5/0x4c0 fs/open.c:1307
 do_sys_open fs/open.c:1329 [inline]
 __do_sys_openat fs/open.c:1345 [inline]
 __se_sys_openat fs/open.c:1340 [inline]
 __x64_sys_openat+0x13f/0x1f0 fs/open.c:1340
 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+0x63/0xcd

Memory state around the buggy address:
 ffff888074dceb80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff888074dcec00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff888074dcec80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                      ^
 ffff888074dced00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff888074dced80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================

Crashes (4):
Manager Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets Title
ci-upstream-kasan-gce-selinux-root 2022/10/07 15:00 upstream ffb39098bf87 8a212197 .config console log report info [disk image] [vmlinux] KASAN: use-after-free Read in slip_open
ci-upstream-kasan-gce-smack-root 2022/06/28 07:03 upstream 941e3e791269 ef82eb2c .config console log report info KASAN: use-after-free Read in slip_open
ci-upstream-kasan-gce-root 2022/05/10 06:50 upstream 9be9ed2612b5 8b277b8e .config console log report info KASAN: use-after-free Read in slip_open
ci-upstream-linux-next-kasan-gce-root 2022/10/14 15:10 linux-next aaa11ce2ffc8 4954e4b2 .config console log report info [disk image] [vmlinux] KASAN: use-after-free Read in slip_open
* Struck through repros no longer work on HEAD.