Skip to contentSkip to conversation

x86/levelling: Avoid NULL pointer dereference

PATCH In review Andrew Cooper 2 participants 2 messages Sep 25, 2017 – Sep 26, 2017

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86/levelling: Avoid NULL pointer dereference

Coverity points out that next is indeed NULL at times. Only try to read the .cpuid_faulting field when we sure that next isn't NULL.

Fixes e7a370733bd "x86: replace arch_vcpu::cpuid_faulting with msr_vcpu_policy"

---
CC: Jan Beulich <[email protected]>

---
 xen/arch/x86/cpu/intel.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
xen/arch/x86/cpu/intel.c +1 -2
index 218236d..ac932e5 100644
@@ -156,7 +156,6 @@ static void intel_ctxt_switch_levelling(const struct vcpu *next)
 	struct cpuidmasks *these_masks = &this_cpu(cpuidmasks);
 	const struct domain *nextd = next ? next->domain : NULL;
 	const struct cpuidmasks *masks;
-	const struct msr_vcpu_policy *vp = next->arch.msr;
 
 	if (cpu_has_cpuid_faulting) {
 		/*
@@ -177,7 +176,7 @@ static void intel_ctxt_switch_levelling(const struct vcpu *next)
 		 */
 		set_cpuid_faulting(nextd && !is_control_domain(nextd) &&
 				   (is_pv_domain(nextd) ||
-				    vp->misc_features_enables.cpuid_faulting));
+				    next->arch.msr->misc_features_enables.cpuid_faulting));
 		return;
 	}
 
Signature · 7 lines
2.1.4


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Reviewed-by on v1 1/1
#1 lore raw

xen/arch/x86/cpu/intel.c static void intel_ctxt_switch_levelling(const struct vcpu *next) · line 160

Quoted 10 lines
Quoted 1 line
Quoted 1 line · On 25.09.17 at 18:28, <[email protected]> wrote:
xen/arch/x86/cpu/intel.c +0 -1
@@ -156,7 +156,6 @@ static void intel_ctxt_switch_levelling(const struct vcpu *next)
 	struct cpuidmasks *these_masks = &this_cpu(cpuidmasks);
 	const struct domain *nextd = next ? next->domain : NULL;
 	const struct cpuidmasks *masks;
-	const struct msr_vcpu_policy *vp = next->arch.msr;
 
 	if (cpu_has_cpuid_faulting) {

And patch context (specifically the same here as for the offending patch) even shows that next is being checked against NULL. Yet none of us did notice.

Jan

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel