Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1345324 > unrolled thread
| Started by | "Michael S. Tsirkin" <mst@redhat.com> |
|---|---|
| First post | 2016-02-28 16:40 +0100 |
| Last post | 2016-03-02 10:40 +0100 |
| Articles | 3 — 3 participants |
Back to article view | Back to linux.kernel
[PATCH for-4,5] mips/kvm: fix ioctl error handling "Michael S. Tsirkin" <mst@redhat.com> - 2016-02-28 16:40 +0100
Re: [PATCH for-4,5] mips/kvm: fix ioctl error handling Sergei Shtylyov <sergei.shtylyov@cogentembedded.com> - 2016-02-28 18:40 +0100
Re: [PATCH for-4,5] mips/kvm: fix ioctl error handling Paolo Bonzini <pbonzini@redhat.com> - 2016-03-02 10:40 +0100
| From | "Michael S. Tsirkin" <mst@redhat.com> |
|---|---|
| Date | 2016-02-28 16:40 +0100 |
| Subject | [PATCH for-4,5] mips/kvm: fix ioctl error handling |
| Message-ID | <r7bBU-4yM-13@gated-at.bofh.it> |
Calling return copy_to_user(...) or return copy_from_user in an ioctl
will not do the right thing if there's a pagefault:
copy_to_user/copy_from_user return the number of bytes not copied in
this case.
Fix up kvm on mips to do
return copy_to_user(...)) ? -EFAULT : 0;
and
return copy_from_user(...)) ? -EFAULT : 0;
everywhere.
Cc: stable@vger.kernel.org
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
Untested.
arch/mips/kvm/mips.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/arch/mips/kvm/mips.c b/arch/mips/kvm/mips.c
index 8bc3977..3110447 100644
--- a/arch/mips/kvm/mips.c
+++ b/arch/mips/kvm/mips.c
@@ -702,7 +702,7 @@ static int kvm_mips_get_reg(struct kvm_vcpu *vcpu,
} else if ((reg->id & KVM_REG_SIZE_MASK) == KVM_REG_SIZE_U128) {
void __user *uaddr = (void __user *)(long)reg->addr;
- return copy_to_user(uaddr, vs, 16);
+ return copy_to_user(uaddr, vs, 16) ? -EFAULT : 0;
} else {
return -EINVAL;
}
@@ -732,7 +732,7 @@ static int kvm_mips_set_reg(struct kvm_vcpu *vcpu,
} else if ((reg->id & KVM_REG_SIZE_MASK) == KVM_REG_SIZE_U128) {
void __user *uaddr = (void __user *)(long)reg->addr;
- return copy_from_user(vs, uaddr, 16);
+ return copy_from_user(vs, uaddr, 16) ? -EFAULT : 0;
} else {
return -EINVAL;
}
--
MST
[toc] | [next] | [standalone]
| From | Sergei Shtylyov <sergei.shtylyov@cogentembedded.com> |
|---|---|
| Date | 2016-02-28 18:40 +0100 |
| Message-ID | <r7du3-5Yj-11@gated-at.bofh.it> |
| In reply to | #1345324 |
Hello.
On 02/28/2016 06:35 PM, Michael S. Tsirkin wrote:
> Calling return copy_to_user(...) or return copy_from_user in an ioctl
Calling return? Perhaps "returning the result of"?
> will not do the right thing if there's a pagefault:
> copy_to_user/copy_from_user return the number of bytes not copied in
> this case.
>
> Fix up kvm on mips to do
> return copy_to_user(...)) ? -EFAULT : 0;
> and
> return copy_from_user(...)) ? -EFAULT : 0;
>
> everywhere.
>
> Cc: stable@vger.kernel.org
> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
[...]
MBR, Sergei
[toc] | [prev] | [next] | [standalone]
| From | Paolo Bonzini <pbonzini@redhat.com> |
|---|---|
| Date | 2016-03-02 10:40 +0100 |
| Message-ID | <r8bqb-5KC-29@gated-at.bofh.it> |
| In reply to | #1345324 |
On 28/02/2016 16:35, Michael S. Tsirkin wrote:
> Calling return copy_to_user(...) or return copy_from_user in an ioctl
> will not do the right thing if there's a pagefault:
> copy_to_user/copy_from_user return the number of bytes not copied in
> this case.
>
> Fix up kvm on mips to do
> return copy_to_user(...)) ? -EFAULT : 0;
> and
> return copy_from_user(...)) ? -EFAULT : 0;
>
> everywhere.
>
> Cc: stable@vger.kernel.org
> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
> ---
>
> Untested.
>
> arch/mips/kvm/mips.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/arch/mips/kvm/mips.c b/arch/mips/kvm/mips.c
> index 8bc3977..3110447 100644
> --- a/arch/mips/kvm/mips.c
> +++ b/arch/mips/kvm/mips.c
> @@ -702,7 +702,7 @@ static int kvm_mips_get_reg(struct kvm_vcpu *vcpu,
> } else if ((reg->id & KVM_REG_SIZE_MASK) == KVM_REG_SIZE_U128) {
> void __user *uaddr = (void __user *)(long)reg->addr;
>
> - return copy_to_user(uaddr, vs, 16);
> + return copy_to_user(uaddr, vs, 16) ? -EFAULT : 0;
> } else {
> return -EINVAL;
> }
> @@ -732,7 +732,7 @@ static int kvm_mips_set_reg(struct kvm_vcpu *vcpu,
> } else if ((reg->id & KVM_REG_SIZE_MASK) == KVM_REG_SIZE_U128) {
> void __user *uaddr = (void __user *)(long)reg->addr;
>
> - return copy_from_user(vs, uaddr, 16);
> + return copy_from_user(vs, uaddr, 16) ? -EFAULT : 0;
> } else {
> return -EINVAL;
> }
>
Applied with the commit message tweak suggested by Sergei.
Paolo
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web