summaryrefslogtreecommitdiffstats
path: root/arch/s390/kernel/compat_signal.c
diff options
context:
space:
mode:
authorHeiko Carstens <heiko.carstens@de.ibm.com>2013-10-14 13:34:28 +0200
committerMartin Schwidefsky <schwidefsky@de.ibm.com>2013-10-24 17:17:06 +0200
commitf8544ec4f49ffb9cb93419e41f0d8c0fb39eb78f (patch)
treecebeb58b9e4ed050b88ef839438de3492cde5510 /arch/s390/kernel/compat_signal.c
parents390: Remove unused declaration of zfcpdump_prefix_array[] (diff)
downloadlinux-f8544ec4f49ffb9cb93419e41f0d8c0fb39eb78f.tar.xz
linux-f8544ec4f49ffb9cb93419e41f0d8c0fb39eb78f.zip
s390/compat,signal: change return values to -EFAULT
Instead of returnin the number of bytes not copied and/or -EFAULT let the signal handler helper functions always return -EFAULT if a user space access failed. This doesn't fix a bug in the current code, but makes is harder to get it wrong in the future. Also "smatch" won't complain anymore about the fact that the number of remaining bytes gets returned instead of -EFAULT. Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com> Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
Diffstat (limited to 'arch/s390/kernel/compat_signal.c')
-rw-r--r--arch/s390/kernel/compat_signal.c25
1 files changed, 14 insertions, 11 deletions
diff --git a/arch/s390/kernel/compat_signal.c b/arch/s390/kernel/compat_signal.c
index ee820079c06d..b7b60f5cc54b 100644
--- a/arch/s390/kernel/compat_signal.c
+++ b/arch/s390/kernel/compat_signal.c
@@ -166,11 +166,14 @@ static int save_sigregs32(struct pt_regs *regs, _sigregs32 __user *sregs)
memcpy(regs32.acrs, current->thread.acrs, sizeof(regs32.acrs));
err = __copy_to_user(&sregs->regs, &regs32, sizeof(regs32));
if (err)
- return err;
+ return -EFAULT;
save_fp_regs(&current->thread.fp_regs);
/* s390_fp_regs and _s390_fp_regs32 are the same ! */
- return __copy_to_user(&sregs->fpregs, &current->thread.fp_regs,
- sizeof(_s390_fp_regs32));
+ err = __copy_to_user(&sregs->fpregs, &current->thread.fp_regs,
+ sizeof(_s390_fp_regs32));
+ if (err)
+ return -EFAULT;
+ return 0;
}
static int restore_sigregs32(struct pt_regs *regs,_sigregs32 __user *sregs)
@@ -183,7 +186,7 @@ static int restore_sigregs32(struct pt_regs *regs,_sigregs32 __user *sregs)
err = __copy_from_user(&regs32, &sregs->regs, sizeof(regs32));
if (err)
- return err;
+ return -EFAULT;
regs->psw.mask = (regs->psw.mask & ~PSW_MASK_USER) |
(__u64)(regs32.psw.mask & PSW32_MASK_USER) << 32 |
(__u64)(regs32.psw.addr & PSW32_ADDR_AMODE);
@@ -201,7 +204,7 @@ static int restore_sigregs32(struct pt_regs *regs,_sigregs32 __user *sregs)
sizeof(_s390_fp_regs32));
current->thread.fp_regs.fpc &= FPC_VALID_MASK;
if (err)
- return err;
+ return -EFAULT;
restore_fp_regs(&current->thread.fp_regs);
clear_thread_flag(TIF_SYSCALL); /* No longer in a system call */
@@ -215,18 +218,18 @@ static int save_sigregs_gprs_high(struct pt_regs *regs, __u32 __user *uregs)
for (i = 0; i < NUM_GPRS; i++)
gprs_high[i] = regs->gprs[i] >> 32;
-
- return __copy_to_user(uregs, &gprs_high, sizeof(gprs_high));
+ if (__copy_to_user(uregs, &gprs_high, sizeof(gprs_high)))
+ return -EFAULT;
+ return 0;
}
static int restore_sigregs_gprs_high(struct pt_regs *regs, __u32 __user *uregs)
{
__u32 gprs_high[NUM_GPRS];
- int err, i;
+ int i;
- err = __copy_from_user(&gprs_high, uregs, sizeof(gprs_high));
- if (err)
- return err;
+ if (__copy_from_user(&gprs_high, uregs, sizeof(gprs_high)))
+ return -EFAULT;
for (i = 0; i < NUM_GPRS; i++)
*(__u32 *)&regs->gprs[i] = gprs_high[i];
return 0;