projects
/
firefly-linux-kernel-4.4.55.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
df50e5d
)
Fix NULL dereference in gfn_to_hva_prot()
author
Gleb Natapov
<gleb@redhat.com>
Tue, 1 Oct 2013 16:58:36 +0000
(19:58 +0300)
committer
Christoffer Dall
<christoffer.dall@linaro.org>
Thu, 2 Oct 2014 15:18:09 +0000
(17:18 +0200)
gfn_to_memslot() can return NULL or invalid slot. We need to check slot
validity before accessing it.
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Gleb Natapov <gleb@redhat.com>
(cherry picked from commit
a2ac07fe292ea41296049dfdbfeed203e2467ee7
)
Signed-off-by: Christoffer Dall <christoffer.dall@linaro.org>
virt/kvm/kvm_main.c
patch
|
blob
|
history
diff --git
a/virt/kvm/kvm_main.c
b/virt/kvm/kvm_main.c
index 8b47fd241a613858fbdbf7845af8c0cba5788d15..c5bc5aef11f58885c1a7344e038ea4c27f5380a9 100644
(file)
--- a/
virt/kvm/kvm_main.c
+++ b/
virt/kvm/kvm_main.c
@@
-1065,10
+1065,12
@@
EXPORT_SYMBOL_GPL(gfn_to_hva);
unsigned long gfn_to_hva_prot(struct kvm *kvm, gfn_t gfn, bool *writable)
{
struct kvm_memory_slot *slot = gfn_to_memslot(kvm, gfn);
- if (writable)
+ unsigned long hva = __gfn_to_hva_many(slot, gfn, NULL, false);
+
+ if (!kvm_is_error_hva(hva) && writable)
*writable = !memslot_is_readonly(slot);
- return
__gfn_to_hva_many(gfn_to_memslot(kvm, gfn), gfn, NULL, false)
;
+ return
hva
;
}
static int kvm_read_hva(void *data, void __user *hva, int len)