rlimits: switch more rlimit syscalls to do_prlimit
After we added more generic do_prlimit, switch sys_getrlimit to that. Also switch compat handling, so we can get rid of ugly __user casts and avoid setting process' address limit to kernel data and back. Signed-off-by: Jiri Slaby <jslaby@suse.cz>
This commit is contained in:
parent
5b41535aac
commit
b95183453a
2 changed files with 11 additions and 23 deletions
|
@ -279,11 +279,6 @@ asmlinkage long compat_sys_setrlimit(unsigned int resource,
|
||||||
struct compat_rlimit __user *rlim)
|
struct compat_rlimit __user *rlim)
|
||||||
{
|
{
|
||||||
struct rlimit r;
|
struct rlimit r;
|
||||||
int ret;
|
|
||||||
mm_segment_t old_fs = get_fs ();
|
|
||||||
|
|
||||||
if (resource >= RLIM_NLIMITS)
|
|
||||||
return -EINVAL;
|
|
||||||
|
|
||||||
if (!access_ok(VERIFY_READ, rlim, sizeof(*rlim)) ||
|
if (!access_ok(VERIFY_READ, rlim, sizeof(*rlim)) ||
|
||||||
__get_user(r.rlim_cur, &rlim->rlim_cur) ||
|
__get_user(r.rlim_cur, &rlim->rlim_cur) ||
|
||||||
|
@ -294,10 +289,7 @@ asmlinkage long compat_sys_setrlimit(unsigned int resource,
|
||||||
r.rlim_cur = RLIM_INFINITY;
|
r.rlim_cur = RLIM_INFINITY;
|
||||||
if (r.rlim_max == COMPAT_RLIM_INFINITY)
|
if (r.rlim_max == COMPAT_RLIM_INFINITY)
|
||||||
r.rlim_max = RLIM_INFINITY;
|
r.rlim_max = RLIM_INFINITY;
|
||||||
set_fs(KERNEL_DS);
|
return do_prlimit(current, resource, &r, NULL);
|
||||||
ret = sys_setrlimit(resource, (struct rlimit __user *) &r);
|
|
||||||
set_fs(old_fs);
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef COMPAT_RLIM_OLD_INFINITY
|
#ifdef COMPAT_RLIM_OLD_INFINITY
|
||||||
|
@ -329,16 +321,13 @@ asmlinkage long compat_sys_old_getrlimit(unsigned int resource,
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
asmlinkage long compat_sys_getrlimit (unsigned int resource,
|
asmlinkage long compat_sys_getrlimit(unsigned int resource,
|
||||||
struct compat_rlimit __user *rlim)
|
struct compat_rlimit __user *rlim)
|
||||||
{
|
{
|
||||||
struct rlimit r;
|
struct rlimit r;
|
||||||
int ret;
|
int ret;
|
||||||
mm_segment_t old_fs = get_fs();
|
|
||||||
|
|
||||||
set_fs(KERNEL_DS);
|
ret = do_prlimit(current, resource, NULL, &r);
|
||||||
ret = sys_getrlimit(resource, (struct rlimit __user *) &r);
|
|
||||||
set_fs(old_fs);
|
|
||||||
if (!ret) {
|
if (!ret) {
|
||||||
if (r.rlim_cur > COMPAT_RLIM_INFINITY)
|
if (r.rlim_cur > COMPAT_RLIM_INFINITY)
|
||||||
r.rlim_cur = COMPAT_RLIM_INFINITY;
|
r.rlim_cur = COMPAT_RLIM_INFINITY;
|
||||||
|
|
17
kernel/sys.c
17
kernel/sys.c
|
@ -1236,15 +1236,14 @@ SYSCALL_DEFINE2(setdomainname, char __user *, name, int, len)
|
||||||
|
|
||||||
SYSCALL_DEFINE2(getrlimit, unsigned int, resource, struct rlimit __user *, rlim)
|
SYSCALL_DEFINE2(getrlimit, unsigned int, resource, struct rlimit __user *, rlim)
|
||||||
{
|
{
|
||||||
if (resource >= RLIM_NLIMITS)
|
struct rlimit value;
|
||||||
return -EINVAL;
|
int ret;
|
||||||
else {
|
|
||||||
struct rlimit value;
|
ret = do_prlimit(current, resource, NULL, &value);
|
||||||
task_lock(current->group_leader);
|
if (!ret)
|
||||||
value = current->signal->rlim[resource];
|
ret = copy_to_user(rlim, &value, sizeof(*rlim)) ? -EFAULT : 0;
|
||||||
task_unlock(current->group_leader);
|
|
||||||
return copy_to_user(rlim, &value, sizeof(*rlim)) ? -EFAULT : 0;
|
return ret;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef __ARCH_WANT_SYS_OLD_GETRLIMIT
|
#ifdef __ARCH_WANT_SYS_OLD_GETRLIMIT
|
||||||
|
|
Loading…
Reference in a new issue