diff options
author | Gleb Natapov | 2011-03-07 13:55:07 +0100 |
---|---|---|
committer | Marcelo Tosatti | 2011-03-17 17:08:33 +0100 |
commit | 399a40c92d744feebf89b1f07208407c26e0aaf5 (patch) | |
tree | 69ae89dacff4378ec621bffc2fb06b71ca86bda7 | |
parent | KVM: emulator: Fix io permission checking for 64bit guest (diff) | |
download | kernel-qcow2-linux-399a40c92d744feebf89b1f07208407c26e0aaf5.tar.gz kernel-qcow2-linux-399a40c92d744feebf89b1f07208407c26e0aaf5.tar.xz kernel-qcow2-linux-399a40c92d744feebf89b1f07208407c26e0aaf5.zip |
KVM: emulator: Fix permission checking in io permission bitmap
Currently if io port + len crosses 8bit boundary in io permission bitmap the
check may allow IO that otherwise should not be allowed. The patch fixes that.
Signed-off-by: Gleb Natapov <gleb@redhat.com>
Signed-off-by: Avi Kivity <avi@redhat.com>
-rw-r--r-- | arch/x86/kvm/emulate.c | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c index d6088b8686fb..0ad47b819a8b 100644 --- a/arch/x86/kvm/emulate.c +++ b/arch/x86/kvm/emulate.c @@ -1769,8 +1769,7 @@ static bool emulator_io_port_access_allowed(struct x86_emulate_ctxt *ctxt, struct desc_struct tr_seg; u32 base3; int r; - u16 io_bitmap_ptr; - u8 perm, bit_idx = port & 0x7; + u16 io_bitmap_ptr, perm, bit_idx = port & 0x7; unsigned mask = (1 << len) - 1; unsigned long base; @@ -1788,7 +1787,7 @@ static bool emulator_io_port_access_allowed(struct x86_emulate_ctxt *ctxt, return false; if (io_bitmap_ptr + port/8 > desc_limit_scaled(&tr_seg)) return false; - r = ops->read_std(base + io_bitmap_ptr + port/8, &perm, 1, ctxt->vcpu, + r = ops->read_std(base + io_bitmap_ptr + port/8, &perm, 2, ctxt->vcpu, NULL); if (r != X86EMUL_CONTINUE) return false; |