syzbot


KASAN: use-after-free Read in get_task_mm

Status: auto-closed as invalid on 2020/03/07 13:32
Reported-by: syzbot+3721b4d0caaf34b4f8bf@syzkaller.appspotmail.com
First crash: 1622d, last: 1618d

Sample crash report:
lowmemorykiller: Killing 'syz-executor.5' (8183) (tgid 8183), adj 1000,
   to free 52508kB on behalf of 'kswapd0' (33) because
   cache 62356kB is below limit 65536kB for oom_score_adj 12
   Free memory is 46896kB above reserved
==================================================================
BUG: KASAN: use-after-free in __lock_acquire+0x2f37/0x4390 kernel/locking/lockdep.c:3224
Read of size 8 at addr ffff8801ca7307d8 by task kswapd0/33

CPU: 0 PID: 33 Comm: kswapd0 Not tainted 4.9.194+ #0
 ffff8801d84274a0 ffffffff81b67001 0000000000000000 ffffea000729cc00
 ffff8801ca7307d8 0000000000000008 ffffffff81210037 ffff8801d84274d8
 ffffffff8150c4f1 0000000000000000 ffff8801ca7307d8 ffff8801ca7307d8
Call Trace:
 [<000000004e3ceb9c>] __dump_stack lib/dump_stack.c:15 [inline]
 [<000000004e3ceb9c>] dump_stack+0xc1/0x120 lib/dump_stack.c:51
 [<00000000c034acea>] print_address_description+0x6f/0x23a mm/kasan/report.c:256
 [<0000000096276734>] kasan_report_error mm/kasan/report.c:355 [inline]
 [<0000000096276734>] kasan_report mm/kasan/report.c:413 [inline]
 [<0000000096276734>] kasan_report.cold+0x8c/0x2ba mm/kasan/report.c:397
 [<00000000a7d377af>] __asan_report_load8_noabort+0x14/0x20 mm/kasan/report.c:434
 [<00000000f230158b>] __lock_acquire+0x2f37/0x4390 kernel/locking/lockdep.c:3224
 [<00000000ff97bff7>] lock_acquire+0x133/0x3d0 kernel/locking/lockdep.c:3756
 [<000000001d0c206d>] __raw_spin_lock include/linux/spinlock_api_smp.h:144 [inline]
 [<000000001d0c206d>] _raw_spin_lock+0x38/0x50 kernel/locking/spinlock.c:151
 [<0000000076c60e9a>] spin_lock include/linux/spinlock.h:302 [inline]
 [<0000000076c60e9a>] task_lock include/linux/sched.h:3217 [inline]
 [<0000000076c60e9a>] get_task_mm+0x20/0xc0 kernel/fork.c:1012
 [<000000000f97dc23>] handle_lmk_event+0x84/0x920 drivers/staging/android/lowmemorykiller.c:109
 [<000000006ea6d043>] lowmem_scan+0x6f3/0xb70 drivers/staging/android/lowmemorykiller.c:354
 [<000000008ef18ef5>] do_shrink_slab mm/vmscan.c:399 [inline]
 [<000000008ef18ef5>] shrink_slab.part.0+0x3cf/0xa20 mm/vmscan.c:502
 [<000000006a4dd0e2>] shrink_slab mm/vmscan.c:466 [inline]
 [<000000006a4dd0e2>] shrink_node+0x1ed/0x750 mm/vmscan.c:2604
 [<000000002a038085>] kswapd_shrink_node mm/vmscan.c:3209 [inline]
 [<000000002a038085>] balance_pgdat mm/vmscan.c:3329 [inline]
 [<000000002a038085>] kswapd+0x7f8/0x13b0 mm/vmscan.c:3523
 [<0000000038f09fc6>] kthread+0x278/0x310 kernel/kthread.c:211
 [<00000000387d1ed6>] ret_from_fork+0x5c/0x70 arch/x86/entry/entry_64.S:375

