[patch 14/62] KVM: MMU: Fix potential race setting upper shadow ptes on nonpae hosts

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Greg KH
Date: Wednesday, July 30, 2008 - 4:58 pm

2.6.26 -stable review patch.  If anyone has any objections, please let
us know.

------------------
From: Avi Kivity <avi@qumranet.com>

Original-Commit-Hash: c23a6fe17abf8562e675465f8d55ba1a551d314d

The direct mapped shadow code (used for real mode and two dimensional paging)
sets upper-level ptes using direct assignment rather than calling
set_shadow_pte().  A nonpae host will split this into two writes, which opens
up a race if another vcpu accesses the same memory area.

Fix by calling set_shadow_pte() instead of assigning directly.

Noticed by Izik Eidus.

Signed-off-by: Avi Kivity <avi@qumranet.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>


---
 arch/x86/kvm/mmu.c |    7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

--- a/arch/x86/kvm/mmu.c
+++ b/arch/x86/kvm/mmu.c
@@ -1171,9 +1171,10 @@ static int __direct_map(struct kvm_vcpu 
 				return -ENOMEM;
 			}
 
-			table[index] = __pa(new_table->spt)
-				| PT_PRESENT_MASK | PT_WRITABLE_MASK
-				| shadow_user_mask | shadow_x_mask;
+			set_shadow_pte(&table[index],
+				       __pa(new_table->spt)
+				       | PT_PRESENT_MASK | PT_WRITABLE_MASK
+				       | shadow_user_mask | shadow_x_mask);
 		}
 		table_addr = table[index] & PT64_BASE_ADDR_MASK;
 	}

-- 
--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[patch 00/62] 2.6.26-stable review, Greg KH, (Wed Jul 30, 4:49 pm)
[patch 03/62] ipv6: use timer pending, Greg KH, (Wed Jul 30, 4:57 pm)
[patch 05/62] hdlcdrv: Fix CRC calculation., Greg KH, (Wed Jul 30, 4:57 pm)
[patch 14/62] KVM: MMU: Fix potential race setting upper s ..., Greg KH, (Wed Jul 30, 4:58 pm)
[patch 23/62] proc: fix /proc/*/pagemap, Greg KH, (Wed Jul 30, 4:58 pm)
[patch 53/62] UML - Fix boot crash, Greg KH, (Wed Jul 30, 4:59 pm)