syzbot


KASAN: use-after-free Read in keyring_compare_object

Status: closed as invalid on 2020/03/07 23:11
Subsystems: keyrings lsm
[Documentation on labels]
Reported-by: syzbot+9a02c5074e2307825994@syzkaller.appspotmail.com
First crash: 1957d, last: 1828d
Discussions (1)
Title Replies (including bot) Last reply
KASAN: use-after-free Read in keyring_compare_object 0 (1) 2019/07/24 15:46

Sample crash report:
==================================================================
BUG: KASAN: use-after-free in keyring_compare_object+0x1d0/0x220 security/keys/keyring.c:314
Read of size 8 at addr ffff8880a1bdb638 by task syz-executor.0/26780

CPU: 1 PID: 26780 Comm: syz-executor.0 Not tainted 5.4.0-rc5+ #0
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.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
 __asan_report_load8_noabort+0x14/0x20 mm/kasan/generic_report.c:132
 keyring_compare_object+0x1d0/0x220 security/keys/keyring.c:314
 assoc_array_find+0x14b/0x1f0 lib/assoc_array.c:331
 search_keyring security/keys/keyring.c:655 [inline]
 search_nested_keyrings+0xb15/0xea0 security/keys/keyring.c:722
 keyring_search_rcu+0x1b4/0x290 security/keys/keyring.c:926
 search_cred_keyrings_rcu+0x1fa/0x2e0 security/keys/process_keys.c:501
 search_process_keyrings_rcu+0x1d/0x320 security/keys/process_keys.c:544
 request_key_and_link+0x2a5/0x12b0 security/keys/request_key.c:602
 __do_sys_request_key security/keys/keyctl.c:223 [inline]
 __se_sys_request_key security/keys/keyctl.c:168 [inline]
 __x64_sys_request_key+0x285/0x430 security/keys/keyctl.c:168
 do_syscall_64+0xfa/0x760 arch/x86/entry/common.c:290
 entry_SYSCALL_64_after_hwframe+0x49/0xbe
RIP: 0033:0x459f49
Code: ad b6 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 b6 fb ff c3 66 2e 0f 1f 84 00 00 00 00
RSP: 002b:00007f5c78dc6c78 EFLAGS: 00000246 ORIG_RAX: 00000000000000f9
RAX: ffffffffffffffda RBX: 0000000000000004 RCX: 0000000000459f49
RDX: 0000000020000380 RSI: 0000000020000340 RDI: 0000000020000100
RBP: 000000000075bf20 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 00007f5c78dc76d4
R13: 00000000004c794a R14: 00000000004dd840 R15: 00000000ffffffff

Allocated by task 7536:
 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 22:
 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
 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

The buggy address belongs to the object at ffff8880a1bdb540
 which belongs to the cache key_jar of size 312
The buggy address is located 248 bytes inside of
 312-byte region [ffff8880a1bdb540, ffff8880a1bdb678)
The buggy address belongs to the page:
page:ffffea000286f6c0 refcount:1 mapcount:0 mapping:ffff88821bc4f000 index:0xffff8880a1bdb6c0
flags: 0x1fffc0000000200(slab)
raw: 01fffc0000000200 ffffea00026e90c8 ffff8880aa5a2a38 ffff88821bc4f000
raw: ffff8880a1bdb6c0 ffff8880a1bdb0c0 0000000100000009 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
 ffff8880a1bdb500: fc fc fc fc fc fc fc fc fb fb fb fb fb fb fb fb
 ffff8880a1bdb580: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff8880a1bdb600: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fc
                                        ^
 ffff8880a1bdb680: fc fc fc fc fc fc fc fc fb fb fb fb fb fb fb fb
 ffff8880a1bdb700: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================

Crashes (6):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2019/10/31 02:43 upstream 320000e72ec0 a41ca8fa .config console log report ci-upstream-kasan-gce
2019/08/29 03:38 upstream 6525771f58cb fd37b39e .config console log report ci-upstream-kasan-gce
2019/08/08 20:08 upstream ecb095bff5d4 e6ebef88 .config console log report ci-upstream-kasan-gce-root
2019/08/04 04:40 upstream dcb8cfbd8fe9 6affd8e8 .config console log report ci-upstream-kasan-gce-selinux-root
2019/11/26 19:04 upstream be2eca94d144 1048481f .config console log report ci-upstream-kasan-gce-386
2019/07/20 14:13 upstream abdfd52a295f 1656845f .config console log report ci-upstream-kasan-gce-386
* Struck through repros no longer work on HEAD.