diff options
author | Jiri Slaby <jirislaby@gmail.com> | 2010-05-04 05:28:25 -0400 |
---|---|---|
committer | Jiri Slaby <jirislaby@gmail.com> | 2010-07-16 03:48:48 -0400 |
commit | b95183453af2ed14a5c7027e58049c9fd17e92ce (patch) | |
tree | 8db2687b9508de182615915c7df1edf26d08638c /kernel/compat.c | |
parent | 5b41535aac0c07135ff6a4c5c2ae115d1c20c0bc (diff) |
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>
Diffstat (limited to 'kernel/compat.c')
-rw-r--r-- | kernel/compat.c | 17 |
1 files changed, 3 insertions, 14 deletions
diff --git a/kernel/compat.c b/kernel/compat.c index 5adab05a3172..e167efce8423 100644 --- a/kernel/compat.c +++ b/kernel/compat.c | |||
@@ -279,11 +279,6 @@ asmlinkage long compat_sys_setrlimit(unsigned int resource, | |||
279 | struct compat_rlimit __user *rlim) | 279 | struct compat_rlimit __user *rlim) |
280 | { | 280 | { |
281 | struct rlimit r; | 281 | struct rlimit r; |
282 | int ret; | ||
283 | mm_segment_t old_fs = get_fs (); | ||
284 | |||
285 | if (resource >= RLIM_NLIMITS) | ||
286 | return -EINVAL; | ||
287 | 282 | ||
288 | if (!access_ok(VERIFY_READ, rlim, sizeof(*rlim)) || | 283 | if (!access_ok(VERIFY_READ, rlim, sizeof(*rlim)) || |
289 | __get_user(r.rlim_cur, &rlim->rlim_cur) || | 284 | __get_user(r.rlim_cur, &rlim->rlim_cur) || |
@@ -294,10 +289,7 @@ asmlinkage long compat_sys_setrlimit(unsigned int resource, | |||
294 | r.rlim_cur = RLIM_INFINITY; | 289 | r.rlim_cur = RLIM_INFINITY; |
295 | if (r.rlim_max == COMPAT_RLIM_INFINITY) | 290 | if (r.rlim_max == COMPAT_RLIM_INFINITY) |
296 | r.rlim_max = RLIM_INFINITY; | 291 | r.rlim_max = RLIM_INFINITY; |
297 | set_fs(KERNEL_DS); | 292 | return do_prlimit(current, resource, &r, NULL); |
298 | ret = sys_setrlimit(resource, (struct rlimit __user *) &r); | ||
299 | set_fs(old_fs); | ||
300 | return ret; | ||
301 | } | 293 | } |
302 | 294 | ||
303 | #ifdef COMPAT_RLIM_OLD_INFINITY | 295 | #ifdef COMPAT_RLIM_OLD_INFINITY |
@@ -329,16 +321,13 @@ asmlinkage long compat_sys_old_getrlimit(unsigned int resource, | |||
329 | 321 | ||
330 | #endif | 322 | #endif |
331 | 323 | ||
332 | asmlinkage long compat_sys_getrlimit (unsigned int resource, | 324 | asmlinkage long compat_sys_getrlimit(unsigned int resource, |
333 | struct compat_rlimit __user *rlim) | 325 | struct compat_rlimit __user *rlim) |
334 | { | 326 | { |
335 | struct rlimit r; | 327 | struct rlimit r; |
336 | int ret; | 328 | int ret; |
337 | mm_segment_t old_fs = get_fs(); | ||
338 | 329 | ||
339 | set_fs(KERNEL_DS); | 330 | ret = do_prlimit(current, resource, NULL, &r); |
340 | ret = sys_getrlimit(resource, (struct rlimit __user *) &r); | ||
341 | set_fs(old_fs); | ||
342 | if (!ret) { | 331 | if (!ret) { |
343 | if (r.rlim_cur > COMPAT_RLIM_INFINITY) | 332 | if (r.rlim_cur > COMPAT_RLIM_INFINITY) |
344 | r.rlim_cur = COMPAT_RLIM_INFINITY; | 333 | r.rlim_cur = COMPAT_RLIM_INFINITY; |