KASAN: use-after-free Write in afs_deactivate_cell

Status: fixed on 2020/11/16 12:12
Subsystems: afs
[Documentation on labels]
Fix commit: 1d0e850a49a5 afs: Fix cell removal
First crash: 1401d, last: 1380d
Discussions (3)
Title Replies (including bot) Last reply
[PATCH 5.9 000/757] 5.9.2-rc1 review 766 (766) 2020/10/30 08:32
[PATCH 5.8 000/633] 5.8.17-rc1 review 638 (638) 2020/10/28 22:08
KASAN: use-after-free Write in afs_deactivate_cell 0 (1) 2020/09/24 09:40

Sample crash report:
BUG: KASAN: use-after-free in afs_deactivate_cell+0x172/0x1a0 fs/afs/cell.c:653
Write of size 8 at addr ffff8880948ed090 by task kworker/1:11/9457

CPU: 1 PID: 9457 Comm: kworker/1:11 Not tainted 5.9.0-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
Workqueue: afs afs_manage_cell
Call Trace:
 __dump_stack lib/dump_stack.c:77 [inline]
 dump_stack+0x198/0x1fb lib/dump_stack.c:118
 print_address_description.constprop.0.cold+0xae/0x497 mm/kasan/report.c:383
 __kasan_report mm/kasan/report.c:513 [inline]
 kasan_report.cold+0x1f/0x37 mm/kasan/report.c:530
 afs_deactivate_cell+0x172/0x1a0 fs/afs/cell.c:653
 afs_manage_cell+0x326/0x11c0 fs/afs/cell.c:721
 process_one_work+0x933/0x15a0 kernel/workqueue.c:2269
 process_scheduled_works kernel/workqueue.c:2331 [inline]
 worker_thread+0x82b/0x1120 kernel/workqueue.c:2417
 kthread+0x3b5/0x4a0 kernel/kthread.c:292
 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:294

Allocated by task 9891:
 kasan_save_stack+0x1b/0x40 mm/kasan/common.c:48
 kasan_set_track mm/kasan/common.c:56 [inline]
 __kasan_kmalloc.constprop.0+0xbf/0xd0 mm/kasan/common.c:461
 kmem_cache_alloc_trace+0x174/0x300 mm/slab.c:3554
 kmalloc include/linux/slab.h:554 [inline]
 kzalloc include/linux/slab.h:666 [inline]
 afs_alloc_cell fs/afs/cell.c:151 [inline]
 afs_lookup_cell+0x5b8/0x1450 fs/afs/cell.c:262
 afs_parse_source fs/afs/super.c:290 [inline]
 afs_parse_param+0x404/0x8c0 fs/afs/super.c:326
 vfs_parse_fs_param fs/fs_context.c:117 [inline]
 vfs_parse_fs_param+0x203/0x550 fs/fs_context.c:98
 vfs_parse_fs_string+0xe6/0x150 fs/fs_context.c:161
 generic_parse_monolithic+0x16f/0x1f0 fs/fs_context.c:201
 do_new_mount fs/namespace.c:2871 [inline]
 path_mount+0x133f/0x20a0 fs/namespace.c:3203
 do_mount fs/namespace.c:3216 [inline]
 __do_sys_mount fs/namespace.c:3424 [inline]
 __se_sys_mount fs/namespace.c:3401 [inline]
 __x64_sys_mount+0x27f/0x300 fs/namespace.c:3401
 do_syscall_64+0x2d/0x70 arch/x86/entry/common.c:46

Freed by task 9619:
 kasan_save_stack+0x1b/0x40 mm/kasan/common.c:48
 kasan_set_track+0x1c/0x30 mm/kasan/common.c:56
 kasan_set_free_info+0x1b/0x30 mm/kasan/generic.c:355
 __kasan_slab_free+0xd8/0x120 mm/kasan/common.c:422
 __cache_free mm/slab.c:3422 [inline]
 kfree+0x10e/0x2a0 mm/slab.c:3760
 rcu_do_batch kernel/rcu/tree.c:2430 [inline]
 rcu_core+0x5ca/0x1130 kernel/rcu/tree.c:2658
 __do_softirq+0x203/0xac5 kernel/softirq.c:298

Last call_rcu():
 kasan_save_stack+0x1b/0x40 mm/kasan/common.c:48
 kasan_record_aux_stack+0x82/0xb0 mm/kasan/generic.c:346
 __call_rcu kernel/rcu/tree.c:2896 [inline]
 call_rcu+0x15e/0x7c0 kernel/rcu/tree.c:2970
 afs_manage_cell+0x250/0x11c0 fs/afs/cell.c:751
 process_one_work+0x933/0x15a0 kernel/workqueue.c:2269
 worker_thread+0x64c/0x1120 kernel/workqueue.c:2415
 kthread+0x3b5/0x4a0 kernel/kthread.c:292
 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:294

The buggy address belongs to the object at ffff8880948ed000
 which belongs to the cache kmalloc-1k of size 1024
The buggy address is located 144 bytes inside of
 1024-byte region [ffff8880948ed000, ffff8880948ed400)
The buggy address belongs to the page:
page:00000000010559be refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x948ed
flags: 0xfffe0000000200(slab)
raw: 00fffe0000000200 ffffea000154d548 ffffea000252a908 ffff8880aa040700
raw: 0000000000000000 ffff8880948ed000 0000000100000002 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
 ffff8880948ecf80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
 ffff8880948ed000: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff8880948ed080: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff8880948ed100: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff8880948ed180: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb

Crashes (4):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2020/10/14 03:46 upstream 029f56db6ac2 fc7735a2 .config console log report info ci-upstream-kasan-gce-root
2020/10/10 02:53 upstream 6f2f486d57c4 93817d89 .config console log report info ci-upstream-kasan-gce-selinux-root
2020/09/30 15:32 upstream 02de58b24d2e 8516f6d3 .config console log report info ci-upstream-kasan-gce-selinux-root
2020/09/22 15:37 linux-next e64997027d5f 3e8f6c27 .config console log report info ci-upstream-linux-next-kasan-gce-root
* Struck through repros no longer work on HEAD.