From: Paolo Bonzini <pbonzini@redhat.com>
To: Shailendra Verma <shailendra.v@samsung.com>,
Gleb Natapov <gleb@kernel.org>,
kvm@vger.kernel.org, Ravikant Sharma <ravikant.s2@samsung.com>
Cc: linux-kernel@vger.kernel.org, vidushi.koul@samsung.com
Subject: Re: Virt: Kvm - Fix possible ERR_PTR() dereferencing.
Date: Tue, 20 Sep 2016 10:36:35 +0200 [thread overview]
Message-ID: <6ee49836-d377-144e-3246-e4312bd0360c@redhat.com> (raw)
In-Reply-To: <1474354210-18881-1-git-send-email-shailendra.v@samsung.com>
On 20/09/2016 08:50, Shailendra Verma wrote:
> This is of course wrong to call kfree() if memdup_user() fails,
> no memory was allocated and the error in the error-valued pointer
> should be returned.
>
> Reviewed-by: Ravikant Sharma <ravikant.s2@samsung.com>
> Signed-off-by: Shailendra Verma <shailendra.v@samsung.com>
> ---
> virt/kvm/kvm_main.c | 20 ++++++--------------
> 1 file changed, 6 insertions(+), 14 deletions(-)
>
> diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
> index 484079e..e3a0653 100644
> --- a/virt/kvm/kvm_main.c
> +++ b/virt/kvm/kvm_main.c
> @@ -2398,10 +2398,8 @@ out_free1:
>
> r = -ENOMEM;
> kvm_regs = memdup_user(argp, sizeof(*kvm_regs));
> - if (IS_ERR(kvm_regs)) {
> - r = PTR_ERR(kvm_regs);
> - goto out;
> - }
> + if (IS_ERR(kvm_regs))
> + return PTR_ERR(kvm_regs);
This incorrectly skips the vcpu_put at the end.
Paolo
> r = kvm_arch_vcpu_ioctl_set_regs(vcpu, kvm_regs);
> kfree(kvm_regs);
> break;
> @@ -2422,11 +2420,8 @@ out_free1:
> }
> case KVM_SET_SREGS: {
> kvm_sregs = memdup_user(argp, sizeof(*kvm_sregs));
> - if (IS_ERR(kvm_sregs)) {
> - r = PTR_ERR(kvm_sregs);
> - kvm_sregs = NULL;
> - goto out;
> - }
> + if (IS_ERR(kvm_sregs))
> + return PTR_ERR(kvm_sregs);
> r = kvm_arch_vcpu_ioctl_set_sregs(vcpu, kvm_sregs);
> break;
> }
> @@ -2514,11 +2509,8 @@ out_free1:
> }
> case KVM_SET_FPU: {
> fpu = memdup_user(argp, sizeof(*fpu));
> - if (IS_ERR(fpu)) {
> - r = PTR_ERR(fpu);
> - fpu = NULL;
> - goto out;
> - }
> + if (IS_ERR(fpu))
> + return PTR_ERR(fpu);
> r = kvm_arch_vcpu_ioctl_set_fpu(vcpu, fpu);
> break;
> }
>
prev parent reply other threads:[~2016-09-20 8:36 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-09-20 6:50 Shailendra Verma
2016-09-20 8:36 ` 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=6ee49836-d377-144e-3246-e4312bd0360c@redhat.com \
--to=pbonzini@redhat.com \
--cc=gleb@kernel.org \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=ravikant.s2@samsung.com \
--cc=shailendra.v@samsung.com \
--cc=vidushi.koul@samsung.com \
/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
all inboxes | Powered by JetHome®