aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86
diff options
context:
space:
mode:
authorPaolo Bonzini <pbonzini@redhat.com>2017-03-27 11:53:50 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2017-03-31 04:31:45 -0400
commit3e8c6bd9dbc44630199892ad27ef745a45335191 (patch)
treee60979d206a8debe477a6806885a237186626c3f /arch/x86
parent79191ea36dc9be10a9c9b03d6b341ed2d2f76045 (diff)
KVM: x86: cleanup the page tracking SRCU instance
commit 2beb6dad2e8f95d710159d5befb390e4f62ab5cf upstream. SRCU uses a delayed work item. Skip cleaning it up, and the result is use-after-free in the work item callbacks. Reported-by: Dmitry Vyukov <dvyukov@google.com> Suggested-by: Dmitry Vyukov <dvyukov@google.com> Fixes: 0eb05bf290cfe8610d9680b49abef37febd1c38a Reviewed-by: Xiao Guangrong <xiaoguangrong.eric@gmail.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'arch/x86')
-rw-r--r--arch/x86/include/asm/kvm_page_track.h1
-rw-r--r--arch/x86/kvm/page_track.c8
-rw-r--r--arch/x86/kvm/x86.c1
3 files changed, 10 insertions, 0 deletions
diff --git a/arch/x86/include/asm/kvm_page_track.h b/arch/x86/include/asm/kvm_page_track.h
index c2b8d24a235c..6226cb0eca23 100644
--- a/arch/x86/include/asm/kvm_page_track.h
+++ b/arch/x86/include/asm/kvm_page_track.h
@@ -35,6 +35,7 @@ struct kvm_page_track_notifier_node {
35}; 35};
36 36
37void kvm_page_track_init(struct kvm *kvm); 37void kvm_page_track_init(struct kvm *kvm);
38void kvm_page_track_cleanup(struct kvm *kvm);
38 39
39void kvm_page_track_free_memslot(struct kvm_memory_slot *free, 40void kvm_page_track_free_memslot(struct kvm_memory_slot *free,
40 struct kvm_memory_slot *dont); 41 struct kvm_memory_slot *dont);
diff --git a/arch/x86/kvm/page_track.c b/arch/x86/kvm/page_track.c
index b431539c3714..85024e0cfaa5 100644
--- a/arch/x86/kvm/page_track.c
+++ b/arch/x86/kvm/page_track.c
@@ -156,6 +156,14 @@ bool kvm_page_track_is_active(struct kvm_vcpu *vcpu, gfn_t gfn,
156 return !!ACCESS_ONCE(slot->arch.gfn_track[mode][index]); 156 return !!ACCESS_ONCE(slot->arch.gfn_track[mode][index]);
157} 157}
158 158
159void kvm_page_track_cleanup(struct kvm *kvm)
160{
161 struct kvm_page_track_notifier_head *head;
162
163 head = &kvm->arch.track_notifier_head;
164 cleanup_srcu_struct(&head->track_srcu);
165}
166
159void kvm_page_track_init(struct kvm *kvm) 167void kvm_page_track_init(struct kvm *kvm)
160{ 168{
161 struct kvm_page_track_notifier_head *head; 169 struct kvm_page_track_notifier_head *head;
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 731044efb195..e5bc139d1ba7 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -7976,6 +7976,7 @@ void kvm_arch_destroy_vm(struct kvm *kvm)
7976 kvm_free_vcpus(kvm); 7976 kvm_free_vcpus(kvm);
7977 kvfree(rcu_dereference_check(kvm->arch.apic_map, 1)); 7977 kvfree(rcu_dereference_check(kvm->arch.apic_map, 1));
7978 kvm_mmu_uninit_vm(kvm); 7978 kvm_mmu_uninit_vm(kvm);
7979 kvm_page_track_cleanup(kvm);
7979} 7980}
7980 7981
7981void kvm_arch_free_memslot(struct kvm *kvm, struct kvm_memory_slot *free, 7982void kvm_arch_free_memslot(struct kvm *kvm, struct kvm_memory_slot *free,