From: Paolo Bonzini <pbonzini@redhat.com>
To: Colin King <colin.king@canonical.com>,
Sean Christopherson <seanjc@google.com>,
Vitaly Kuznetsov <vkuznets@redhat.com>,
Wanpeng Li <wanpengli@tencent.com>,
Jim Mattson <jmattson@google.com>, Joerg Roedel <joro@8bytes.org>,
Thomas Gleixner <tglx@linutronix.de>,
Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>,
x86@kernel.org, "H . Peter Anvin" <hpa@zytor.com>,
Nathan Tempelman <natet@google.com>,
kvm@vger.kernel.org
Cc: kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH][next] KVM: x86: Fix potential fput on a null source_kvm_file
Date: Mon, 3 May 2021 16:05:21 +0200 [thread overview]
Message-ID: <9d28cde2-7aff-64bb-26f4-9909344676e5@redhat.com> (raw)
In-Reply-To: <20210430170303.131924-1-colin.king@canonical.com>
On 30/04/21 19:03, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> The fget can potentially return null, so the fput on the error return
> path can cause a null pointer dereference. Fix this by checking for
> a null source_kvm_file before doing a fput.
>
> Addresses-Coverity: ("Dereference null return")
> Fixes: 54526d1fd593 ("KVM: x86: Support KVM VMs sharing SEV context")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
> arch/x86/kvm/svm/sev.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/arch/x86/kvm/svm/sev.c b/arch/x86/kvm/svm/sev.c
> index 1356ee095cd5..8b11c711a0e4 100644
> --- a/arch/x86/kvm/svm/sev.c
> +++ b/arch/x86/kvm/svm/sev.c
> @@ -1764,7 +1764,8 @@ int svm_vm_copy_asid_from(struct kvm *kvm, unsigned int source_fd)
> e_source_unlock:
> mutex_unlock(&source_kvm->lock);
> e_source_put:
> - fput(source_kvm_file);
> + if (source_kvm_file)
> + fput(source_kvm_file);
> return ret;
> }
>
>
Queued, thanks.
Paolo
prev parent reply other threads:[~2021-05-03 14:05 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-04-30 17:03 [PATCH][next] KVM: x86: Fix potential fput on a null source_kvm_file Colin King
2021-05-03 14:05 ` Paolo Bonzini [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=9d28cde2-7aff-64bb-26f4-9909344676e5@redhat.com \
--to=pbonzini@redhat.com \
--cc=bp@alien8.de \
--cc=colin.king@canonical.com \
--cc=hpa@zytor.com \
--cc=jmattson@google.com \
--cc=joro@8bytes.org \
--cc=kernel-janitors@vger.kernel.org \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=natet@google.com \
--cc=seanjc@google.com \
--cc=tglx@linutronix.de \
--cc=vkuznets@redhat.com \
--cc=wanpengli@tencent.com \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).