diff options
Diffstat (limited to 'fs/compat.c')
-rw-r--r-- | fs/compat.c | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/fs/compat.c b/fs/compat.c index 7b21b0a82596..4db6216e5266 100644 --- a/fs/compat.c +++ b/fs/compat.c | |||
@@ -1544,9 +1544,10 @@ int compat_core_sys_select(int n, compat_ulong_t __user *inp, | |||
1544 | compat_ulong_t __user *outp, compat_ulong_t __user *exp, s64 *timeout) | 1544 | compat_ulong_t __user *outp, compat_ulong_t __user *exp, s64 *timeout) |
1545 | { | 1545 | { |
1546 | fd_set_bits fds; | 1546 | fd_set_bits fds; |
1547 | char *bits; | 1547 | void *bits; |
1548 | int size, max_fds, ret = -EINVAL; | 1548 | int size, max_fds, ret = -EINVAL; |
1549 | struct fdtable *fdt; | 1549 | struct fdtable *fdt; |
1550 | long stack_fds[SELECT_STACK_ALLOC/sizeof(long)]; | ||
1550 | 1551 | ||
1551 | if (n < 0) | 1552 | if (n < 0) |
1552 | goto out_nofds; | 1553 | goto out_nofds; |
@@ -1564,11 +1565,14 @@ int compat_core_sys_select(int n, compat_ulong_t __user *inp, | |||
1564 | * since we used fdset we need to allocate memory in units of | 1565 | * since we used fdset we need to allocate memory in units of |
1565 | * long-words. | 1566 | * long-words. |
1566 | */ | 1567 | */ |
1567 | ret = -ENOMEM; | ||
1568 | size = FDS_BYTES(n); | 1568 | size = FDS_BYTES(n); |
1569 | bits = kmalloc(6 * size, GFP_KERNEL); | 1569 | bits = stack_fds; |
1570 | if (!bits) | 1570 | if (size > sizeof(stack_fds) / 6) { |
1571 | goto out_nofds; | 1571 | bits = kmalloc(6 * size, GFP_KERNEL); |
1572 | ret = -ENOMEM; | ||
1573 | if (!bits) | ||
1574 | goto out_nofds; | ||
1575 | } | ||
1572 | fds.in = (unsigned long *) bits; | 1576 | fds.in = (unsigned long *) bits; |
1573 | fds.out = (unsigned long *) (bits + size); | 1577 | fds.out = (unsigned long *) (bits + size); |
1574 | fds.ex = (unsigned long *) (bits + 2*size); | 1578 | fds.ex = (unsigned long *) (bits + 2*size); |
@@ -1600,7 +1604,8 @@ int compat_core_sys_select(int n, compat_ulong_t __user *inp, | |||
1600 | compat_set_fd_set(n, exp, fds.res_ex)) | 1604 | compat_set_fd_set(n, exp, fds.res_ex)) |
1601 | ret = -EFAULT; | 1605 | ret = -EFAULT; |
1602 | out: | 1606 | out: |
1603 | kfree(bits); | 1607 | if (bits != stack_fds) |
1608 | kfree(bits); | ||
1604 | out_nofds: | 1609 | out_nofds: |
1605 | return ret; | 1610 | return ret; |
1606 | } | 1611 | } |
@@ -2230,21 +2235,16 @@ asmlinkage long compat_sys_signalfd(int ufd, | |||
2230 | asmlinkage long compat_sys_timerfd(int ufd, int clockid, int flags, | 2235 | asmlinkage long compat_sys_timerfd(int ufd, int clockid, int flags, |
2231 | const struct compat_itimerspec __user *utmr) | 2236 | const struct compat_itimerspec __user *utmr) |
2232 | { | 2237 | { |
2233 | long res; | ||
2234 | struct itimerspec t; | 2238 | struct itimerspec t; |
2235 | struct itimerspec __user *ut; | 2239 | struct itimerspec __user *ut; |
2236 | 2240 | ||
2237 | res = -EFAULT; | ||
2238 | if (get_compat_itimerspec(&t, utmr)) | 2241 | if (get_compat_itimerspec(&t, utmr)) |
2239 | goto err_exit; | 2242 | return -EFAULT; |
2240 | ut = compat_alloc_user_space(sizeof(*ut)); | 2243 | ut = compat_alloc_user_space(sizeof(*ut)); |
2241 | if (copy_to_user(ut, &t, sizeof(t)) ) | 2244 | if (copy_to_user(ut, &t, sizeof(t))) |
2242 | goto err_exit; | 2245 | return -EFAULT; |
2243 | 2246 | ||
2244 | res = sys_timerfd(ufd, clockid, flags, ut); | 2247 | return sys_timerfd(ufd, clockid, flags, ut); |
2245 | err_exit: | ||
2246 | return res; | ||
2247 | } | 2248 | } |
2248 | 2249 | ||
2249 | #endif /* CONFIG_TIMERFD */ | 2250 | #endif /* CONFIG_TIMERFD */ |
2250 | |||