[syzbot] WARNING in static_key_slow_try_dec (2)

11 views
Skip to first unread message

syzbot

unread,
Aug 13, 2021, 1:27:24 PM8/13/21
to ar...@kernel.org, jba...@akamai.com, jpoi...@redhat.com, linux-...@vger.kernel.org, pet...@infradead.org, ros...@goodmis.org, syzkall...@googlegroups.com
Hello,

syzbot found the following issue on:

HEAD commit: da454ebf578f Add linux-next specific files for 20210809
git tree: linux-next
console output: https://syzkaller.appspot.com/x/log.txt?x=10b246f6300000
kernel config: https://syzkaller.appspot.com/x/.config?x=c37951c17eb89b18
dashboard link: https://syzkaller.appspot.com/bug?extid=9fc046ab2b0cf295a063
compiler: gcc (Debian 10.2.1-6) 10.2.1 20210110, GNU ld (GNU Binutils for Debian) 2.35.1
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=128d6d81300000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=169e5431300000

IMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by: syzbot+9fc046...@syzkaller.appspotmail.com

------------[ cut here ]------------
jump label: negative count!
WARNING: CPU: 1 PID: 10689 at kernel/jump_label.c:235 static_key_slow_try_dec+0xca/0xe0 kernel/jump_label.c:235
Modules linked in:
CPU: 1 PID: 10689 Comm: syz-executor251 Not tainted 5.14.0-rc5-next-20210809-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
RIP: 0010:static_key_slow_try_dec+0xca/0xe0 kernel/jump_label.c:235
Code: 5d c3 e8 a9 e7 dc ff 45 31 ed 5b 44 89 e8 5d 41 5c 41 5d c3 44 89 e5 eb 8e e8 92 e7 dc ff 48 c7 c7 c0 ce 94 89 e8 22 f3 52 07 <0f> 0b eb c5 48 89 df e8 ca 8a 22 00 e9 6a ff ff ff 0f 1f 44 00 00
RSP: 0018:ffffc90005b77ac0 EFLAGS: 00010286
RAX: 0000000000000000 RBX: ffffffff8d6d70e0 RCX: 0000000000000000
RDX: ffff88801e923900 RSI: ffffffff815d7628 RDI: fffff52000b6ef4a
RBP: 00000000ffffffff R08: 0000000000000000 R09: 0000000000000000
R10: ffffffff815d13ce R11: 0000000000000000 R12: 00000000ffffffff
R13: 0000000000000001 R14: ffff888077341100 R15: 0000000000000040
FS: 00007f154119d700(0000) GS:ffff8880b9d00000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 0000560538236198 CR3: 000000006fc65000 CR4: 00000000001526e0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
Call Trace:
__static_key_slow_dec_deferred+0x60/0x100 kernel/jump_label.c:286
kvm_free_lapic+0x144/0x1a0 arch/x86/kvm/lapic.c:2211
kvm_arch_vcpu_create+0x890/0xbf0 arch/x86/kvm/x86.c:10737
kvm_vm_ioctl_create_vcpu arch/x86/kvm/../../../virt/kvm/kvm_main.c:3557 [inline]
kvm_vm_ioctl+0x137f/0x23d0 arch/x86/kvm/../../../virt/kvm/kvm_main.c:4279
vfs_ioctl fs/ioctl.c:51 [inline]
__do_sys_ioctl fs/ioctl.c:874 [inline]
__se_sys_ioctl fs/ioctl.c:860 [inline]
__x64_sys_ioctl+0x193/0x200 fs/ioctl.c:860
do_syscall_x64 arch/x86/entry/common.c:50 [inline]
do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80
entry_SYSCALL_64_after_hwframe+0x44/0xae
RIP: 0033:0x44faf9
Code: 28 00 00 00 75 05 48 83 c4 28 c3 e8 c1 18 00 00 90 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 bc ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007f154119d208 EFLAGS: 00000246 ORIG_RAX: 0000000000000010
RAX: ffffffffffffffda RBX: 00000000004ce4d8 RCX: 000000000044faf9
RDX: 0000000000000000 RSI: 000000000000ae41 RDI: 0000000000000004
RBP: 00000000004ce4d0 R08: 00007f154119d700 R09: 0000000000000000
R10: 00007f154119d700 R11: 0000000000000246 R12: 00000000004ce4dc
R13: 00007ffdb527176f R14: 00007f154119d300 R15: 0000000000022000


