syzbot


KASAN: use-after-free Read in remove_wait_queue

Status: fixed on 2018/02/26 20:04
Subsystems: fs
[Documentation on labels]
Reported-by: syzbot+a2a3c4909716e271487e@syzkaller.appspotmail.com
Fix commit: 5eeb2ca02a2f ANDROID: binder: synchronize_rcu() when using POLLFREE.
First crash: 2212d, last: 2199d
Duplicate bugs (1)
duplicates (1):
Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
KASAN: use-after-free Read in do_raw_spin_unlock (2) fs C 1 2211d 2208d 0/26 closed as dup on 2018/02/12 15:57
Discussions (6)
Title Replies (including bot) Last reply
[PATCH 4.9 00/47] 4.9.196-stable review 61 (61) 2019/12/12 17:32
[PATCH 4.4 00/36] 4.4.196-stable review 49 (49) 2019/10/08 05:14
[PATCH 4.15 00/45] 4.15.6-stable review 53 (53) 2018/02/25 09:59
[PATCH 4.14 000/159] 4.14.22-stable review 164 (164) 2018/02/24 17:57
[PATCH] ANDROID: binder: synchronize_rcu() when using POLLFREE. 2 (2) 2018/02/16 08:49
KASAN: use-after-free Read in remove_wait_queue 5 (6) 2018/02/13 07:42
Similar bugs (5)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
upstream KASAN: use-after-free Read in remove_wait_queue (3) kernfs C inconclusive 123 410d 836d 22/26 fixed on 2023/02/24 13:50
linux-4.14 KASAN: use-after-free Read in remove_wait_queue (2) C error 7 728d 1424d 0/1 upstream: reported C repro on 2020/04/07 06:03
upstream KASAN: use-after-free Read in remove_wait_queue (2) fs C 4 2182d 2192d 5/26 fixed on 2018/06/07 13:52
android-49 KASAN: use-after-free Read in remove_wait_queue C 6 2199d 2209d 2/3 fixed on 2018/03/05 12:02
linux-4.14 KASAN: use-after-free Read in remove_wait_queue 1 1648d 1648d 0/1 auto-closed as invalid on 2019/12/24 15:10

Sample crash report:
audit: type=1400 audit(1519272433.225:7): avc:  denied  { map } for  pid=4176 comm="syzkaller526503" path="/root/syzkaller526503939" dev="sda1" ino=16481 scontext=unconfined_u:system_r:insmod_t:s0-s0:c0.c1023 tcontext=unconfined_u:object_r:user_home_t:s0 tclass=file permissive=1
==================================================================
BUG: KASAN: use-after-free in __lock_acquire+0x3d4d/0x3e00 kernel/locking/lockdep.c:3310
Read of size 8 at addr ffff8801adc976c0 by task syzkaller526503/4176

CPU: 1 PID: 4176 Comm: syzkaller526503 Not tainted 4.16.0-rc2+ #323
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
Call Trace:
 __dump_stack lib/dump_stack.c:17 [inline]
 dump_stack+0x194/0x257 lib/dump_stack.c:53
 print_address_description+0x73/0x250 mm/kasan/report.c:256
 kasan_report_error mm/kasan/report.c:354 [inline]
 kasan_report+0x23b/0x360 mm/kasan/report.c:412
 __asan_report_load8_noabort+0x14/0x20 mm/kasan/report.c:433
 __lock_acquire+0x3d4d/0x3e00 kernel/locking/lockdep.c:3310
 lock_acquire+0x1d5/0x580 kernel/locking/lockdep.c:3920
 __raw_spin_lock_irqsave include/linux/spinlock_api_smp.h:110 [inline]
 _raw_spin_lock_irqsave+0x96/0xc0 kernel/locking/spinlock.c:152
 remove_wait_queue+0x81/0x350 kernel/sched/wait.c:50
 ep_remove_wait_queue fs/eventpoll.c:596 [inline]
 ep_unregister_pollwait.isra.7+0x18c/0x590 fs/eventpoll.c:614
 ep_free+0x13f/0x320 fs/eventpoll.c:832
 ep_eventpoll_release+0x44/0x60 fs/eventpoll.c:864
 __fput+0x327/0x7e0 fs/file_table.c:209
 ____fput+0x15/0x20 fs/file_table.c:243
 task_work_run+0x199/0x270 kernel/task_work.c:113
 exit_task_work include/linux/task_work.h:22 [inline]
 do_exit+0x9bb/0x1ad0 kernel/exit.c:865
 do_group_exit+0x149/0x400 kernel/exit.c:968
 SYSC_exit_group kernel/exit.c:979 [inline]
 SyS_exit_group+0x1d/0x20 kernel/exit.c:977
 do_syscall_64+0x280/0x940 arch/x86/entry/common.c:287
 entry_SYSCALL_64_after_hwframe+0x42/0xb7
RIP: 0033:0x43e958
RSP: 002b:00007ffe8dfef598 EFLAGS: 00000246 ORIG_RAX: 00000000000000e7
RAX: ffffffffffffffda RBX: 0000000000000000 RCX: 000000000043e958
RDX: 0000000000000000 RSI: 000000000000003c RDI: 0000000000000000
RBP: 00000000004be300 R08: 00000000000000e7 R09: ffffffffffffffd0
R10: 00000000004002c8 R11: 0000000000000246 R12: 0000000000000001
R13: 00000000006cc160 R14: 0000000000000000 R15: 0000000000000000

