syzbot


KASAN: use-after-free Read in work_is_static_object

Status: fixed on 2018/05/09 07:47
Subsystems: net
[Documentation on labels]
Reported-by: syzbot+40396d275b34b0dd5dad@syzkaller.appspotmail.com
Fix commit: 2cc683e88c0c kcm: lock lower socket in kcm_attach
First crash: 2300d, last: 2285d
Discussions (1)
Title Replies (including bot) Last reply
Re: KASAN: use-after-free Read in work_is_static_object 3 (3) 2018/05/09 02:49

Sample crash report:
device ip6_vti0 entered promiscuous mode
==================================================================
BUG: KASAN: use-after-free in constant_test_bit arch/x86/include/asm/bitops.h:325 [inline]
BUG: KASAN: use-after-free in work_is_static_object+0x39/0x40 kernel/workqueue.c:443
Read of size 8 at addr ffff8801beca5788 by task syz-executor2/12922

CPU: 0 PID: 12922 Comm: syz-executor2 Not tainted 4.15.0-rc5+ #178
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
Call Trace:
 __dump_stack lib/dump_stack.c:17 [inline]
 dump_stack+0x194/0x257 lib/dump_stack.c:53
 print_address_description+0x73/0x250 mm/kasan/report.c:252
 kasan_report_error mm/kasan/report.c:351 [inline]
 kasan_report+0x25b/0x340 mm/kasan/report.c:409
 __asan_report_load8_noabort+0x14/0x20 mm/kasan/report.c:430
 constant_test_bit arch/x86/include/asm/bitops.h:325 [inline]
 work_is_static_object+0x39/0x40 kernel/workqueue.c:443
 debug_object_activate+0x36f/0x730 lib/debugobjects.c:470
 debug_work_activate kernel/workqueue.c:492 [inline]
 __queue_work+0x163/0x1230 kernel/workqueue.c:1381
 queue_work_on+0x16a/0x1c0 kernel/workqueue.c:1487
 queue_work include/linux/workqueue.h:488 [inline]
 strp_check_rcv+0x25/0x30 net/strparser/strparser.c:552
 kcm_attach net/kcm/kcmsock.c:1439 [inline]
 kcm_attach_ioctl net/kcm/kcmsock.c:1460 [inline]
 kcm_ioctl+0x82f/0x1690 net/kcm/kcmsock.c:1665
 sock_do_ioctl+0x65/0xb0 net/socket.c:956
 sock_ioctl+0x2c2/0x440 net/socket.c:1053
 vfs_ioctl fs/ioctl.c:46 [inline]
 do_vfs_ioctl+0x1b1/0x1520 fs/ioctl.c:686
 SYSC_ioctl fs/ioctl.c:701 [inline]
 SyS_ioctl+0x8f/0xc0 fs/ioctl.c:692
 entry_SYSCALL_64_fastpath+0x23/0x9a
RIP: 0033:0x452ac9
RSP: 002b:00007f1bbd860c58 EFLAGS: 00000212 ORIG_RAX: 0000000000000010
RAX: ffffffffffffffda RBX: 000000000071bea0 RCX: 0000000000452ac9
RDX: 0000000020954ff8 RSI: 00000000000089e0 RDI: 0000000000000017
RBP: 000000000000057b R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000212 R12: 00000000006f6428
R13: 00000000ffffffff R14: 00007f1bbd8616d4 R15: 0000000000000000

Allocated by task 12922:
 save_stack+0x43/0xd0 mm/kasan/kasan.c:447
 set_track mm/kasan/kasan.c:459 [inline]
 kasan_kmalloc+0xad/0xe0 mm/kasan/kasan.c:551
 kasan_slab_alloc+0x12/0x20 mm/kasan/kasan.c:489
 kmem_cache_alloc+0x12e/0x760 mm/slab.c:3544
 kmem_cache_zalloc include/linux/slab.h:678 [inline]
 kcm_attach net/kcm/kcmsock.c:1394 [inline]
 kcm_attach_ioctl net/kcm/kcmsock.c:1460 [inline]
 kcm_ioctl+0x2d2/0x1690 net/kcm/kcmsock.c:1665
 sock_do_ioctl+0x65/0xb0 net/socket.c:956
 sock_ioctl+0x2c2/0x440 net/socket.c:1053
 vfs_ioctl fs/ioctl.c:46 [inline]
 do_vfs_ioctl+0x1b1/0x1520 fs/ioctl.c:686
 SYSC_ioctl fs/ioctl.c:701 [inline]
 SyS_ioctl+0x8f/0xc0 fs/ioctl.c:692
 entry_SYSCALL_64_fastpath+0x23/0x9a

Freed by task 12929:
 save_stack+0x43/0xd0 mm/kasan/kasan.c:447
 set_track mm/kasan/kasan.c:459 [inline]
 kasan_slab_free+0x71/0xc0 mm/kasan/kasan.c:524
 __cache_free mm/slab.c:3488 [inline]
 kmem_cache_free+0x83/0x2a0 mm/slab.c:3746
 kcm_unattach+0xe53/0x1510 net/kcm/kcmsock.c:1563
 kcm_unattach_ioctl net/kcm/kcmsock.c:1608 [inline]
 kcm_ioctl+0xe54/0x1690 net/kcm/kcmsock.c:1675
 sock_do_ioctl+0x65/0xb0 net/socket.c:956
 sock_ioctl+0x2c2/0x440 net/socket.c:1053
 vfs_ioctl fs/ioctl.c:46 [inline]
 do_vfs_ioctl+0x1b1/0x1520 fs/ioctl.c:686
 SYSC_ioctl fs/ioctl.c:701 [inline]
 SyS_ioctl+0x8f/0xc0 fs/ioctl.c:692
 entry_SYSCALL_64_fastpath+0x23/0x9a

The buggy address belongs to the object at ffff8801beca56c0
 which belongs to the cache kcm_psock_cache of size 544
The buggy address is located 200 bytes inside of
 544-byte region [ffff8801beca56c0, ffff8801beca58e0)
The buggy address belongs to the page:
page:000000005180a80a count:1 mapcount:0 mapping:0000000058aa9a5c index:0x0 compound_mapcount: 0
flags: 0x2fffc0000008100(slab|head)
raw: 02fffc0000008100 ffff8801beca40c0 0000000000000000 000000010000000b
raw: ffff8801d31e8a48 ffff8801d31e8a48 ffff8801d3f6a380 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
 ffff8801beca5680: fc fc fc fc fc fc fc fc fb fb fb fb fb fb fb fb
 ffff8801beca5700: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff8801beca5780: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                      ^
 ffff8801beca5800: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff8801beca5880: fb fb fb fb fb fb fb fb fb fb fb fb fc fc fc fc
==================================================================

Crashes (3):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2018/01/08 07:25 net-next-old f66faae2f80a 19c05fff .config console log report ci-upstream-net-kasan-gce
2018/01/23 20:03 bpf-next 2310035fa03f a5b7566c .config console log report ci-upstream-bpf-next-kasan-gce
2018/01/10 15:04 linux-next b4464bcab38d 02a19b64 .config console log report ci-upstream-next-kasan-gce
* Struck through repros no longer work on HEAD.