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

From: syzbot
Date: Wed May 15 2019 - 01:29:50 EST


Hello,

syzbot found the following crash on:

HEAD commit: 63863ee8 Merge tag 'gcc-plugins-v5.2-rc1' of ssh://gitolit..
git tree: net-next
console output: https://syzkaller.appspot.com/x/log.txt?x=128b8d74a00000
kernel config: https://syzkaller.appspot.com/x/.config?x=52ff73a1f6d0b441
dashboard link: https://syzkaller.appspot.com/bug?extid=81215bf96c82318c7e74
compiler: gcc (GCC) 9.0.0 20181231 (experimental)

Unfortunately, I don't have any reproducer for this crash yet.

IMPORTANT: if you fix the bug, please add the following tag to the commit:
Reported-by: syzbot+81215bf96c82318c7e74@xxxxxxxxxxxxxxxxxxxxxxxxx

==================================================================
BUG: KASAN: use-after-free in timer_is_static_object+0x80/0x90 kernel/time/timer.c:608
Read of size 8 at addr ffff8880a5e88da8 by task kworker/0:2/2851

CPU: 0 PID: 2851 Comm: kworker/0:2 Not tainted 5.1.0+ #7
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
Workqueue: pencrypt padata_serial_worker
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:188
__kasan_report.cold+0x1b/0x40 mm/kasan/report.c:317
kasan_report+0x12/0x20 mm/kasan/common.c:614
__asan_report_load8_noabort+0x14/0x20 mm/kasan/generic_report.c:132
timer_is_static_object+0x80/0x90 kernel/time/timer.c:608
debug_object_activate+0x298/0x4f0 lib/debugobjects.c:510
debug_timer_activate kernel/time/timer.c:710 [inline]
__mod_timer kernel/time/timer.c:1035 [inline]
mod_timer kernel/time/timer.c:1096 [inline]
add_timer+0x3c6/0x930 kernel/time/timer.c:1132
__queue_delayed_work+0x1af/0x270 kernel/workqueue.c:1648
queue_delayed_work_on+0x19a/0x200 kernel/workqueue.c:1673
queue_delayed_work include/linux/workqueue.h:509 [inline]
schedule_delayed_work include/linux/workqueue.h:610 [inline]
tls_encrypt_done+0x44c/0x560 net/tls/tls_sw.c:477
aead_request_complete include/crypto/internal/aead.h:75 [inline]
pcrypt_aead_serial+0x7f/0xb0 crypto/pcrypt.c:123
padata_serial_worker+0x2a8/0x4b0 kernel/padata.c:349
process_one_work+0x98e/0x1790 kernel/workqueue.c:2268
worker_thread+0x98/0xe40 kernel/workqueue.c:2414
kthread+0x357/0x430 kernel/kthread.c:253
ret_from_fork+0x3a/0x50 arch/x86/entry/entry_64.S:352

Allocated by task 9310:
save_stack+0x23/0x90 mm/kasan/common.c:71
set_track mm/kasan/common.c:79 [inline]
__kasan_kmalloc mm/kasan/common.c:489 [inline]
__kasan_kmalloc.constprop.0+0xcf/0xe0 mm/kasan/common.c:462
kasan_kmalloc+0x9/0x10 mm/kasan/common.c:503
kmem_cache_alloc_trace+0x151/0x760 mm/slab.c:3586
kmalloc include/linux/slab.h:547 [inline]
kzalloc include/linux/slab.h:742 [inline]
tls_set_sw_offload+0x123e/0x1640 net/tls/tls_sw.c:2193
do_tls_setsockopt_conf net/tls/tls_main.c:527 [inline]
do_tls_setsockopt net/tls/tls_main.c:574 [inline]
tls_setsockopt+0x7cd/0x8d0 net/tls/tls_main.c:593
sock_common_setsockopt+0x9a/0xe0 net/core/sock.c:3130
__sys_setsockopt+0x180/0x280 net/socket.c:2078
__do_sys_setsockopt net/socket.c:2089 [inline]
__se_sys_setsockopt net/socket.c:2086 [inline]
__x64_sys_setsockopt+0xbe/0x150 net/socket.c:2086
do_syscall_64+0x103/0x670 arch/x86/entry/common.c:298
entry_SYSCALL_64_after_hwframe+0x49/0xbe

Freed by task 9303:
save_stack+0x23/0x90 mm/kasan/common.c:71
set_track mm/kasan/common.c:79 [inline]
__kasan_slab_free+0x102/0x150 mm/kasan/common.c:451
kasan_slab_free+0xe/0x10 mm/kasan/common.c:459
__cache_free mm/slab.c:3463 [inline]
kfree+0xcf/0x230 mm/slab.c:3786
tls_sw_free_resources_tx+0x3b3/0x6e0 net/tls/tls_sw.c:2100
tls_sk_proto_close+0x5fa/0x780 net/tls/tls_main.c:289
inet_release+0x105/0x1f0 net/ipv4/af_inet.c:432
inet6_release+0x53/0x80 net/ipv6/af_inet6.c:474
__sock_release+0xd3/0x2b0 net/socket.c:607
sock_close+0x1b/0x30 net/socket.c:1279
__fput+0x302/0x890 fs/file_table.c:279
____fput+0x16/0x20 fs/file_table.c:312
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:167
prepare_exit_to_usermode arch/x86/entry/common.c:198 [inline]
syscall_return_slowpath arch/x86/entry/common.c:276 [inline]
do_syscall_64+0x57e/0x670 arch/x86/entry/common.c:301
entry_SYSCALL_64_after_hwframe+0x49/0xbe

The buggy address belongs to the object at ffff8880a5e88d00
which belongs to the cache kmalloc-512 of size 512
The buggy address is located 168 bytes inside of
512-byte region [ffff8880a5e88d00, ffff8880a5e88f00)
The buggy address belongs to the page:
page:ffffea000297a200 count:1 mapcount:0 mapping:ffff8880aa400940 index:0x0
flags: 0x1fffc0000000200(slab)
raw: 01fffc0000000200 ffffea00012ac408 ffffea0002947608 ffff8880aa400940
raw: 0000000000000000 ffff8880a5e88080 0000000100000006 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
ffff8880a5e88c80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
ffff8880a5e88d00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff8880a5e88d80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
^
ffff8880a5e88e00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff8880a5e88e80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================


---
This bug is generated by a bot. It may contain errors.
See https://goo.gl/tpsmEJ for more information about syzbot.
syzbot engineers can be reached at syzkaller@xxxxxxxxxxxxxxxxx

syzbot will keep track of this bug report. See:
https://goo.gl/tpsmEJ#status for how to communicate with syzbot.