syzbot


KASAN: use-after-free Write in afs_manage_cell

Status: fixed on 2020/11/16 12:12
Subsystems: afs
[Documentation on labels]
Reported-by: syzbot+f59c67285cb61166a0cf@syzkaller.appspotmail.com
Fix commit: 1d0e850a49a5 afs: Fix cell removal
First crash: 1441d, last: 1371d
Cause bisection: introduced by (bisect log) :
commit c99c2171fc61476afac0dfb59fb2c447a01fb1e0
Author: David Howells <dhowells@redhat.com>
Date: Thu Nov 1 23:07:27 2018 +0000

  afs: Use fs_context to pass parameters over automount

Crash: KASAN: use-after-free Read in fscache_alloc_cookie (log)
Repro: C syz .config
  
Fix bisection: fixed by (bisect log) :
commit 1d0e850a49a5b56f8f3cb51e74a11e2fedb96be6
Author: David Howells <dhowells@redhat.com>
Date: Fri Oct 16 12:21:14 2020 +0000

  afs: Fix cell removal

  
Discussions (1)
Title Replies (including bot) Last reply
KASAN: use-after-free Write in afs_manage_cell 1 (5) 2020/11/14 14:41
Last patch testing requests (1)
Created Duration User Patch Repo Result
2020/11/03 02:11 20m foxhlchen@gmail.com upstream OK

Sample crash report:
==================================================================
BUG: KASAN: use-after-free in afs_deactivate_cell fs/afs/cell.c:653 [inline]
BUG: KASAN: use-after-free in afs_manage_cell+0x67f/0x1540 fs/afs/cell.c:721
Write of size 8 at addr ffff88809f692090 by task kworker/1:3/2652

CPU: 1 PID: 2652 Comm: kworker/1:3 Not tainted 5.9.0-rc8-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+0x1d6/0x29e lib/dump_stack.c:118
 print_address_description+0x66/0x620 mm/kasan/report.c:383
 __kasan_report mm/kasan/report.c:513 [inline]
 kasan_report+0x132/0x1d0 mm/kasan/report.c:530
 afs_deactivate_cell fs/afs/cell.c:653 [inline]
 afs_manage_cell+0x67f/0x1540 fs/afs/cell.c:721
 process_one_work+0x789/0xfc0 kernel/workqueue.c:2269
 process_scheduled_works kernel/workqueue.c:2331 [inline]
 worker_thread+0xde4/0x1460 kernel/workqueue.c:2417
 kthread+0x37e/0x3a0 drivers/block/aoe/aoecmd.c:1234
 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:294

Allocated by task 21356:
 kasan_save_stack mm/kasan/common.c:48 [inline]
 kasan_set_track mm/kasan/common.c:56 [inline]
 __kasan_kmalloc+0x100/0x130 mm/kasan/common.c:461
 kmem_cache_alloc_trace+0x1e4/0x2e0 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+0x4ab/0x14d0 fs/afs/cell.c:262
 afs_parse_source fs/afs/super.c:290 [inline]
 afs_parse_param+0x526/0x790 fs/afs/super.c:326
 vfs_parse_fs_param+0x1e5/0x460 fs/fs_context.c:117
 vfs_parse_fs_string fs/fs_context.c:161 [inline]
 generic_parse_monolithic+0x230/0x350 fs/fs_context.c:201
 do_new_mount fs/namespace.c:2871 [inline]
 path_mount+0x176c/0x29e0 fs/namespace.c:3192
 do_mount fs/namespace.c:3205 [inline]
 __do_sys_mount fs/namespace.c:3413 [inline]
 __se_sys_mount+0x126/0x180 fs/namespace.c:3390
 do_syscall_64+0x31/0x70 arch/x86/entry/common.c:46
 entry_SYSCALL_64_after_hwframe+0x44/0xa9

Freed by task 2652:
 kasan_save_stack mm/kasan/common.c:48 [inline]
 kasan_set_track+0x3d/0x70 mm/kasan/common.c:56
 kasan_set_free_info+0x17/0x30 mm/kasan/generic.c:355
 __kasan_slab_free+0xdd/0x110 mm/kasan/common.c:422
 __cache_free mm/slab.c:3422 [inline]
 kfree+0x113/0x200 mm/slab.c:3760
 rcu_do_batch kernel/rcu/tree.c:2430 [inline]
 rcu_core+0x79b/0x1130 kernel/rcu/tree.c:2658
 __do_softirq+0x256/0x6d5 kernel/softirq.c:298

