FAILED: patch "[PATCH] MIPS: kvm: Fix ioctl error handling." failed to apply to 4.4-stable tree
Subsystems (3)
[email protected]
maintainerThe 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 <[email protected]>.
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
Quoted 1 line
From
887349f69f37e71e2a8bfbd743831625a0b2ff51Mon Sep 17 00:00:00 2001
From: "Michael S. Tsirkin" <[email protected]>
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.
Patchwork: https://patchwork.linux-mips.org/patch/12709/
arch/mips/kvm/mips.c +2 -2
@@ -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 ; }
Hi Greg,
Quoted 5 lines · On Mon, Mar 07, 2016 at 12:39:08PM -0800, [email protected] 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 <[email protected]>.
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
Quoted 57 lines
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From
887349f69f37e71e2a8bfbd743831625a0b2ff51Mon Sep 17 00:00:00 2001
From: "Michael S. Tsirkin" <[email protected]>
Date: Sun, 28 Feb 2016 17:35:59 +0200
Subject: [PATCH] MIPS: kvm: Fix ioctl error handling.Calling return
copy_to_user(...)or returncopy_from_userin 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 <[email protected]>Cc Paolo Bonzini <[email protected]>Cc James Hogan <[email protected]>Patchwork: https://patchwork.linux-mips.org/patch/12709/
Signed-off-by Ralf Baechle <[email protected]>arch/mips/kvm/mips.c +2
-2@@ -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 ; }
Greg KH
maintainerQuoted 4 lines · James Hogan
Hi Greg,
Quoted 1 line · On Mon, Mar 07, 2016 at 12:39:08PM -0800, [email protected] wrote:
Quoted 8 lines
Quoted 4 lines
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 <[email protected]>.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
Quoted 10 lines · Greg KH
Quoted 9 lines · James Hogan
Hi Greg,
Quoted 5 lines · On Mon, Mar 07, 2016 at 12:39:08PM -0800, [email protected] 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 <[email protected]>.
Quoted 5 lines
Quoted 3 lines
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
arch/mips/kvm/mips.c +2 -2
@@ -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
Greg KH
maintainerQuoted 37 lines · James Hogan
Quoted 10 lines · Greg KH
Quoted 9 lines · James Hogan
Hi Greg,
Quoted 5 lines · On Mon, Mar 07, 2016 at 12:39:08PM -0800, [email protected] 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 <[email protected]>.Quoted 5 lines
Quoted 3 lines
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 | catarch/mips/kvm/mips.c +1
-1@@ -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 ; }
arch/mips/kvm/mips.c static int kvm_mips_set_reg(struct kvm_vcpu *vcpu, · line 738
Quoted 8 lines
arch/mips/kvm/mips.c +1
-1@@ -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...
Quoted 57 lines · Greg KH
Quoted 37 lines · James Hogan
Quoted 10 lines · Greg KH
Quoted 9 lines · James Hogan
Hi Greg,
Quoted 5 lines · On Mon, Mar 07, 2016 at 12:39:08PM -0800, [email protected] 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 <[email protected]>.Quoted 5 lines
Quoted 3 lines
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 | catarch/mips/kvm/mips.c +1
-1@@ -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 ; }arch/mips/kvm/mips.c static int kvm_mips_set_reg(struct kvm_vcpu *vcpu, · line 738
Quoted 8 lines
arch/mips/kvm/mips.c +1
-1@@ -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 filearch/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 filearch/mips/kvm/mips.c.rej
Quoted 5 lines
Is this an issue with 4.4.5 perhaps?
Ah, do we have duplicate patches here? Look at commit
0178fd7dcc4451fcb90bec5e91226586962478d2which 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