Commit 254d4d48 authored by Gleb Natapov's avatar Gleb Natapov Committed by Avi Kivity

KVM: fix segment_base() error checking

fix segment_base() to properly check for null segment selector and
avoid accessing NULL pointer if ldt selector in null.
Signed-off-by: default avatarGleb Natapov <gleb@redhat.com>
Signed-off-by: default avatarAvi Kivity <avi@redhat.com>
parent d6ab1ed4
...@@ -230,7 +230,7 @@ unsigned long segment_base(u16 selector) ...@@ -230,7 +230,7 @@ unsigned long segment_base(u16 selector)
unsigned long table_base; unsigned long table_base;
unsigned long v; unsigned long v;
if (selector == 0) if (!(selector & ~3))
return 0; return 0;
native_store_gdt(&gdt); native_store_gdt(&gdt);
...@@ -239,6 +239,8 @@ unsigned long segment_base(u16 selector) ...@@ -239,6 +239,8 @@ unsigned long segment_base(u16 selector)
if (selector & 4) { /* from ldt */ if (selector & 4) { /* from ldt */
u16 ldt_selector = kvm_read_ldt(); u16 ldt_selector = kvm_read_ldt();
if (!(ldt_selector & ~3))
return 0;
table_base = segment_base(ldt_selector); table_base = segment_base(ldt_selector);
} }
d = (struct desc_struct *)(table_base + (selector & ~7)); d = (struct desc_struct *)(table_base + (selector & ~7));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment