All of lore.kernel.org
 help / color / mirror / Atom feed
* FAILED: patch "[PATCH] MIPS: kvm: Fix ioctl error handling." failed to apply to 4.4-stable tree
@ 2016-03-07 20:39 gregkh
  2016-03-08 14:01 ` James Hogan
  0 siblings, 1 reply; 6+ messages in thread
From: gregkh @ 2016-03-07 20:39 UTC (permalink / raw)
  To: mst, james.hogan, pbonzini, ralf; +Cc: stable


The patch below does not apply to the 4.4-stable tree.
If someone wants it applied there, or to any other stable or longterm
tree, then please email the backport, including the original git commit
id to <stable@vger.kernel.org>.

thanks,

greg k-h

------------------ original commit in Linus's tree ------------------

>From 887349f69f37e71e2a8bfbd743831625a0b2ff51 Mon Sep 17 00:00:00 2001
From: "Michael S. Tsirkin" <mst@redhat.com>
Date: Sun, 28 Feb 2016 17:35:59 +0200
Subject: [PATCH] MIPS: kvm: Fix ioctl error handling.

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.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: James Hogan <james.hogan@imgtec.com>
Cc: linux-kernel@vger.kernel.org
Cc: linux-mips@linux-mips.org
Cc: stable@vger.kernel.org
Cc: kvm@vger.kernel.org
Patchwork: https://patchwork.linux-mips.org/patch/12709/
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>

diff --git a/arch/mips/kvm/mips.c b/arch/mips/kvm/mips.c
index 8bc3977576e6..3110447ab1e9 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;
 	}


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: FAILED: patch "[PATCH] MIPS: kvm: Fix ioctl error handling." failed to apply to 4.4-stable tree
  2016-03-07 20:39 FAILED: patch "[PATCH] MIPS: kvm: Fix ioctl error handling." failed to apply to 4.4-stable tree gregkh
@ 2016-03-08 14:01 ` James Hogan
  2016-03-08 14:10   ` Greg KH
  0 siblings, 1 reply; 6+ messages in thread
From: James Hogan @ 2016-03-08 14:01 UTC (permalink / raw)
  To: gregkh; +Cc: mst, pbonzini, ralf, stable

[-- Attachment #1: Type: text/plain, Size: 2507 bytes --]

Hi Greg,

On Mon, Mar 07, 2016 at 12:39:08PM -0800, gregkh@linuxfoundation.org wrote:
> 
> The patch below does not apply to the 4.4-stable tree.
> If someone wants it applied there, or to any other stable or longterm
> tree, then please email the backport, including the original git commit
> id to <stable@vger.kernel.org>.

I don't see any conflicts when this is applied to 4.4.4. Asside from the
hashes the cherry-picked commit is identical. Is it conflicting with
some other stable patch since then or something?

Thanks
James

> 
> thanks,
> 
> greg k-h
> 
> ------------------ original commit in Linus's tree ------------------
> 
> From 887349f69f37e71e2a8bfbd743831625a0b2ff51 Mon Sep 17 00:00:00 2001
> From: "Michael S. Tsirkin" <mst@redhat.com>
> Date: Sun, 28 Feb 2016 17:35:59 +0200
> Subject: [PATCH] MIPS: kvm: Fix ioctl error handling.
> 
> 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.
> 
> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
> Cc: Paolo Bonzini <pbonzini@redhat.com>
> Cc: James Hogan <james.hogan@imgtec.com>
> Cc: linux-kernel@vger.kernel.org
> Cc: linux-mips@linux-mips.org
> Cc: stable@vger.kernel.org
> Cc: kvm@vger.kernel.org
> Patchwork: https://patchwork.linux-mips.org/patch/12709/
> Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
> 
> diff --git a/arch/mips/kvm/mips.c b/arch/mips/kvm/mips.c
> index 8bc3977576e6..3110447ab1e9 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;
>  	}
> 

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: FAILED: patch "[PATCH] MIPS: kvm: Fix ioctl error handling." failed to apply to 4.4-stable tree
  2016-03-08 14:01 ` James Hogan
@ 2016-03-08 14:10   ` Greg KH
  2016-03-08 14:42     ` James Hogan
  0 siblings, 1 reply; 6+ messages in thread
