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: 146d, last: 97d
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 1035d 1046d 1/1 fixed on 2020/01/03 09:37
upstream KASAN: use-after-free Read in slip_open C done 3 1044d 1045d 16/24 fixed on 2019/12/13 00:31
linux-4.14 KASAN: use-after-free Read in slip_open C done done 2 1042d 1042d 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:732 [inline]
BUG: KASAN: use-after-free in slip_open+0x215/0xe70 drivers/net/slip/slip.c:806
Read of size 4 at addr ffff888082da20c0 by task syz-executor.0/10352

CPU: 1 PID: 10352 Comm: syz-executor.0 Not tainted 5.19.0-rc4-syzkaller-00014-g941e3e791269 #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+0x1e3/0x2cb lib/dump_stack.c:106
 print_address_description+0x65/0x4b0 mm/kasan/report.c:313
 print_report+0xf4/0x210 mm/kasan/report.c:429
 kasan_report+0xfb/0x130 mm/kasan/report.c:491
 sl_sync drivers/net/slip/slip.c:732 [inline]
 slip_open+0x215/0xe70 drivers/net/slip/slip.c:806
 tty_ldisc_open drivers/tty/tty_ldisc.c:433 [inline]
 tty_set_ldisc+0x369/0x670 drivers/tty/tty_ldisc.c:558
 tty_ioctl+0xada/0xc60 drivers/tty/tty_io.c:2714
 vfs_ioctl fs/ioctl.c:51 [inline]
 __do_sys_ioctl fs/ioctl.c:870 [inline]
 __se_sys_ioctl+0xfb/0x170 fs/ioctl.c:856
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x2b/0x70 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x46/0xb0
RIP: 0033:0x7f7f83889109
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:00007f7f849d9168 EFLAGS: 00000246 ORIG_RAX: 0000000000000010
RAX: ffffffffffffffda RBX: 00007f7f8399bf60 RCX: 00007f7f83889109
RDX: 0000000020000100 RSI: 0000000000005423 RDI: 0000000000000003
RBP: 00007f7f838e305d R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 00007ffcb785781f R14: 00007f7f849d9300 R15: 0000000000022000
 </TASK>

Allocated by task 10336:
 kasan_save_stack mm/kasan/common.c:38 [inline]
 kasan_set_track mm/kasan/common.c:45 [inline]
 set_alloc_info mm/kasan/common.c:436 [inline]
 ____kasan_kmalloc+0xdc/0x110 mm/kasan/common.c:515
 kasan_kmalloc include/linux/kasan.h:234 [inline]
 __kmalloc_node+0x262/0x400 mm/slub.c:4494
 kmalloc_node include/linux/slab.h:623 [inline]
 kvmalloc_node+0x6e/0x160 mm/util.c:613
 kvmalloc include/linux/slab.h:750 [inline]
 kvzalloc include/linux/slab.h:758 [inline]
 alloc_netdev_mqs+0x85/0xea0 net/core/dev.c:10580
 sl_alloc drivers/net/slip/slip.c:756 [inline]
 slip_open+0x390/0xe70 drivers/net/slip/slip.c:817
 tty_ldisc_open drivers/tty/tty_ldisc.c:433 [inline]
 tty_set_ldisc+0x369/0x670 drivers/tty/tty_ldisc.c:558
 tty_ioctl+0xada/0xc60 drivers/tty/tty_io.c:2714
 vfs_ioctl fs/ioctl.c:51 [inline]
 __do_sys_ioctl fs/ioctl.c:870 [inline]
 __se_sys_ioctl+0xfb/0x170 fs/ioctl.c:856
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x2b/0x70 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x46/0xb0

Freed by task 10335:
 kasan_save_stack mm/kasan/common.c:38 [inline]
 kasan_set_track+0x4c/0x70 mm/kasan/common.c:45
 kasan_set_free_info+0x1f/0x40 mm/kasan/generic.c:370
 ____kasan_slab_free+0xd8/0x110 mm/kasan/common.c:366
 kasan_slab_free include/linux/kasan.h:200 [inline]
 slab_free_hook mm/slub.c:1754 [inline]
 slab_free_freelist_hook+0x12e/0x1a0 mm/slub.c:1780
 slab_free mm/slub.c:3536 [inline]
 kfree+0xc6/0x210 mm/slub.c:4584
 device_release+0x98/0x1c0
 kobject_cleanup+0x235/0x470 lib/kobject.c:673
 netdev_run_todo+0xf9c/0x1090 net/core/dev.c:10362
 unregister_netdev+0x1a0/0x210 net/core/dev.c:10899
 tty_ldisc_kill drivers/tty/tty_ldisc.c:608 [inline]
 tty_ldisc_release+0x23c/0x510 drivers/tty/tty_ldisc.c:776
 tty_release_struct+0x27/0xd0 drivers/tty/tty_io.c:1694
 tty_release+0xc06/0xe60 drivers/tty/tty_io.c:1865
 __fput+0x3b9/0x820 fs/file_table.c:317
 task_work_run+0x146/0x1c0 kernel/task_work.c:177
 resume_user_mode_work include/linux/resume_user_mode.h:49 [inline]
 exit_to_user_mode_loop+0x134/0x160 kernel/entry/common.c:169
 exit_to_user_mode_prepare+0xad/0x110 kernel/entry/common.c:201
 __syscall_exit_to_user_mode_work kernel/entry/common.c:283 [inline]
 syscall_exit_to_user_mode+0x2e/0x60 kernel/entry/common.c:294
 entry_SYSCALL_64_after_hwframe+0x46/0xb0

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

