syzbot


KASAN: use-after-free Read in unix_dgram_poll

Status: fixed on 2019/03/28 12:00
Reported-by: syzbot+503d4cc169fcec1cb18c@syzkaller.appspotmail.com
Fix commit: 84c4e1f89fef aio: simplify - and fix - fget/fput for io_submit()
First crash: 1220d, last: 1220d

Sample crash report:
IPv6: ADDRCONF(NETDEV_CHANGE): hsr0: link becomes ready
8021q: adding VLAN 0 to HW filter on device batadv0
==================================================================
BUG: KASAN: use-after-free in unix_dgram_poll+0x5e1/0x690 net/unix/af_unix.c:2695
Read of size 4 at addr ffff8880a01afc20 by task syz-executor.5/13126

CPU: 1 PID: 13126 Comm: syz-executor.5 Not tainted 5.0.0-rc8+ #88
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+0x172/0x1f0 lib/dump_stack.c:113
 print_address_description.cold+0x7c/0x20d mm/kasan/report.c:187
 kasan_report.cold+0x1b/0x40 mm/kasan/report.c:317
 __asan_report_load4_noabort+0x14/0x20 mm/kasan/generic_report.c:134
 unix_dgram_poll+0x5e1/0x690 net/unix/af_unix.c:2695
 sock_poll+0x291/0x340 net/socket.c:1127
 vfs_poll include/linux/poll.h:86 [inline]
 aio_poll fs/aio.c:1766 [inline]
 __io_submit_one fs/aio.c:1876 [inline]
 io_submit_one+0xe3e/0x1cf0 fs/aio.c:1909
 __do_sys_io_submit fs/aio.c:1954 [inline]
 __se_sys_io_submit fs/aio.c:1924 [inline]
 __x64_sys_io_submit+0x1bd/0x580 fs/aio.c:1924
 ? 0xffffffff81000000
 do_syscall_64+0x103/0x610 arch/x86/entry/common.c:290
 entry_SYSCALL_64_after_hwframe+0x49/0xbe
RIP: 0033:0x457e29
Code: ad b8 fb ff c3 66 2e 0f 1f 84 00 00 00 00 00 66 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 0f 83 7b b8 fb ff c3 66 2e 0f 1f 84 00 00 00 00
RSP: 002b:00007ff39b9c3c78 EFLAGS: 00000246 ORIG_RAX: 00000000000000d1
RAX: ffffffffffffffda RBX: 0000000000000003 RCX: 0000000000457e29
RDX: 0000000020000600 RSI: 1ffffffffffffd70 RDI: 00007ff39b9a3000
RBP: 000000000073bf00 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 00007ff39b9c46d4
R13: 00000000004bf02f R14: 00000000004d09b0 R15: 00000000ffffffff

Allocated by task 13126:
 save_stack+0x45/0xd0 mm/kasan/common.c:73
 set_track mm/kasan/common.c:85 [inline]
 __kasan_kmalloc mm/kasan/common.c:495 [inline]
 __kasan_kmalloc.constprop.0+0xcf/0xe0 mm/kasan/common.c:468
 kasan_slab_alloc+0xf/0x20 mm/kasan/common.c:503
 slab_post_alloc_hook mm/slab.h:440 [inline]
 slab_alloc mm/slab.c:3388 [inline]
 kmem_cache_alloc+0x11a/0x6f0 mm/slab.c:3548
 sk_prot_alloc+0x67/0x2e0 net/core/sock.c:1471
 sk_alloc+0x39/0xf70 net/core/sock.c:1531
 unix_create1+0xc3/0x530 net/unix/af_unix.c:764
 unix_create+0x103/0x1e0 net/unix/af_unix.c:825
 __sock_create+0x3e6/0x750 net/socket.c:1275
 sock_create net/socket.c:1315 [inline]
 __sys_socketpair+0x272/0x5e0 net/socket.c:1407
 __do_sys_socketpair net/socket.c:1456 [inline]
 __se_sys_socketpair net/socket.c:1453 [inline]
 __x64_sys_socketpair+0x97/0xf0 net/socket.c:1453
 do_syscall_64+0x103/0x610 arch/x86/entry/common.c:290
 entry_SYSCALL_64_after_hwframe+0x49/0xbe

