diff options
author | Gleb Natapov <gleb@redhat.com> | 2011-03-07 07:55:07 -0500 |
---|---|---|
committer | Marcelo Tosatti <mtosatti@redhat.com> | 2011-03-17 12:08:33 -0400 |
commit | 399a40c92d744feebf89b1f07208407c26e0aaf5 (patch) | |
tree | 69ae89dacff4378ec621bffc2fb06b71ca86bda7 /arch/x86 | |
parent | 5601d05b8c340ee2643febc146099325eff187eb (diff) |
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>
Diffstat (limited to 'arch/x86')
-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, | |||
1769 | struct desc_struct tr_seg; | 1769 | struct desc_struct tr_seg; |
1770 | u32 base3; | 1770 | u32 base3; |
1771 | int r; | 1771 | int r; |
1772 | u16 io_bitmap_ptr; | 1772 | u16 io_bitmap_ptr, perm, bit_idx = port & 0x7; |
1773 | u8 perm, bit_idx = port & 0x7; | ||
1774 | unsigned mask = (1 << len) - 1; | 1773 | unsigned mask = (1 << len) - 1; |
1775 | unsigned long base; | 1774 | unsigned long base; |
1776 | 1775 | ||
@@ -1788,7 +1787,7 @@ static bool emulator_io_port_access_allowed(struct x86_emulate_ctxt *ctxt, | |||
1788 | return false; | 1787 | return false; |
1789 | if (io_bitmap_ptr + port/8 > desc_limit_scaled(&tr_seg)) | 1788 | if (io_bitmap_ptr + port/8 > desc_limit_scaled(&tr_seg)) |
1790 | return false; | 1789 | return false; |
1791 | r = ops->read_std(base + io_bitmap_ptr + port/8, &perm, 1, ctxt->vcpu, | 1790 | r = ops->read_std(base + io_bitmap_ptr + port/8, &perm, 2, ctxt->vcpu, |
1792 | NULL); | 1791 | NULL); |
1793 | if (r != X86EMUL_CONTINUE) | 1792 | if (r != X86EMUL_CONTINUE) |
1794 | return false; | 1793 | return false; |