From: Greg KH @ 2016-03-08 14:10 UTC (permalink / raw)
  To: James Hogan; +Cc: mst, pbonzini, ralf, stable

On Tue, Mar 08, 2016 at 02:01:08PM +0000, James Hogan wrote:
> Hi Greg,
> 
> On Mon, Mar 07, 2016 at 12:39:08PM -0800, gregkh@linuxfoundation.org wrote:
> > 
> > The patch below does not apply to the 4.4-stable tree.
> > If someone wants it applied there, or to any other stable or longterm
> > tree, then please email the backport, including the original git commit
> > id to <stable@vger.kernel.org>.
> 
> I don't see any conflicts when this is applied to 4.4.4. Asside from the
> hashes the cherry-picked commit is identical. Is it conflicting with
> some other stable patch since then or something?

Try using patch, not 'cherry-pick' and see if it still applies.

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: FAILED: patch "[PATCH] MIPS: kvm: Fix ioctl error handling." failed to apply to 4.4-stable tree
  2016-03-08 14:10   ` Greg KH
@ 2016-03-08 14:42     ` James Hogan
  2016-03-12  6:37       ` Greg KH
  0 siblings, 1 reply; 6+ messages in thread
From: James Hogan @ 2016-03-08 14:42 UTC (permalink / raw)
  To: Greg KH; +Cc: mst, pbonzini, ralf, stable

[-- Attachment #1: Type: text/plain, Size: 1937 bytes --]

On Tue, Mar 08, 2016 at 06:10:29AM -0800, Greg KH wrote:
> On Tue, Mar 08, 2016 at 02:01:08PM +0000, James Hogan wrote:
> > Hi Greg,
> > 
> > On Mon, Mar 07, 2016 at 12:39:08PM -0800, gregkh@linuxfoundation.org wrote:
> > > 
> > > The patch below does not apply to the 4.4-stable tree.
> > > If someone wants it applied there, or to any other stable or longterm
> > > tree, then please email the backport, including the original git commit
> > > id to <stable@vger.kernel.org>.
> > 
> > I don't see any conflicts when this is applied to 4.4.4. Asside from the
> > hashes the cherry-picked commit is identical. Is it conflicting with
> > some other stable patch since then or something?
> 
> Try using patch, not 'cherry-pick' and see if it still applies.

$ git reset --hard HEAD~
HEAD is now at c252409a688a Linux 4.4.4
$ git show 887349f69f37e71e2a8bfbd743831625a0b2ff51 | patch -p1
patching file arch/mips/kvm/mips.c
$ git diff | cat
diff --git a/arch/mips/kvm/mips.c b/arch/mips/kvm/mips.c
index b9b803facdbf..2683d04fdda5 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;
        }

Cheers
James

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: FAILED: patch "[PATCH] MIPS: kvm: Fix ioctl error handling." failed to apply to 4.4-stable tree
  2016-03-08 14:42     ` James Hogan
@ 2016-03-12  6:37       ` Greg KH
  2016-03-12 22:14         ` James Hogan
  0 siblings, 1 reply; 6+ messages in thread
From: Greg KH @ 2016-03-12  6:37 UTC (permalink / raw)
  To: James Hogan; +Cc: mst, pbonzini, ralf, stable

On Tue, Mar 08, 2016 at 02:42:01PM +0000, James Hogan wrote:
> On Tue, Mar 08, 2016 at 06:10:29AM -0800, Greg KH wrote:
> > On Tue, Mar 08, 2016 at 02:01:08PM +0000, James Hogan wrote:
> > > Hi Greg,
> > > 
> > > On Mon, Mar 07, 2016 at 12:39:08PM -0800, gregkh@linuxfoundation.org wrote:
> > > > 
> > > > The patch below does not apply to the 4.4-stable tree.
> > > > If someone wants it applied there, or to any other stable or longterm
> > > > tree, then please email the backport, including the original git commit
> > > > id to <stable@vger.kernel.org>.
> > > 
> > > I don't see any conflicts when this is applied to 4.4.4. Asside from the
> > > hashes the cherry-picked commit is identical. Is it conflicting with
> > > some other stable patch since then or something?
> > 
> > Try using patch, not 'cherry-pick' and see if it still applies.
> 
> $ git reset --hard HEAD~
> HEAD is now at c252409a688a Linux 4.4.4
> $ git show 887349f69f37e71e2a8bfbd743831625a0b2ff51 | patch -p1
> patching file arch/mips/kvm/mips.c
> $ git diff | cat
> diff --git a/arch/mips/kvm/mips.c b/arch/mips/kvm/mips.c
> index b9b803facdbf..2683d04fdda5 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;
>         }
> 

