summaryrefslogtreecommitdiffstats
path: root/kernel/sys.c
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2017-05-27 04:04:29 +0200
committerAl Viro <viro@zeniv.linux.org.uk>2017-05-27 21:38:06 +0200
commit613763a1f056211522bac77ff39f25706e678fdd (patch)
tree8c93f1836574bfad7be7bedab670defd5b7651b0 /kernel/sys.c
parenttrim __ARCH_WANT_SYS_OLD_GETRLIMIT (diff)
downloadlinux-613763a1f056211522bac77ff39f25706e678fdd.tar.xz
linux-613763a1f056211522bac77ff39f25706e678fdd.zip
take compat_sys_old_getrlimit() to native syscall
... and sanitize the ifdefs in there Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'kernel/sys.c')
-rw-r--r--kernel/sys.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/kernel/sys.c b/kernel/sys.c
index 8a94b4eabcaa..3778a8a417b6 100644
--- a/kernel/sys.c
+++ b/kernel/sys.c
@@ -1328,6 +1328,30 @@ SYSCALL_DEFINE2(old_getrlimit, unsigned int, resource,
return copy_to_user(rlim, &x, sizeof(x)) ? -EFAULT : 0;
}
+#ifdef CONFIG_COMPAT
+COMPAT_SYSCALL_DEFINE2(old_getrlimit, unsigned int, resource,
+ struct compat_rlimit __user *, rlim)
+{
+ struct rlimit r;
+
+ if (resource >= RLIM_NLIMITS)
+ return -EINVAL;
+
+ task_lock(current->group_leader);
+ r = current->signal->rlim[resource];
+ task_unlock(current->group_leader);
+ if (r.rlim_cur > 0x7FFFFFFF)
+ r.rlim_cur = 0x7FFFFFFF;
+ if (r.rlim_max > 0x7FFFFFFF)
+ r.rlim_max = 0x7FFFFFFF;
+
+ if (put_user(r.rlim_cur, &rlim->rlim_cur) ||
+ put_user(r.rlim_max, &rlim->rlim_max))
+ return -EFAULT;
+ return 0;
+}
+#endif
+
#endif
static inline bool rlim64_is_infinity(__u64 rlim64)