syzbot


general protection fault in __schedule

Status: closed as dup on 2017/12/21 00:34
Subsystems: mm
[Documentation on labels]
Reported-by: syzbot+df206d897b7957e7c7a8c34e18c39a24d5256877@syzkaller.appspotmail.com
First crash: 2530d, last: 2529d
Duplicate of
Title Repro Cause bisect Fix bisect Count Last Reported
KASAN: use-after-free Read in __schedule kvm C 145 2529d 2530d
Similar bugs (1)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
upstream general protection fault in __schedule (2) kernel C done done 1712 2253d 2297d 0/28 closed as dup on 2019/11/22 20:54

Sample crash report:
kasan: CONFIG_KASAN_INLINE enabled
kasan: GPF could be caused by NULL-ptr deref or user memory access
general protection fault: 0000 [#1] SMP KASAN
Dumping ftrace buffer:
   (ftrace buffer empty)
Modules linked in:
CPU: 0 PID: 10593 Comm: syzkaller307550 Not tainted 4.15.0-rc4-mm1+ #47
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
RIP: 0010:__fire_sched_out_preempt_notifiers kernel/sched/core.c:2550 [inline]
RIP: 0010:fire_sched_out_preempt_notifiers kernel/sched/core.c:2558 [inline]
RIP: 0010:prepare_task_switch kernel/sched/core.c:2594 [inline]
RIP: 0010:context_switch kernel/sched/core.c:2765 [inline]
RIP: 0010:__schedule+0xdf0/0x2060 kernel/sched/core.c:3376
RSP: 0018:ffff8801d0f3f478 EFLAGS: 00010806
RAX: 1bd5a00000000022 RBX: ffff8801db22c900 RCX: ffffffff810caeaf
RDX: 0000000000000000 RSI: 0000000000000000 RDI: dead000000000110
RBP: ffff8801d0f3f648 R08: 0000000000000000 R09: 1ffff1003a1e7e63
R10: ffff8801d0f3f2e0 R11: 0000000000000002 R12: ffff8801d9f40200
R13: dead000000000100 R14: dffffc0000000000 R15: ffff8801d0430040
FS:  00007fdcd52b2700(0000) GS:ffff8801db200000(0000) knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00007fdde2cd8e78 CR3: 00000001cab1f001 CR4: 00000000001626f0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
Call Trace:
 preempt_schedule_common+0x22/0x60 kernel/sched/core.c:3515
 _cond_resched+0x1d/0x30 kernel/sched/core.c:4852
 zap_pmd_range mm/memory.c:1443 [inline]
 zap_pud_range mm/memory.c:1470 [inline]
 zap_p4d_range mm/memory.c:1491 [inline]
 unmap_page_range+0x872/0x22e0 mm/memory.c:1512
 unmap_single_vma+0x15f/0x2d0 mm/memory.c:1557
 zap_page_range+0x35c/0x5f0 mm/memory.c:1611
 madvise_dontneed_single_vma mm/madvise.c:510 [inline]
 madvise_dontneed_free mm/madvise.c:563 [inline]
 madvise_vma mm/madvise.c:688 [inline]
 SYSC_madvise mm/madvise.c:863 [inline]
 SyS_madvise+0xf9e/0x13d0 mm/madvise.c:791
 entry_SYSCALL_64_fastpath+0x1f/0x96
RIP: 0033:0x448fc7
RSP: 002b:00007fdcd52b1dd8 EFLAGS: 00000206 ORIG_RAX: 000000000000001c
RAX: ffffffffffffffda RBX: 000000002012d800 RCX: 0000000000448fc7
RDX: 0000000000000004 RSI: 00000000007fb000 RDI: 00007fdcd4ab2000
RBP: 000000002012d800 R08: 0000000000000012 R09: 0000000000000000
R10: 00008c0000500000 R11: 0000000000000206 R12: 00007fdcd52b06c0
R13: 00000000ffffffff R14: ffffffffffffffff R15: 000000002012a000
Code: 08 4c 89 e8 48 c1 e8 03 42 80 3c 30 00 0f 85 ce 0f 00 00 4d 8b 6d 00 4d 85 ed 0f 84 72 f9 ff ff 49 8d 7d 10 48 89 f8 48 c1 e8 03 <42> 80 3c 30 00 74 ac eb a5 49 8d bc 24 28 04 00 00 48 b8 00 00 
RIP: __fire_sched_out_preempt_notifiers kernel/sched/core.c:2550 [inline] RSP: ffff8801d0f3f478
RIP: fire_sched_out_preempt_notifiers kernel/sched/core.c:2558 [inline] RSP: ffff8801d0f3f478
RIP: prepare_task_switch kernel/sched/core.c:2594 [inline] RSP: ffff8801d0f3f478
RIP: context_switch kernel/sched/core.c:2765 [inline] RSP: ffff8801d0f3f478
RIP: __schedule+0xdf0/0x2060 kernel/sched/core.c:3376 RSP: ffff8801d0f3f478

======================================================
WARNING: possible circular locking dependency detected
4.15.0-rc4-mm1+ #47 Not tainted
------------------------------------------------------
syzkaller307550/10593 is trying to acquire lock:
 ((console_sem).lock){..-.}, at: [<00000000f34c3e08>] down_trylock+0x13/0x70 kernel/locking/semaphore.c:136

but task is already holding lock:
 (&rq->lock){-.-.}, at: [<00000000b265f4bc>] rq_lock kernel/sched/sched.h:1766 [inline]
 (&rq->lock){-.-.}, at: [<00000000b265f4bc>] __schedule+0x24e/0x2060 kernel/sched/core.c:3313

which lock already depends on the new lock.


the existing dependency chain (in reverse order) is:

-> #2 (&rq->lock){-.-.}:
       __raw_spin_lock include/linux/spinlock_api_smp.h:142 [inline]
       _raw_spin_lock+0x2a/0x40 kernel/locking/spinlock.c:144
       rq_lock kernel/sched/sched.h:1766 [inline]
       task_fork_fair+0x7a/0x690 kernel/sched/fair.c:9448
       sched_fork+0x435/0xc00 kernel/sched/core.c:2405
       copy_process.part.37+0x1758/0x4b60 kernel/fork.c:1776
       copy_process kernel/fork.c:1619 [inline]
       _do_fork+0x1f7/0xf70 kernel/fork.c:2100
       kernel_thread+0x34/0x40 kernel/fork.c:2159
       rest_init+0x22/0xf0 init/main.c:402
       start_kernel+0x7f1/0x819 init/main.c:716
       x86_64_start_reservations+0x2a/0x2c arch/x86/kernel/head64.c:378
       x86_64_start_kernel+0x77/0x7a arch/x86/kernel/head64.c:359
       secondary_startup_64+0xa5/0xb0 arch/x86/kernel/head_64.S:237

-> #1 (&p->pi_lock){-.-.}:
       __raw_spin_lock_irqsave include/linux/spinlock_api_smp.h:110 [inline]
       _raw_spin_lock_irqsave+0x96/0xc0 kernel/locking/spinlock.c:152
       try_to_wake_up+0xbc/0x1600 kernel/sched/core.c:1989
       wake_up_process+0x10/0x20 kernel/sched/core.c:2152
       __up.isra.0+0x1cc/0x2c0 kernel/locking/semaphore.c:262
       up+0x13b/0x1d0 kernel/locking/semaphore.c:187
       __up_console_sem+0xb2/0x1a0 kernel/printk/printk.c:245
       console_unlock+0x538/0xd70 kernel/printk/printk.c:2248
       do_con_write+0x106e/0x1f70 drivers/tty/vt/vt.c:2433
       con_write+0x25/0xb0 drivers/tty/vt/vt.c:2782
       process_output_block drivers/tty/n_tty.c:579 [inline]
       n_tty_write+0x5ef/0xec0 drivers/tty/n_tty.c:2302
       do_tty_write drivers/tty/tty_io.c:949 [inline]
       tty_write+0x3fa/0x840 drivers/tty/tty_io.c:1033
       __vfs_write+0xef/0x970 fs/read_write.c:480
       vfs_write+0x189/0x510 fs/read_write.c:544
       SYSC_write fs/read_write.c:589 [inline]
       SyS_write+0xef/0x220 fs/read_write.c:581
       entry_SYSCALL_64_fastpath+0x1f/0x96

-> #0 ((console_sem).lock){..-.}:
       lock_acquire+0x1d5/0x580 kernel/locking/lockdep.c:3914
       __raw_spin_lock_irqsave include/linux/spinlock_api_smp.h:110 [inline]
       _raw_spin_lock_irqsave+0x96/0xc0 kernel/locking/spinlock.c:152
       down_trylock+0x13/0x70 kernel/locking/semaphore.c:136
       __down_trylock_console_sem+0xa2/0x1e0 kernel/printk/printk.c:228
       console_trylock+0x15/0x100 kernel/printk/printk.c:2065
       vprintk_emit+0x49b/0x590 kernel/printk/printk.c:1756
       vprintk_default+0x28/0x30 kernel/printk/printk.c:1796
       vprintk_func+0x57/0xc0 kernel/printk/printk_safe.c:379
       printk+0xaa/0xca kernel/printk/printk.c:1829
       kasan_die_handler+0x31/0x3f arch/x86/mm/kasan_init_64.c:242
       notifier_call_chain+0x136/0x2c0 kernel/notifier.c:93
       __atomic_notifier_call_chain kernel/notifier.c:183 [inline]
       atomic_notifier_call_chain+0x77/0x140 kernel/notifier.c:193
       notify_die+0x18c/0x280 kernel/notifier.c:549
       do_general_protection+0x331/0x3e0 arch/x86/kernel/traps.c:557
       general_protection+0x2c/0x60 arch/x86/entry/entry_64.S:1242
       __fire_sched_out_preempt_notifiers kernel/sched/core.c:2550 [inline]
       fire_sched_out_preempt_notifiers kernel/sched/core.c:2558 [inline]
       prepare_task_switch kernel/sched/core.c:2594 [inline]
       context_switch kernel/sched/core.c:2765 [inline]
       __schedule+0xdf0/0x2060 kernel/sched/core.c:3376
       preempt_schedule_common+0x22/0x60 kernel/sched/core.c:3515
       _cond_resched+0x1d/0x30 kernel/sched/core.c:4852
       zap_pmd_range mm/memory.c:1443 [inline]
       zap_pud_range mm/memory.c:1470 [inline]
       zap_p4d_range mm/memory.c:1491 [inline]
       unmap_page_range+0x872/0x22e0 mm/memory.c:1512
       unmap_single_vma+0x15f/0x2d0 mm/memory.c:1557
       zap_page_range+0x35c/0x5f0 mm/memory.c:1611
       madvise_dontneed_single_vma mm/madvise.c:510 [inline]
       madvise_dontneed_free mm/madvise.c:563 [inline]
       madvise_vma mm/madvise.c:688 [inline]
       SYSC_madvise mm/madvise.c:863 [inline]
       SyS_madvise+0xf9e/0x13d0 mm/madvise.c:791
       entry_SYSCALL_64_fastpath+0x1f/0x96

other info that might help us debug this:

Chain exists of:
  (console_sem).lock --> &p->pi_lock --> &rq->lock

 Possible unsafe locking scenario:

       CPU0                    CPU1
       ----                    ----
  lock(&rq->lock);
                               lock(&p->pi_lock);
                               lock(&rq->lock);
  lock((console_sem).lock);

 *** DEADLOCK ***

3 locks held by syzkaller307550/10593:
 #0:  (&mm->mmap_sem){++++}, at: [<00000000d78784d1>] SYSC_madvise mm/madvise.c:830 [inline]
 #0:  (&mm->mmap_sem){++++}, at: [<00000000d78784d1>] SyS_madvise+0x1021/0x13d0 mm/madvise.c:791
 #1:  (&rq->lock){-.-.}, at: [<00000000b265f4bc>] rq_lock kernel/sched/sched.h:1766 [inline]
 #1:  (&rq->lock){-.-.}, at: [<00000000b265f4bc>] __schedule+0x24e/0x2060 kernel/sched/core.c:3313
 #2:  (rcu_read_lock){....}, at: [<00000000f41df1f6>] rcu_read_unlock include/linux/rcupdate.h:682 [inline]
 #2:  (rcu_read_lock){....}, at: [<00000000f41df1f6>] atomic_notifier_call_chain+0x0/0x140 kernel/notifier.c:184

stack backtrace:
CPU: 0 PID: 10593 Comm: syzkaller307550 Not tainted 4.15.0-rc4-mm1+ #47
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_circular_bug.isra.37+0x2cd/0x2dc kernel/locking/lockdep.c:1218
 check_prev_add kernel/locking/lockdep.c:1858 [inline]
 check_prevs_add kernel/locking/lockdep.c:1971 [inline]
 validate_chain kernel/locking/lockdep.c:2412 [inline]
 __lock_acquire+0x30a8/0x3e00 kernel/locking/lockdep.c:3426
 lock_acquire+0x1d5/0x580 kernel/locking/lockdep.c:3914
 __raw_spin_lock_irqsave include/linux/spinlock_api_smp.h:110 [inline]
 _raw_spin_lock_irqsave+0x96/0xc0 kernel/locking/spinlock.c:152
 down_trylock+0x13/0x70 kernel/locking/semaphore.c:136
 __down_trylock_console_sem+0xa2/0x1e0 kernel/printk/printk.c:228
 console_trylock+0x15/0x100 kernel/printk/printk.c:2065
 vprintk_emit+0x49b/0x590 kernel/printk/printk.c:1756
 vprintk_default+0x28/0x30 kernel/printk/printk.c:1796
 vprintk_func+0x57/0xc0 kernel/printk/printk_safe.c:379
 printk+0xaa/0xca kernel/printk/printk.c:1829
 kasan_die_handler+0x31/0x3f arch/x86/mm/kasan_init_64.c:242
 notifier_call_chain+0x136/0x2c0 kernel/notifier.c:93
 __atomic_notifier_call_chain kernel/notifier.c:183 [inline]
 atomic_notifier_call_chain+0x77/0x140 kernel/notifier.c:193
 notify_die+0x18c/0x280 kernel/notifier.c:549
 do_general_protection+0x331/0x3e0 arch/x86/kernel/traps.c:557
 general_protection+0x2c/0x60 arch/x86/entry/entry_64.S:1242
RIP: 0010:__fire_sched_out_preempt_notifiers kernel/sched/core.c:2550 [inline]
RIP: 0010:fire_sched_out_preempt_notifiers kernel/sched/core.c:2558 [inline]
RIP: 0010:prepare_task_switch kernel/sched/core.c:2594 [inline]
RIP: 0010:context_switch kernel/sched/core.c:2765 [inline]
RIP: 0010:__schedule+0xdf0/0x2060 kernel/sched/core.c:3376
RSP: 0018:ffff8801d0f3f478 EFLAGS: 00010806
RAX: 1bd5a00000000022 RBX: ffff8801db22c900 RCX: ffffffff810caeaf
RDX: 0000000000000000 RSI: 0000000000000000 RDI: dead000000000110
RBP: ffff8801d0f3f648 R08: 0000000000000000 R09: 1ffff1003a1e7e63
R10: ffff8801d0f3f2e0 R11: 0000000000000002 R12: ffff8801d9f40200
R13: dead000000000100 R14: dffffc0000000000 R15: ffff8801d0430040
 preempt_schedule_common+0x22/0x60 kernel/sched/core.c:3515
 _cond_resched+0x1d/0x30 kernel/sched/core.c:4852
 zap_pmd_range mm/memory.c:1443 [inline]
 zap_pud_range mm/memory.c:1470 [inline]
 zap_p4d_range mm/memory.c:1491 [inline]
 unmap_page_range+0x872/0x22e0 mm/memory.c:1512
 unmap_single_vma+0x15f/0x2d0 mm/memory.c:1557
 zap_page_range+0x35c/0x5f0 mm/memory.c:1611
 madvise_dontneed_single_vma mm/madvise.c:510 [inline]
 madvise_dontneed_free mm/madvise.c:563 [inline]
 madvise_vma mm/madvise.c:688 [inline]
 SYSC_madvise mm/madvise.c:863 [inline]
 SyS_madvise+0xf9e/0x13d0 mm/madvise.c:791
 entry_SYSCALL_64_fastpath+0x1f/0x96
RIP: 0033:0x448fc7
RSP: 002b:00007fdcd52b1dd8 EFLAGS: 00000206 ORIG_RAX: 000000000000001c
RAX: ffffffffffffffda RBX: 000000002012d800 RCX: 0000000000448fc7
RDX: 0000000000000004 RSI: 00000000007fb000 RDI: 00007fdcd4ab2000
RBP: 000000002012d800 R08: 0000000000000012 R09: 0000000000000000
R10: 00008c0000500000 R11: 0000000000000206 R12: 00007fdcd52b06c0
R13: 00000000ffffffff R14: ffffffffffffffff R15: 000000002012a000
---[ end trace 0c4261f7190de16d ]---

Crashes (722):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2017/12/21 09:49 mmots 75aa5540627f eaadba98 .config console log report syz C ci-upstream-mmots-kasan-gce
2017/12/20 21:25 linux-next 7dc9f647127d 90a46995 .config console log report syz C ci-upstream-next-kasan-gce
2017/12/20 15:57 linux-next 7dc9f647127d 90a46995 .config console log report syz C ci-upstream-next-kasan-gce
2017/12/22 01:08 mmots 75aa5540627f 81fe66b4 .config console log report ci-upstream-mmots-kasan-gce
2017/12/22 01:08 mmots 75aa5540627f 81fe66b4 .config console log report ci-upstream-mmots-kasan-gce
2017/12/22 01:06 mmots 75aa5540627f 81fe66b4 .config console log report ci-upstream-mmots-kasan-gce
2017/12/22 01:06 mmots 75aa5540627f 81fe66b4 .config console log report ci-upstream-mmots-kasan-gce
2017/12/22 01:04 mmots 75aa5540627f 81fe66b4 .config console log report ci-upstream-mmots-kasan-gce
2017/12/22 01:01 mmots 75aa5540627f 81fe66b4 .config console log report ci-upstream-mmots-kasan-gce
2017/12/22 00:57 mmots 75aa5540627f 81fe66b4 .config console log report ci-upstream-mmots-kasan-gce
2017/12/22 00:51 mmots 75aa5540627f 81fe66b4 .config console log report ci-upstream-mmots-kasan-gce
2017/12/22 00:50 mmots 75aa5540627f 81fe66b4 .config console log report ci-upstream-mmots-kasan-gce
2017/12/22 00:48 mmots 75aa5540627f 81fe66b4 .config console log report ci-upstream-mmots-kasan-gce
2017/12/22 00:45 mmots 75aa5540627f 81fe66b4 .config console log report ci-upstream-mmots-kasan-gce
2017/12/22 00:34 mmots 75aa5540627f 81fe66b4 .config console log report ci-upstream-mmots-kasan-gce
2017/12/22 00:31 mmots 75aa5540627f 81fe66b4 .config console log report ci-upstream-mmots-kasan-gce
2017/12/22 00:31 mmots 75aa5540627f 81fe66b4 .config console log report ci-upstream-mmots-kasan-gce
2017/12/22 00:29 mmots 75aa5540627f 81fe66b4 .config console log report ci-upstream-mmots-kasan-gce
2017/12/22 00:26 mmots 75aa5540627f 81fe66b4 .config console log report ci-upstream-mmots-kasan-gce
2017/12/22 00:22 mmots 75aa5540627f 81fe66b4 .config console log report ci-upstream-mmots-kasan-gce
2017/12/22 00:14 mmots 75aa5540627f 81fe66b4 .config console log report ci-upstream-mmots-kasan-gce
2017/12/22 00:10 mmots 75aa5540627f 81fe66b4 .config console log report ci-upstream-mmots-kasan-gce
2017/12/22 00:05 mmots 75aa5540627f 81fe66b4 .config console log report ci-upstream-mmots-kasan-gce
2017/12/22 00:04 mmots 75aa5540627f 81fe66b4 .config console log report ci-upstream-mmots-kasan-gce
2017/12/22 00:02 mmots 75aa5540627f 81fe66b4 .config console log report ci-upstream-mmots-kasan-gce
2017/12/22 00:00 mmots 75aa5540627f 81fe66b4 .config console log report ci-upstream-mmots-kasan-gce
2017/12/21 23:56 mmots 75aa5540627f 81fe66b4 .config console log report ci-upstream-mmots-kasan-gce
2017/12/21 23:55 mmots 75aa5540627f 81fe66b4 .config console log report ci-upstream-mmots-kasan-gce
2017/12/21 23:54 mmots 75aa5540627f 81fe66b4 .config console log report ci-upstream-mmots-kasan-gce
2017/12/21 23:53 mmots 75aa5540627f 81fe66b4 .config console log report ci-upstream-mmots-kasan-gce
2017/12/21 23:50 mmots 75aa5540627f 81fe66b4 .config console log report ci-upstream-mmots-kasan-gce
2017/12/21 23:48 mmots 75aa5540627f 81fe66b4 .config console log report ci-upstream-mmots-kasan-gce
2017/12/21 23:44 mmots 75aa5540627f 81fe66b4 .config console log report ci-upstream-mmots-kasan-gce
2017/12/21 23:42 mmots 75aa5540627f 81fe66b4 .config console log report ci-upstream-mmots-kasan-gce
2017/12/21 23:42 mmots 75aa5540627f 81fe66b4 .config console log report ci-upstream-mmots-kasan-gce
2017/12/21 23:39 mmots 75aa5540627f 81fe66b4 .config console log report ci-upstream-mmots-kasan-gce
2017/12/21 23:33 mmots 75aa5540627f 81fe66b4 .config console log report ci-upstream-mmots-kasan-gce
2017/12/21 23:32 mmots 75aa5540627f 81fe66b4 .config console log report ci-upstream-mmots-kasan-gce
2017/12/21 23:28 mmots 75aa5540627f 81fe66b4 .config console log report ci-upstream-mmots-kasan-gce
2017/12/21 23:27 mmots 75aa5540627f 81fe66b4 .config console log report ci-upstream-mmots-kasan-gce
2017/12/21 23:26 mmots 75aa5540627f 81fe66b4 .config console log report ci-upstream-mmots-kasan-gce
2017/12/21 23:23 mmots 75aa5540627f 81fe66b4 .config console log report ci-upstream-mmots-kasan-gce
2017/12/21 23:21 mmots 75aa5540627f 81fe66b4 .config console log report ci-upstream-mmots-kasan-gce
* Struck through repros no longer work on HEAD.