Bad refcount user syz ================================================================== BUG: KASAN: use-after-free in atomic_read include/asm-generic/atomic-instrumented.h:26 [inline] BUG: KASAN: use-after-free in refcount_inc_not_zero_checked+0x81/0x200 lib/refcount.c:123 Read of size 4 at addr ffff888099bfb000 by task syz-executor.1/27415 CPU: 0 PID: 27415 Comm: syz-executor.1 Not tainted 5.4.0-rc3+ #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 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_inc_not_zero_checked+0x81/0x200 lib/refcount.c:123 refcount_inc_checked+0x17/0x70 lib/refcount.c:156 __key_get include/linux/key.h:281 [inline] find_key_to_update+0xe3/0x110 security/keys/keyring.c:1130 key_create_or_update+0x588/0xbe0 security/keys/key.c:905 __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 RIP: 0033:0x459a59 Code: fd b7 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 cb b7 fb ff c3 66 2e 0f 1f 84 00 00 00 00 RSP: 002b:00007f526ca0dc78 EFLAGS: 00000246 ORIG_RAX: 00000000000000f8 RAX: ffffffffffffffda RBX: 0000000000000005 RCX: 0000000000459a59 RDX: 0000000020000440 RSI: 0000000020000000 RDI: 0000000020000040 RBP: 000000000075bf20 R08: fffffffffffffffe R09: 0000000000000000 R10: 0000000000000001 R11: 0000000000000246 R12: 00007f526ca0e6d4 R13: 00000000004bfab8 R14: 00000000004d1ad8 R15: 00000000ffffffff Allocated by task 27415: 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 5: 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 ffff888099bfb000 which belongs to the cache key_jar of size 312 The buggy address is located 0 bytes inside of 312-byte region [ffff888099bfb000, ffff888099bfb138) The buggy address belongs to the page: page:ffffea000266fec0 refcount:1 mapcount:0 mapping:ffff88821bc4f000 index:0x0 flags: 0x1fffc0000000200(slab) raw: 01fffc0000000200 ffffea0002022048 ffffea00025ed788 ffff88821bc4f000 raw: 0000000000000000 ffff888099bfb000 000000010000000a 0000000000000000 page dumped because: kasan: bad access detected Memory state around the buggy address: ffff888099bfaf00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fc ffff888099bfaf80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc >ffff888099bfb000: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ^ ffff888099bfb080: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ffff888099bfb100: fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc fc ==================================================================