---
This report is generated by a bot. It may contain errors.
See https://goo.gl/tpsmEJ for more information about syzbot.
syzbot engineers can be reached at syzk...@googlegroups.com.

syzbot will keep track of this issue. See:
https://goo.gl/tpsmEJ#status for how to communicate with syzbot.
syzbot can test patches for this issue, for details see:
https://goo.gl/tpsmEJ#testing-patches

Tetsuo Handa

unread,
Oct 10, 2021, 1:34:52 AM10/10/21
to Sean Christopherson, Reiji Watanabe, Paolo Bonzini, syzkall...@googlegroups.com, linux-...@vger.kernel.org, syzbot
Hello.

Commit 4547700a4d190ac4 ("KVM: x86: Consolidate APIC base RESET initialization code")
changed the location to set MSR_IA32_APICBASE_ENABLE flag. And syzbot is reporting
underflow bug due to too late initialization of vcpu->arch.apic_base member. We need to
make sure that vcpu->arch.apic_base is initialized before kvm_free_lapic() is called.

kvm_vm_ioctl() {
kvm_vm_ioctl_create_vcpu() {
kvm_arch_vcpu_create() {
if (something_went_wrong)
goto fail_free_lapic;
/* vcpu->arch.apic_base is initialized when something_went_wrong is false. */
kvm_vcpu_reset() {
kvm_lapic_reset(struct kvm_vcpu *vcpu, bool init_event) {
vcpu->arch.apic_base = APIC_DEFAULT_PHYS_BASE | MSR_IA32_APICBASE_ENABLE;
}
}
return 0;
fail_free_lapic:
kvm_free_lapic() {
/* vcpu->arch.apic_base is not yet initialized when something_went_wrong is true. */
if (!(vcpu->arch.apic_base & MSR_IA32_APICBASE_ENABLE))
static_branch_slow_dec_deferred(&apic_hw_disabled); // <= underflow bug.
}
return r;
}
}
}

Sean Christopherson

unread,
Oct 12, 2021, 11:30:40 AM10/12/21
to Tetsuo Handa, Reiji Watanabe, Paolo Bonzini, syzkall...@googlegroups.com, linux-...@vger.kernel.org, syzbot
On Sun, Oct 10, 2021, Tetsuo Handa wrote:
> Hello.
>
> Commit 4547700a4d190ac4 ("KVM: x86: Consolidate APIC base RESET initialization code")

That's definitely where the error was made visible, but commit 421221234ada ("KVM:
x86: Open code necessary bits of kvm_lapic_set_base() at vCPU RESET") is the real
culprit. I'll send a patch later today. I'm leaning toward a partial revert with
some extra comments.

Thanks for the debug! I was having trouble reproducing the syzbot report.

Sean Christopherson

unread,
Oct 12, 2021, 12:37:34 PM10/12/21
to Tetsuo Handa, Reiji Watanabe, Paolo Bonzini, syzkall...@googlegroups.com, linux-...@vger.kernel.org, syzbot
On Tue, Oct 12, 2021, Sean Christopherson wrote:
> On Sun, Oct 10, 2021, Tetsuo Handa wrote:
> > Hello.
> >
> > Commit 4547700a4d190ac4 ("KVM: x86: Consolidate APIC base RESET initialization code")
>
> That's definitely where the error was made visible,

I take that back, the bug was likely visible even before the redundant vendor code
was dropped. Doesn't change the fix in any way though.
Reply all
Reply to author
Forward
0 new messages