Allocated by task 8178:
 save_stack_trace+0x16/0x20 arch/x86/kernel/stacktrace.c:57
 save_stack mm/kasan/kasan.c:512 [inline]
 set_track mm/kasan/kasan.c:524 [inline]
 kasan_kmalloc.part.0+0x62/0xf0 mm/kasan/kasan.c:616
 kasan_kmalloc+0xb7/0xd0 mm/kasan/kasan.c:601
 kasan_slab_alloc+0xf/0x20 mm/kasan/kasan.c:554
 slab_post_alloc_hook mm/slab.h:417 [inline]
 slab_alloc_node mm/slub.c:2715 [inline]
 slab_alloc mm/slub.c:2723 [inline]
 kmem_cache_alloc+0xd5/0x2b0 mm/slub.c:2728
 kmem_cache_alloc_node include/linux/slab.h:364 [inline]
 alloc_task_struct_node kernel/fork.c:146 [inline]
 dup_task_struct kernel/fork.c:490 [inline]
 copy_process.part.0+0x1714/0x6690 kernel/fork.c:1640
 copy_process kernel/fork.c:1586 [inline]
 _do_fork+0x1c1/0xd50 kernel/fork.c:2111
 SYSC_clone kernel/fork.c:2223 [inline]
 SyS_clone+0x37/0x50 kernel/fork.c:2217
 do_syscall_64+0x1ad/0x5c0 arch/x86/entry/common.c:288
 entry_SYSCALL_64_after_swapgs+0x5d/0xdb

Freed by task 17:
 save_stack_trace+0x16/0x20 arch/x86/kernel/stacktrace.c:57
 save_stack mm/kasan/kasan.c:512 [inline]
 set_track mm/kasan/kasan.c:524 [inline]
 kasan_slab_free+0xb0/0x190 mm/kasan/kasan.c:589
 slab_free_hook mm/slub.c:1355 [inline]
 slab_free_freelist_hook mm/slub.c:1377 [inline]
 slab_free mm/slub.c:2958 [inline]
 kmem_cache_free+0xbe/0x310 mm/slub.c:2980
 free_task_struct kernel/fork.c:151 [inline]
 free_task+0x74/0xb0 kernel/fork.c:367
 __put_task_struct+0x27c/0x4a0 kernel/fork.c:404
 put_task_struct include/linux/sched.h:2337 [inline]
 delayed_put_task_struct+0x9a/0x2f0 kernel/exit.c:166
 __rcu_reclaim kernel/rcu/rcu.h:118 [inline]
 rcu_do_batch kernel/rcu/tree.c:2797 [inline]
 invoke_rcu_callbacks kernel/rcu/tree.c:3061 [inline]
 __rcu_process_callbacks kernel/rcu/tree.c:3028 [inline]
 rcu_process_callbacks+0x8c2/0x1300 kernel/rcu/tree.c:3045
 __do_softirq+0x22d/0x964 kernel/softirq.c:288

The buggy address belongs to the object at ffff8801ca730000
 which belongs to the cache task_struct of size 5824
The buggy address is located 2008 bytes inside of
 5824-byte region [ffff8801ca730000, ffff8801ca7316c0)
The buggy address belongs to the page:
page:ffffea000729cc00 count:1 mapcount:0 mapping:          (null) index:0x0 compound_mapcount: 0
flags: 0x4000000000010200(slab|head)
page dumped because: kasan: bad access detected

Memory state around the buggy address:
 ffff8801ca730680: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff8801ca730700: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff8801ca730780: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                                                    ^
 ffff8801ca730800: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff8801ca730880: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================

Crashes (2):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2019/11/08 13:31 https://android.googlesource.com/kernel/common android-4.9 7fe05eede1c8 1e35461e .config console log report ci-android-49-kasan-gce-root
2019/11/04 03:59 https://android.googlesource.com/kernel/common android-4.9 7fe05eede1c8 b35fad31 .config console log report ci-android-49-kasan-gce-root
* Struck through repros no longer work on HEAD.