syzbot


KASAN: use-after-free Read in key_put

Status: auto-closed as invalid on 2020/02/22 07:21
Subsystems: keyrings lsm
[Documentation on labels]
Reported-by: syzbot+f3745a1dc2a5eb5040ef@syzkaller.appspotmail.com
First crash: 1932d, last: 1891d
Discussions (1)
Title Replies (including bot) Last reply
KASAN: use-after-free Read in key_put 0 (1) 2019/09/18 08:05

Sample crash report:
==================================================================
BUG: KASAN: use-after-free in atomic_read include/asm-generic/atomic-instrumented.h:26 [inline]
BUG: KASAN: use-after-free in refcount_sub_and_test_checked+0x87/0x200 lib/refcount.c:182
Read of size 4 at addr ffff888097ea1680 by task kworker/0:7/32188

CPU: 0 PID: 32188 Comm: kworker/0:7 Not tainted 5.4.0-rc3+ #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
Workqueue: events key_garbage_collector
Call Trace:
 __dump_stack lib/dump_stack.c:77 [inline]
 dump_stack+0x172/0x1f0 lib/dump_stack.c:113
 print_address_description.constprop.0.cold+0xd4/0x30b mm/kasan/report.c:374
 __kasan_report.cold+0x1b/0x41 mm/kasan/report.c:506
 kasan_report+0x12/0x20 mm/kasan/common.c:634
 check_memory_region_inline mm/kasan/generic.c:185 [inline]
 check_memory_region+0x134/0x1a0 mm/kasan/generic.c:192
 __kasan_check_read+0x11/0x20 mm/kasan/common.c:92
 atomic_read include/asm-generic/atomic-instrumented.h:26 [inline]
 refcount_sub_and_test_checked+0x87/0x200 lib/refcount.c:182
 refcount_dec_and_test_checked+0x1b/0x20 lib/refcount.c:220
 key_put+0x20/0x90 security/keys/key.c:646
 keyring_free_object+0x19/0x20 security/keys/keyring.c:389
 assoc_array_destroy_subtree.part.0+0x1c5/0x4b0 lib/assoc_array.c:393
 assoc_array_destroy_subtree lib/assoc_array.c:354 [inline]
 assoc_array_destroy+0x43/0x90 lib/assoc_array.c:444
 keyring_destroy+0x259/0x2f0 security/keys/keyring.c:431
 key_gc_unused_keys.constprop.0+0x315/0x5b0 security/keys/gc.c:136
 key_garbage_collector+0x3f3/0x940 security/keys/gc.c:292
 process_one_work+0x9af/0x1740 kernel/workqueue.c:2269
 worker_thread+0x98/0xe40 kernel/workqueue.c:2415
 kthread+0x361/0x430 kernel/kthread.c:255
 ret_from_fork+0x24/0x30 arch/x86/entry/entry_64.S:352

Allocated by task 1021:
 save_stack+0x23/0x90 mm/kasan/common.c:69
 set_track mm/kasan/common.c:77 [inline]
 __kasan_kmalloc mm/kasan/common.c:510 [inline]
 __kasan_kmalloc.constprop.0+0xcf/0xe0 mm/kasan/common.c:483
 kasan_slab_alloc+0xf/0x20 mm/kasan/common.c:518
 slab_post_alloc_hook mm/slab.h:584 [inline]
 slab_alloc mm/slab.c:3319 [inline]
 kmem_cache_alloc+0x121/0x710 mm/slab.c:3483
 kmem_cache_zalloc include/linux/slab.h:680 [inline]
 key_alloc+0x426/0x1110 security/keys/key.c:276
 key_create_or_update+0x652/0xbe0 security/keys/key.c:924
 __do_sys_add_key security/keys/keyctl.c:132 [inline]
 __se_sys_add_key security/keys/keyctl.c:72 [inline]
 __x64_sys_add_key+0x2bd/0x4f0 security/keys/keyctl.c:72
 do_syscall_64+0xfa/0x760 arch/x86/entry/common.c:290
 entry_SYSCALL_64_after_hwframe+0x49/0xbe

Freed by task 32188:
 save_stack+0x23/0x90 mm/kasan/common.c:69
 set_track mm/kasan/common.c:77 [inline]
 kasan_set_free_info mm/kasan/common.c:332 [inline]
 __kasan_slab_free+0x102/0x150 mm/kasan/common.c:471
 kasan_slab_free+0xe/0x10 mm/kasan/common.c:480
 __cache_free mm/slab.c:3425 [inline]
 kmem_cache_free+0x86/0x320 mm/slab.c:3693
 key_gc_unused_keys.constprop.0+0x194/0x5b0 security/keys/gc.c:157
 key_garbage_collector+0x3f3/0x940 security/keys/gc.c:292
 process_one_work+0x9af/0x1740 kernel/workqueue.c:2269
 process_scheduled_works kernel/workqueue.c:2331 [inline]
 worker_thread+0x7be/0xe40 kernel/workqueue.c:2417
 kthread+0x361/0x430 kernel/kthread.c:255
 ret_from_fork+0x24/0x30 arch/x86/entry/entry_64.S:352

The buggy address belongs to the object at ffff888097ea1680
 which belongs to the cache key_jar of size 312
The buggy address is located 0 bytes inside of
 312-byte region [ffff888097ea1680, ffff888097ea17b8)
The buggy address belongs to the page:
page:ffffea00025fa840 refcount:1 mapcount:0 mapping:ffff88821bc4f000 index:0xffff888097ea1080
flags: 0x1fffc0000000200(slab)
raw: 01fffc0000000200 ffffea0002382788 ffffea000265f588 ffff88821bc4f000
raw: ffff888097ea1080 ffff888097ea1080 0000000100000008 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
 ffff888097ea1580: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 ffff888097ea1600: 00 00 00 00 00 00 00 fc fc fc fc fc fc fc fc fc
>ffff888097ea1680: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                   ^
 ffff888097ea1700: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff888097ea1780: fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc fc
==================================================================

Crashes (3):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2019/10/16 18:37 upstream bc88f85c6c09 8c88c9c1 .config console log report ci-upstream-kasan-gce
2019/09/14 06:43 upstream a7f89616b737 32d59357 .config console log report ci-upstream-kasan-gce-selinux-root
2019/10/25 07:21 upstream 39a38bcba4ab d01bb02a .config console log report ci-upstream-kasan-gce-386
* Struck through repros no longer work on HEAD.