lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Mon, 4 Nov 2019 20:16:58 +0800
From:   Wanpeng Li <kernellwp@...il.com>
To:     Paolo Bonzini <pbonzini@...hat.com>
Cc:     LKML <linux-kernel@...r.kernel.org>, kvm <kvm@...r.kernel.org>,
        Radim Krčmář <rkrcmar@...hat.com>,
        Sean Christopherson <sean.j.christopherson@...el.com>,
        Vitaly Kuznetsov <vkuznets@...hat.com>,
        Wanpeng Li <wanpengli@...cent.com>,
        Jim Mattson <jmattson@...gle.com>,
        Joerg Roedel <joro@...tes.org>
Subject: Re: [PATCH 2/2] KVM: Fix rcu splat if vm creation fails

On Mon, 4 Nov 2019 at 19:18, Paolo Bonzini <pbonzini@...hat.com> wrote:
>
> On 04/11/19 07:27, Wanpeng Li wrote:
> > From: Wanpeng Li <wanpengli@...cent.com>
> >
> > Reported by syzkaller:
> >
> >    =============================
> >    WARNING: suspicious RCU usage
> >    -----------------------------
> >    ./include/linux/kvm_host.h:536 suspicious rcu_dereference_check() usage!
> >
> >    other info that might help us debug this:
> >
> >    rcu_scheduler_active = 2, debug_locks = 1
> >    no locks held by repro_11/12688.
> >
> >    stack backtrace:
> >    Call Trace:
> >     dump_stack+0x7d/0xc5
> >     lockdep_rcu_suspicious+0x123/0x170
> >     kvm_dev_ioctl+0x9a9/0x1260 [kvm]
> >     do_vfs_ioctl+0x1a1/0xfb0
> >     ksys_ioctl+0x6d/0x80
> >     __x64_sys_ioctl+0x73/0xb0
> >     do_syscall_64+0x108/0xaa0
> >     entry_SYSCALL_64_after_hwframe+0x49/0xbe
> >
> > Commit a97b0e773e4 (kvm: call kvm_arch_destroy_vm if vm creation fails)
> > sets users_count to 1 before kvm_arch_init_vm(), however, if kvm_arch_init_vm()
> > fails, we need to dec this count. Or, we can move the sets refcount after
> > kvm_arch_init_vm().
>
> I don't understand this one, hasn't
>
>         WARN_ON_ONCE(!refcount_dec_and_test(&kvm->users_count));
>
> decreased the conut already?  With your patch the refcount would then
> underflow.

r = kvm_arch_init_vm(kvm, type);
if (r)
    goto out_err_no_arch_destroy_vm;

out_err_no_disable:
    kvm_arch_destroy_vm(kvm);
    WARN_ON_ONCE(!refcount_dec_and_test(&kvm->users_count));
out_err_no_arch_destroy_vm:

So, if kvm_arch_init_vm() fails, we will not execute
WARN_ON_ONCE(!refcount_dec_and_test(&kvm->users_count));

    Wanpeng

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