Fails for me:

~/linux/stable/linux-4.4.y $ git show 887349f69f37e71e2a8bfbd743831625a0b2ff51 | patch -p1
patching file arch/mips/kvm/mips.c
Reversed (or previously applied) patch detected!  Assume -R? [n]
Apply anyway? [n]
Skipping patch.
2 out of 2 hunks ignored -- saving rejects to file arch/mips/kvm/mips.c.rej


Is this an issue with 4.4.5 perhaps?

Ah, do we have duplicate patches here?  Look at commit
0178fd7dcc4451fcb90bec5e91226586962478d2 which is in 4.4.5 now, it's
this same patch...


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: FAILED: patch "[PATCH] MIPS: kvm: Fix ioctl error handling." failed to apply to 4.4-stable tree
  2016-03-12  6:37       ` Greg KH
@ 2016-03-12 22:14         ` James Hogan
  0 siblings, 0 replies; 6+ messages in thread
From: James Hogan @ 2016-03-12 22:14 UTC (permalink / raw)
  To: Greg KH; +Cc: mst, pbonzini, ralf, stable

[-- Attachment #1: Type: text/plain, Size: 2846 bytes --]

On Fri, Mar 11, 2016 at 10:37:45PM -0800, Greg KH wrote:
> On Tue, Mar 08, 2016 at 02:42:01PM +0000, James Hogan wrote:
> > On Tue, Mar 08, 2016 at 06:10:29AM -0800, Greg KH wrote:
> > > On Tue, Mar 08, 2016 at 02:01:08PM +0000, James Hogan wrote:
> > > > Hi Greg,
> > > > 
> > > > On Mon, Mar 07, 2016 at 12:39:08PM -0800, gregkh@linuxfoundation.org wrote:
> > > > > 
> > > > > The patch below does not apply to the 4.4-stable tree.
> > > > > If someone wants it applied there, or to any other stable or longterm
> > > > > tree, then please email the backport, including the original git commit
> > > > > id to <stable@vger.kernel.org>.
> > > > 
> > > > I don't see any conflicts when this is applied to 4.4.4. Asside from the
> > > > hashes the cherry-picked commit is identical. Is it conflicting with
> > > > some other stable patch since then or something?
> > > 
> > > Try using patch, not 'cherry-pick' and see if it still applies.
> > 
> > $ git reset --hard HEAD~
> > HEAD is now at c252409a688a Linux 4.4.4
> > $ git show 887349f69f37e71e2a8bfbd743831625a0b2ff51 | patch -p1
> > patching file arch/mips/kvm/mips.c
> > $ git diff | cat
> > diff --git a/arch/mips/kvm/mips.c b/arch/mips/kvm/mips.c
> > index b9b803facdbf..2683d04fdda5 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;
> >         }
> > 
> 
> Fails for me:
> 
> ~/linux/stable/linux-4.4.y $ git show 887349f69f37e71e2a8bfbd743831625a0b2ff51 | patch -p1
> patching file arch/mips/kvm/mips.c
> Reversed (or previously applied) patch detected!  Assume -R? [n]
> Apply anyway? [n]
> Skipping patch.
> 2 out of 2 hunks ignored -- saving rejects to file arch/mips/kvm/mips.c.rej
> 
> 
> Is this an issue with 4.4.5 perhaps?
> 
> Ah, do we have duplicate patches here?  Look at commit
> 0178fd7dcc4451fcb90bec5e91226586962478d2 which is in 4.4.5 now, it's
> this same patch...

Ah yes, that'd be it. Both Ralf and Paolo applied it.

Thanks
James

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2016-03-12 22:14 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-03-07 20:39 FAILED: patch "[PATCH] MIPS: kvm: Fix ioctl error handling." failed to apply to 4.4-stable tree gregkh
2016-03-08 14:01 ` James Hogan
2016-03-08 14:10   ` Greg KH
2016-03-08 14:42     ` James Hogan
2016-03-12  6:37       ` Greg KH
2016-03-12 22:14         ` James Hogan

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.