From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 72B16C2D0A3 for ; Tue, 3 Nov 2020 21:46:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1D79122403 for ; Tue, 3 Nov 2020 21:46:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1604439982; bh=CW705dfPC+HRWp4+0+GOOvbCAY93A+1RXl1xBKjNevs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=zLSCnPg2nNRugybdFVeSE31ejDKv4TLu6j/p5aGZ5MQzkqpQ/G1am9Z3e+JNg+JUP sFWRcYWr8VQW+Nuf3BYKOrP6q7slCmjZVArs6nsc0IFHf2Nn2zDpiv8LDOuo4/nNb8 LtFnIcbu9yrJWEyC04s20o5Hi04h5ZdIa3TvGB4I= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732043AbgKCVqV (ORCPT ); Tue, 3 Nov 2020 16:46:21 -0500 Received: from mail.kernel.org ([198.145.29.99]:48530 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732056AbgKCUwO (ORCPT ); Tue, 3 Nov 2020 15:52:14 -0500 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 6ABE92053B; Tue, 3 Nov 2020 20:52:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1604436733; bh=CW705dfPC+HRWp4+0+GOOvbCAY93A+1RXl1xBKjNevs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AFaCLxFLnbIYzp5aaEGlxjxLXIu+nce+rU4Sk6u+nsgBc5eJcMmrPUuTF20uTQZa0 E1zL2EB6udrZJTU64DxFqwV/8h6v+vDrKmE6LBvaB4wrvNEW+U8Wp3wnUA6tvsSeRs FKLx59AWTtIiY7SksZ+0CAUYnPy9j0B4tdvZB8Lw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Takashi Iwai , Paolo Bonzini Subject: [PATCH 5.9 378/391] KVM: x86: Fix NULL dereference at kvm_msr_ignored_check() Date: Tue, 3 Nov 2020 21:37:09 +0100 Message-Id: <20201103203412.671287363@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201103203348.153465465@linuxfoundation.org> References: <20201103203348.153465465@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Takashi Iwai commit d383b3146d805a743658225c8973f5d38c6fedf4 upstream. 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: 12bc2132b15e ("KVM: X86: Do the same ignore_msrs check for feature msrs") BugLink: https://bugzilla.suse.com/show_bug.cgi?id=1178280 Cc: Signed-off-by: Takashi Iwai Message-Id: <20201030151414.20165-1-tiwai@suse.de> Signed-off-by: Paolo Bonzini Signed-off-by: Greg Kroah-Hartman --- arch/x86/kvm/x86.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -259,13 +259,13 @@ static int kvm_msr_ignored_check(struct if (ignore_msrs) { if (report_ignored_msrs) - vcpu_unimpl(vcpu, "ignored %s: 0x%x data 0x%llx\n", - op, msr, data); + kvm_pr_unimpl("ignored %s: 0x%x data 0x%llx\n", + op, msr, data); /* Mask the error */ return 0; } else { - vcpu_debug_ratelimited(vcpu, "unhandled %s: 0x%x data 0x%llx\n", - op, msr, data); + kvm_debug_ratelimited("unhandled %s: 0x%x data 0x%llx\n", + op, msr, data); return 1; } }