Last call_rcu():
 kasan_save_stack+0x27/0x50 mm/kasan/common.c:48
 kasan_record_aux_stack+0x7b/0xb0 mm/kasan/generic.c:346
 __call_rcu kernel/rcu/tree.c:2896 [inline]
 call_rcu+0x141/0x830 kernel/rcu/tree.c:2970
 afs_manage_cell+0xd7d/0x1540 fs/afs/cell.c:751
 process_one_work+0x789/0xfc0 kernel/workqueue.c:2269
 worker_thread+0xaa4/0x1460 kernel/workqueue.c:2415
 kthread+0x37e/0x3a0 drivers/block/aoe/aoecmd.c:1234
 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:294

Second to last call_rcu():
 kasan_save_stack+0x27/0x50 mm/kasan/common.c:48
 kasan_record_aux_stack+0x7b/0xb0 mm/kasan/generic.c:346
 __call_rcu kernel/rcu/tree.c:2896 [inline]
 call_rcu+0x141/0x830 kernel/rcu/tree.c:2970
 afs_manage_cell+0xd7d/0x1540 fs/afs/cell.c:751
 process_one_work+0x789/0xfc0 kernel/workqueue.c:2269
 worker_thread+0xaa4/0x1460 kernel/workqueue.c:2415
 kthread+0x37e/0x3a0 drivers/block/aoe/aoecmd.c:1234
 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:294

The buggy address belongs to the object at ffff88809f692000
 which belongs to the cache kmalloc-1k of size 1024
The buggy address is located 144 bytes inside of
 1024-byte region [ffff88809f692000, ffff88809f692400)
The buggy address belongs to the page:
page:00000000e1f1106e refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x9f692
flags: 0xfffe0000000200(slab)
raw: 00fffe0000000200 ffffea000252e048 ffffea00027a1888 ffff8880aa440700
raw: 0000000000000000 ffff88809f692000 0000000100000002 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
 ffff88809f691f80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
 ffff88809f692000: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff88809f692080: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                         ^
 ffff88809f692100: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff88809f692180: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================

Crashes (20):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2020/10/11 10:51 upstream da690031a5d6 4a77ae0b .config console log report syz C ci-upstream-kasan-gce-smack-root
2020/10/10 07:50 upstream 6f2f486d57c4 93817d89 .config console log report syz C ci-upstream-kasan-gce-selinux-root
2020/08/26 10:25 upstream abb3438d69fb 344da168 .config console log report syz C ci-upstream-kasan-gce-smack-root
2020/08/26 09:44 upstream abb3438d69fb 344da168 .config console log report syz C ci-upstream-kasan-gce-root
2020/10/12 13:02 upstream 3dd0130f2430 4a77ae0b .config console log report syz ci-upstream-kasan-gce-smack-root
2020/10/06 14:53 upstream 7575fdda569b 1880b4a9 .config console log report syz ci-upstream-kasan-gce-smack-root
2020/10/15 10:27 upstream 3e4fb4346c78 63869021 .config console log report info ci-upstream-kasan-gce
2020/10/05 17:17 upstream 549738f15da0 1880b4a9 .config console log report info ci-upstream-kasan-gce-smack-root
2020/09/28 10:09 upstream a1b8638ba132 6bfdbe89 .config console log report info ci-upstream-kasan-gce-selinux-root
2020/09/28 10:05 upstream a1b8638ba132 6bfdbe89 .config console log report info ci-upstream-kasan-gce-smack-root
2020/09/28 00:58 upstream a1bffa48745a 5dd8aee8 .config console log report info ci-upstream-kasan-gce-smack-root
2020/09/24 04:45 upstream c9c9e6a49f89 54289b08 .config console log report info ci-upstream-kasan-gce-selinux-root
2020/09/20 18:02 upstream 325d0eab4f31 9564d2e9 .config console log report info ci-upstream-kasan-gce-smack-root
2020/09/20 08:51 upstream 325d0eab4f31 53ce8104 .config console log report info ci-upstream-kasan-gce-root
2020/09/20 03:30 upstream eb5f95f1593f 53ce8104 .config console log report info ci-upstream-kasan-gce-root
2020/08/30 13:43 upstream 1127b219ce94 d5a3ae1f .config console log report ci-upstream-kasan-gce-root
2020/08/06 04:31 upstream fffe3ae0ee84 0487ea6f .config console log report ci-upstream-kasan-gce-root
2020/10/08 05:36 linux-next 8b787da7ba8c 1880b4a9 .config console log report info ci-upstream-linux-next-kasan-gce-root
2020/09/21 14:36 linux-next b10b8ad86211 9e1fa68e .config console log report info ci-upstream-linux-next-kasan-gce-root
2020/08/26 08:25 linux-next 3a00d3dfd4b6 344da168 .config console log report ci-upstream-linux-next-kasan-gce-root
* Struck through repros no longer work on HEAD.