arm64: ptrace: fix compat reg getter/setter return values
authorWill Deacon <will.deacon@arm.com>
Fri, 22 Aug 2014 13:20:24 +0000 (14:20 +0100)
committerWill Deacon <will.deacon@arm.com>
Thu, 28 Aug 2014 19:01:42 +0000 (20:01 +0100)
copy_{to,from}_user return the number of bytes remaining on failure, not
an error code.

This patch returns -EFAULT when the copy operation didn't complete,
rather than expose the number of bytes not copied directly to userspace.

Signed-off-by: Will Deacon <will.deacon@arm.com>
arch/arm64/kernel/ptrace.c

index 2ac99887800142a5670e0e55bea89ecc020bfe57..fe63ac5e9bf5582cb4e494262a9d714d4b6758a7 100644 (file)
@@ -663,8 +663,10 @@ static int compat_gpr_get(struct task_struct *target,
                        kbuf += sizeof(reg);
                } else {
                        ret = copy_to_user(ubuf, &reg, sizeof(reg));
-                       if (ret)
+                       if (ret) {
+                               ret = -EFAULT;
                                break;
+                       }
 
                        ubuf += sizeof(reg);
                }
@@ -702,8 +704,10 @@ static int compat_gpr_set(struct task_struct *target,
                        kbuf += sizeof(reg);
                } else {
                        ret = copy_from_user(&reg, ubuf, sizeof(reg));
-                       if (ret)
-                               return ret;
+                       if (ret) {
+                               ret = -EFAULT;
+                               break;
+                       }
 
                        ubuf += sizeof(reg);
                }