Allocated by task 4176:
 save_stack+0x43/0xd0 mm/kasan/kasan.c:447
 set_track mm/kasan/kasan.c:459 [inline]
 kasan_kmalloc+0xad/0xe0 mm/kasan/kasan.c:552
 __do_kmalloc_node mm/slab.c:3669 [inline]
 __kmalloc_node+0x47/0x70 mm/slab.c:3676
 kmalloc_node include/linux/slab.h:554 [inline]
 kvmalloc_node+0x99/0xd0 mm/util.c:419
 kvmalloc include/linux/mm.h:541 [inline]
 kvzalloc include/linux/mm.h:549 [inline]
 alloc_netdev_mqs+0x16d/0xfb0 net/core/dev.c:8299
 ppp_create_interface drivers/net/ppp/ppp_generic.c:3018 [inline]
 ppp_unattached_ioctl drivers/net/ppp/ppp_generic.c:866 [inline]
 ppp_ioctl+0x1715/0x2a50 drivers/net/ppp/ppp_generic.c:602
 vfs_ioctl fs/ioctl.c:46 [inline]
 do_vfs_ioctl+0x1b1/0x1520 fs/ioctl.c:686
 SYSC_ioctl fs/ioctl.c:701 [inline]
 SyS_ioctl+0x8f/0xc0 fs/ioctl.c:692
 do_syscall_64+0x280/0x940 arch/x86/entry/common.c:287
 entry_SYSCALL_64_after_hwframe+0x42/0xb7

Freed by task 4176:
 save_stack+0x43/0xd0 mm/kasan/kasan.c:447
 set_track mm/kasan/kasan.c:459 [inline]
 __kasan_slab_free+0x11a/0x170 mm/kasan/kasan.c:520
 kasan_slab_free+0xe/0x10 mm/kasan/kasan.c:527
 __cache_free mm/slab.c:3485 [inline]
 kfree+0xd9/0x260 mm/slab.c:3800
 kvfree+0x36/0x60 mm/util.c:438
 netdev_freemem+0x4c/0x60 net/core/dev.c:8253
 netdev_release+0x10a/0x160 net/core/net-sysfs.c:1502
 device_release+0x7c/0x210 drivers/base/core.c:814
 kobject_cleanup lib/kobject.c:646 [inline]
 kobject_release lib/kobject.c:675 [inline]
 kref_put include/linux/kref.h:70 [inline]
 kobject_put+0x14c/0x250 lib/kobject.c:692
 put_device+0x20/0x30 drivers/base/core.c:1931
 free_netdev+0x2f5/0x400 net/core/dev.c:8410
 ppp_destroy_interface+0x2bc/0x390 drivers/net/ppp/ppp_generic.c:3100
 ppp_release+0x12b/0x1a0 drivers/net/ppp/ppp_generic.c:415
 ppp_ioctl+0x3b1/0x2a50 drivers/net/ppp/ppp_generic.c:628
 vfs_ioctl fs/ioctl.c:46 [inline]
 do_vfs_ioctl+0x1b1/0x1520 fs/ioctl.c:686
 SYSC_ioctl fs/ioctl.c:701 [inline]
 SyS_ioctl+0x8f/0xc0 fs/ioctl.c:692
 do_syscall_64+0x280/0x940 arch/x86/entry/common.c:287
 entry_SYSCALL_64_after_hwframe+0x42/0xb7

The buggy address belongs to the object at ffff8801adc96b40
 which belongs to the cache kmalloc-4096 of size 4096
The buggy address is located 2944 bytes inside of
 4096-byte region [ffff8801adc96b40, ffff8801adc97b40)
The buggy address belongs to the page:
page:ffffea0006b72580 count:1 mapcount:0 mapping:ffff8801adc96b40 index:0x0 compound_mapcount: 0
flags: 0x2fffc0000008100(slab|head)
raw: 02fffc0000008100 ffff8801adc96b40 0000000000000000 0000000100000001
raw: ffffea0006cee820 ffffea0006c71ea0 ffff8801db000dc0 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
 ffff8801adc97580: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff8801adc97600: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff8801adc97680: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                                           ^
 ffff8801adc97700: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff8801adc97780: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================

Crashes (7):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2018/02/22 04:09 upstream af3e79d29555 04cbdbd1 .config console log report syz C ci-upstream-kasan-gce
2018/02/22 09:30 upstream af3e79d29555 04cbdbd1 .config console log report syz C ci-upstream-kasan-gce-386
2018/02/22 07:08 upstream af3e79d29555 04cbdbd1 .config console log report syz C ci-upstream-kasan-gce-386
2018/02/09 15:14 upstream f1517df8701c 9fb5ec43 .config console log report syz C ci-upstream-kasan-gce-386
2018/02/09 11:21 upstream f1517df8701c 9fb5ec43 .config console log report ci-upstream-kasan-gce
2018/02/16 23:47 upstream 1a2a7d3ee659 c8b3f7c1 .config console log report ci-upstream-kasan-gce-386
2018/02/11 19:49 upstream d48fcbd864a0 4e9b726d .config console log report ci-upstream-kasan-gce-386
* Struck through repros no longer work on HEAD.