Skip to content

Commit d383b31

Browse files
tiwaibonzini
authored andcommitted
KVM: x86: Fix NULL dereference at kvm_msr_ignored_check()
The newly introduced kvm_msr_ignored_check() tries to print error or debug messages via vcpu_*() macros, but those may cause Oops when NULL vcpu is passed for KVM_GET_MSRS ioctl. Fix it by replacing the print calls with kvm_*() macros. (Note that this will leave vcpu argument completely unused in the function, but I didn't touch it to make the fix as small as possible. A clean up may be applied later.) Fixes: 12bc213 ("KVM: X86: Do the same ignore_msrs check for feature msrs") BugLink: https://bugzilla.suse.com/show_bug.cgi?id=1178280 Cc: <stable@vger.kernel.org> Signed-off-by: Takashi Iwai <tiwai@suse.de> Message-Id: <20201030151414.20165-1-tiwai@suse.de> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
1 parent 8a967d6 commit d383b31

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

arch/x86/kvm/x86.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -265,13 +265,13 @@ static int kvm_msr_ignored_check(struct kvm_vcpu *vcpu, u32 msr,
265265

266266
if (ignore_msrs) {
267267
if (report_ignored_msrs)
268-
vcpu_unimpl(vcpu, "ignored %s: 0x%x data 0x%llx\n",
269-
op, msr, data);
268+
kvm_pr_unimpl("ignored %s: 0x%x data 0x%llx\n",
269+
op, msr, data);
270270
/* Mask the error */
271271
return 0;
272272
} else {
273-
vcpu_debug_ratelimited(vcpu, "unhandled %s: 0x%x data 0x%llx\n",
274-
op, msr, data);
273+
kvm_debug_ratelimited("unhandled %s: 0x%x data 0x%llx\n",
274+
op, msr, data);
275275
return -ENOENT;
276276
}
277277
}

0 commit comments

Comments
 (0)