The buggy address belongs to the physical page:
page:ffffea00020b6800 refcount:1 mapcount:0 mapping:0000000000000000 index:0xffff888082da4000 pfn:0x82da0
head:ffffea00020b6800 order:3 compound_mapcount:0 compound_pincount:0
memcg:ffff88802552c841
flags: 0xfff00000010200(slab|head|node=0|zone=1|lastcpupid=0x7ff)
raw: 00fff00000010200 ffffea0001982a08 ffffea0001f39008 ffff888011c4c280
raw: ffff888082da4000 0000000000040002 00000001ffffffff ffff88802552c841
page dumped because: kasan: bad access detected
page_owner tracks the page as allocated
page last allocated via order 3, migratetype Unmovable, gfp_mask 0x1d20c0(__GFP_IO|__GFP_FS|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP|__GFP_NOMEMALLOC|__GFP_HARDWALL), pid 2976, tgid 2976 (udevd), ts 282825724393, free_ts 282715351382
 prep_new_page mm/page_alloc.c:2456 [inline]
 get_page_from_freelist+0x72b/0x7a0 mm/page_alloc.c:4198
 __alloc_pages+0x259/0x560 mm/page_alloc.c:5426
 alloc_slab_page+0x70/0xf0 mm/slub.c:1824
 allocate_slab+0x5e/0x520 mm/slub.c:1969
 new_slab mm/slub.c:2029 [inline]
 ___slab_alloc+0x42e/0xce0 mm/slub.c:3031
 __slab_alloc mm/slub.c:3118 [inline]
 slab_alloc_node mm/slub.c:3209 [inline]
 __kmalloc_node+0x2c0/0x400 mm/slub.c:4490
 kmalloc_node include/linux/slab.h:623 [inline]
 kvmalloc_node+0x6e/0x160 mm/util.c:613
 kvmalloc include/linux/slab.h:750 [inline]
 seq_buf_alloc fs/seq_file.c:38 [inline]
 seq_read_iter+0x1f6/0xd30 fs/seq_file.c:210
 call_read_iter include/linux/fs.h:2052 [inline]
 new_sync_read fs/read_write.c:401 [inline]
 vfs_read+0xa01/0xd10 fs/read_write.c:482
 ksys_read+0x19b/0x2c0 fs/read_write.c:620
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x2b/0x70 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x46/0xb0
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+0x812/0x900 mm/page_alloc.c:1421
 free_unref_page_prepare mm/page_alloc.c:3343 [inline]
 free_unref_page+0x7d/0x390 mm/page_alloc.c:3438
 free_slab mm/slub.c:2068 [inline]
 discard_slab mm/slub.c:2074 [inline]
 __unfreeze_partials+0x1ab/0x200 mm/slub.c:2548
 put_cpu_partial+0x116/0x180 mm/slub.c:2624
 do_slab_free mm/slub.c:3524 [inline]
 ___cache_free+0x118/0x1a0 mm/slub.c:3543
 qlist_free_all+0x2b/0x70 mm/kasan/quarantine.c:187
 kasan_quarantine_reduce+0x169/0x180 mm/kasan/quarantine.c:294
 __kasan_slab_alloc+0x2f/0xe0 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:3243 [inline]
 slab_alloc mm/slub.c:3251 [inline]
 __kmalloc+0x1bd/0x370 mm/slub.c:4442
 kmalloc include/linux/slab.h:605 [inline]
 tomoyo_realpath_from_path+0xd8/0x5f0 security/tomoyo/realpath.c:254
 tomoyo_get_realpath security/tomoyo/file.c:151 [inline]
 tomoyo_path_perm+0x270/0x6b0 security/tomoyo/file.c:822
 security_inode_getattr+0xc0/0x140 security/security.c:1344
 vfs_getattr+0x26/0x360 fs/stat.c:157
 vfs_statx+0x183/0x3f0 fs/stat.c:232
 vfs_fstatat fs/stat.c:255 [inline]
 __do_sys_newfstatat fs/stat.c:425 [inline]
 __se_sys_newfstatat+0xf6/0x790 fs/stat.c:419
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x2b/0x70 arch/x86/entry/common.c:80

Memory state around the buggy address:
 ffff888082da1f80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
 ffff888082da2000: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff888082da2080: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                                           ^
 ffff888082da2100: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff888082da2180: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================

Crashes (2):
Manager Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Title
ci-upstream-kasan-gce-smack-root 2022/06/28 07:03 upstream 941e3e791269 ef82eb2c .config 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 log report info KASAN: use-after-free Read in slip_open
* Struck through repros no longer work on HEAD.