Freed by task 13125:
 save_stack+0x45/0xd0 mm/kasan/common.c:73
 set_track mm/kasan/common.c:85 [inline]
 __kasan_slab_free+0x102/0x150 mm/kasan/common.c:457
 kasan_slab_free+0xe/0x10 mm/kasan/common.c:465
 __cache_free mm/slab.c:3494 [inline]
 kmem_cache_free+0x86/0x260 mm/slab.c:3754
 sk_prot_free net/core/sock.c:1512 [inline]
 __sk_destruct+0x4b6/0x6d0 net/core/sock.c:1596
 sk_destruct+0x7b/0x90 net/core/sock.c:1604
 __sk_free+0xce/0x300 net/core/sock.c:1615
 sk_free+0x42/0x50 net/core/sock.c:1626
 sock_put include/net/sock.h:1707 [inline]
 unix_release_sock+0x921/0xbb0 net/unix/af_unix.c:573
 unix_release+0x44/0x90 net/unix/af_unix.c:835
 __sock_release+0xd3/0x250 net/socket.c:579
 sock_close+0x1b/0x30 net/socket.c:1139
 __fput+0x2df/0x8d0 fs/file_table.c:278
 ____fput+0x16/0x20 fs/file_table.c:309
 task_work_run+0x14a/0x1c0 kernel/task_work.c:113
 tracehook_notify_resume include/linux/tracehook.h:188 [inline]
 exit_to_usermode_loop+0x273/0x2c0 arch/x86/entry/common.c:166
 prepare_exit_to_usermode arch/x86/entry/common.c:197 [inline]
 syscall_return_slowpath arch/x86/entry/common.c:268 [inline]
 do_syscall_64+0x52d/0x610 arch/x86/entry/common.c:293
 entry_SYSCALL_64_after_hwframe+0x49/0xbe

The buggy address belongs to the object at ffff8880a01af880
 which belongs to the cache UNIX(23:syz5) of size 1728
The buggy address is located 928 bytes inside of
 1728-byte region [ffff8880a01af880, ffff8880a01aff40)
The buggy address belongs to the page:
page:ffffea0002806bc0 count:1 mapcount:0 mapping:ffff888094fa46c0 index:0x0
flags: 0x1fffc0000000200(slab)
raw: 01fffc0000000200 ffffea0002955ec8 ffffea00025d9e88 ffff888094fa46c0
raw: 0000000000000000 ffff8880a01af140 0000000100000002 ffff88808c96eec0
page dumped because: kasan: bad access detected
page->mem_cgroup:ffff88808c96eec0

Memory state around the buggy address:
 ffff8880a01afb00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff8880a01afb80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff8880a01afc00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                               ^
 ffff8880a01afc80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff8880a01afd00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================
------------[ cut here ]------------
downgrading a read lock
WARNING: CPU: 1 PID: 13124 at kernel/locking/lockdep.c:3553 __lock_downgrade kernel/locking/lockdep.c:3553 [inline]
WARNING: CPU: 1 PID: 13124 at kernel/locking/lockdep.c:3553 lock_downgrade+0x478/0x810 kernel/locking/lockdep.c:3816
kobject: 'loop3' (00000000fcb52bc5): fill_kobj_path: path = '/devices/virtual/block/loop3'

Crashes (2):
Manager Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Title
ci-upstream-kasan-gce-smack-root 2019/02/27 13:22 upstream 7d762d69145a 083cfd0e .config log report syz
ci-upstream-kasan-gce 2019/02/27 09:15 upstream 7d762d69145a f2468c12 .config log report syz