KVM: x86: Handle SRCU initialization failure during page track init
authorHaimin Zhang <tcs_kernel@tencent.com>
Fri, 3 Sep 2021 02:37:06 +0000 (10:37 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 6 Oct 2021 13:56:04 +0000 (15:56 +0200)
commitdeb2949417677649e2413266d7ce8c2ff73952b4
tree757fe2e6414fe2e2d9a63e64ba78074e55123030
parentf7ac4d24e1610b92689946fa88177673f1e88a3f
KVM: x86: Handle SRCU initialization failure during page track init

commit eb7511bf9182292ef1df1082d23039e856d1ddfb upstream.

Check the return of init_srcu_struct(), which can fail due to OOM, when
initializing the page track mechanism.  Lack of checking leads to a NULL
pointer deref found by a modified syzkaller.

Reported-by: TCS Robot <tcs_robot@tencent.com>
Signed-off-by: Haimin Zhang <tcs_kernel@tencent.com>
Message-Id: <1630636626-12262-1-git-send-email-tcs_kernel@tencent.com>
[Move the call towards the beginning of kvm_arch_init_vm. - Paolo]
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
arch/x86/include/asm/kvm_page_track.h
arch/x86/kvm/mmu/page_track.c
arch/x86/kvm/x86.c