syzbot


KASAN: use-after-free Read in get_work_pool

Status: fixed on 2018/03/23 18:14
Reported-by: syzbot+ea75c0ffcd353d32515f064aaebefc5279e6161e@syzkaller.appspotmail.com
Fix commit: 2cc683e88c0c kcm: lock lower socket in kcm_attach
First crash: 1755d, last: 1688d
similar bugs (2):
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
upstream KASAN: use-after-free Read in get_work_pool (2) C done 2 847d 936d 0/22 closed as dup on 2020/02/24 18:36
linux-4.14 KASAN: use-after-free Read in get_work_pool C done 1 851d 941d 1/1 fixed on 2020/04/03 09:27

Sample crash report:
BUG: KASAN: use-after-free in __read_once_size include/linux/compiler.h:276 [inline]
BUG: KASAN: use-after-free in atomic64_read arch/x86/include/asm/atomic64_64.h:21 [inline]
BUG: KASAN: use-after-free in atomic_long_read include/asm-generic/atomic-long.h:44 [inline]
BUG: KASAN: use-after-free in get_work_pool+0x1c2/0x1e0 kernel/workqueue.c:709
Read of size 8 at addr ffff8801cc7fe338 by task syz-executor7/1637

CPU: 1 PID: 1637 Comm: syz-executor7 Not tainted 4.13.0+ #79
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
Call Trace:
 __dump_stack lib/dump_stack.c:16 [inline]
 dump_stack+0x194/0x257 lib/dump_stack.c:52
 print_address_description+0x73/0x250 mm/kasan/report.c:252
 kasan_report_error mm/kasan/report.c:351 [inline]
 kasan_report+0x24e/0x340 mm/kasan/report.c:409
 __asan_report_load8_noabort+0x14/0x20 mm/kasan/report.c:430
 __read_once_size include/linux/compiler.h:276 [inline]
 atomic64_read arch/x86/include/asm/atomic64_64.h:21 [inline]
 atomic_long_read include/asm-generic/atomic-long.h:44 [inline]
 get_work_pool+0x1c2/0x1e0 kernel/workqueue.c:709
 __queue_work+0x235/0x1150 kernel/workqueue.c:1401
 queue_work_on+0x16a/0x1c0 kernel/workqueue.c:1486
 queue_work include/linux/workqueue.h:489 [inline]
 strp_check_rcv+0x25/0x30 net/strparser/strparser.c:553
 kcm_attach net/kcm/kcmsock.c:1439 [inline]
 kcm_attach_ioctl net/kcm/kcmsock.c:1460 [inline]
 kcm_ioctl+0x826/0x1610 net/kcm/kcmsock.c:1695
 sock_do_ioctl+0x65/0xb0 net/socket.c:961
 sock_ioctl+0x2c2/0x440 net/socket.c:1058
 vfs_ioctl fs/ioctl.c:45 [inline]
 do_vfs_ioctl+0x1b1/0x1530 fs/ioctl.c:685
 SYSC_ioctl fs/ioctl.c:700 [inline]
 SyS_ioctl+0x8f/0xc0 fs/ioctl.c:691
 entry_SYSCALL_64_fastpath+0x1f/0xbe
RIP: 0033:0x451e59
RSP: 002b:00007fa38043dc08 EFLAGS: 00000216 ORIG_RAX: 0000000000000010
RAX: ffffffffffffffda RBX: 0000000000718160 RCX: 0000000000451e59
RDX: 00000000209b9000 RSI: 00000000000089e0 RDI: 000000000000000b
RBP: 0000000000000082 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000216 R12: 00000000004b9fa6
R13: 00000000ffffffff R14: 000000000000000b R15: 00000000000089e0

Allocated by task 1637:
 save_stack_trace+0x16/0x20 arch/x86/kernel/stacktrace.c:59
 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:3561
 kmem_cache_zalloc include/linux/slab.h:656 [inline]
 kcm_attach net/kcm/kcmsock.c:1394 [inline]
 kcm_attach_ioctl net/kcm/kcmsock.c:1460 [inline]
 kcm_ioctl+0x2d1/0x1610 net/kcm/kcmsock.c:1695
 sock_do_ioctl+0x65/0xb0 net/socket.c:961
 sock_ioctl+0x2c2/0x440 net/socket.c:1058
 vfs_ioctl fs/ioctl.c:45 [inline]
 do_vfs_ioctl+0x1b1/0x1530 fs/ioctl.c:685
 SYSC_ioctl fs/ioctl.c:700 [inline]
 SyS_ioctl+0x8f/0xc0 fs/ioctl.c:691
 entry_SYSCALL_64_fastpath+0x1f/0xbe

Freed by task 1645:
 save_stack_trace+0x16/0x20 arch/x86/kernel/stacktrace.c:59
 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:3503 [inline]
 kmem_cache_free+0x77/0x280 mm/slab.c:3763
 kcm_unattach+0xe50/0x1510 net/kcm/kcmsock.c:1563
 kcm_unattach_ioctl net/kcm/kcmsock.c:1608 [inline]
 kcm_ioctl+0xdf0/0x1610 net/kcm/kcmsock.c:1705
 sock_do_ioctl+0x65/0xb0 net/socket.c:961
 sock_ioctl+0x2c2/0x440 net/socket.c:1058
 vfs_ioctl fs/ioctl.c:45 [inline]
 do_vfs_ioctl+0x1b1/0x1530 fs/ioctl.c:685
 SYSC_ioctl fs/ioctl.c:700 [inline]
 SyS_ioctl+0x8f/0xc0 fs/ioctl.c:691
 entry_SYSCALL_64_fastpath+0x1f/0xbe

The buggy address belongs to the object at ffff8801cc7fe200
 which belongs to the cache kcm_psock_cache of size 664
The buggy address is located 312 bytes inside of
 664-byte region [ffff8801cc7fe200, ffff8801cc7fe498)
The buggy address belongs to the page:
page:ffffea000731ff80 count:1 mapcount:0 mapping:ffff8801cc7fe200 index:0x0 compound_mapcount: 0
flags: 0x200000000008100(slab|head)
raw: 0200000000008100 ffff8801cc7fe200 0000000000000000 0000000100000009
raw: ffffea00072e4320 ffffea00072d99a0 ffff8801d2e59cc0 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
 ffff8801cc7fe200: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff8801cc7fe280: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff8801cc7fe300: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                                        ^
 ffff8801cc7fe380: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff8801cc7fe400: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================

Crashes (8):
Manager Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Title
ci-upstream-kasan-gce 2017/09/12 03:14 upstream f007cad159e9 449b6f15 .config log report syz
ci-upstream-net-kasan-gce 2017/11/11 13:57 net-next bee955cd3ab4 e0a2b195 .config log report syz
ci-upstream-net-kasan-gce 2017/09/12 12:42 net-next ad9a19d00370 96b8e399 .config log report syz
ci-upstream-net-kasan-gce 2017/09/12 02:18 net-next ad9a19d00370 96b8e399 .config log report syz
ci-upstream-next-kasan-gce 2017/09/12 13:21 linux-next 0d71e2d4aa14 0bd6a0a5 .config log report syz
ci-upstream-net-kasan-gce 2017/11/17 23:35 net-next 6363b3f3ac5b bf820689 .config log report
ci-upstream-net-kasan-gce 2017/11/12 19:21 net-next fdae5f37a88c e0a2b195 .config log report
ci-upstream-net-kasan-gce 2017/10/24 19:02 net-next 49ca1943a7ad 92f543f0 .config log report