diff options
author | Andrew Morton <akpm@osdl.org> | 2006-02-17 16:52:58 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2006-02-17 16:59:28 -0500 |
commit | 74910e6c7dc7471b286a883c1a7af70483ffd2ba (patch) | |
tree | 42314cf5882563b967284900a18e990b8a974a91 | |
parent | 200a4552af34b9a32e1f68a881a9ed5c7ec699cc (diff) |
[PATCH] select: time comparison fixes
I got all of these backwards. We want to return
min(input timeout, new timeout)
to userspace to prevent increasing the time-remaining value.
Thanks to Ernst Herzberg <earny@net4u.de> for reporting and diagnosing.
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
-rw-r--r-- | fs/compat.c | 6 | ||||
-rw-r--r-- | fs/select.c | 6 |
2 files changed, 6 insertions, 6 deletions
diff --git a/fs/compat.c b/fs/compat.c index a2ba78bdf7f7..5333c7d7427f 100644 --- a/fs/compat.c +++ b/fs/compat.c | |||
@@ -1757,7 +1757,7 @@ asmlinkage long compat_sys_select(int n, compat_ulong_t __user *inp, | |||
1757 | goto sticky; | 1757 | goto sticky; |
1758 | rtv.tv_usec = jiffies_to_usecs(do_div((*(u64*)&timeout), HZ)); | 1758 | rtv.tv_usec = jiffies_to_usecs(do_div((*(u64*)&timeout), HZ)); |
1759 | rtv.tv_sec = timeout; | 1759 | rtv.tv_sec = timeout; |
1760 | if (compat_timeval_compare(&rtv, &tv) < 0) | 1760 | if (compat_timeval_compare(&rtv, &tv) >= 0) |
1761 | rtv = tv; | 1761 | rtv = tv; |
1762 | if (copy_to_user(tvp, &rtv, sizeof(rtv))) { | 1762 | if (copy_to_user(tvp, &rtv, sizeof(rtv))) { |
1763 | sticky: | 1763 | sticky: |
@@ -1834,7 +1834,7 @@ asmlinkage long compat_sys_pselect7(int n, compat_ulong_t __user *inp, | |||
1834 | rts.tv_sec++; | 1834 | rts.tv_sec++; |
1835 | rts.tv_nsec -= NSEC_PER_SEC; | 1835 | rts.tv_nsec -= NSEC_PER_SEC; |
1836 | } | 1836 | } |
1837 | if (compat_timespec_compare(&rts, &ts) < 0) | 1837 | if (compat_timespec_compare(&rts, &ts) >= 0) |
1838 | rts = ts; | 1838 | rts = ts; |
1839 | copy_to_user(tsp, &rts, sizeof(rts)); | 1839 | copy_to_user(tsp, &rts, sizeof(rts)); |
1840 | } | 1840 | } |
@@ -1934,7 +1934,7 @@ asmlinkage long compat_sys_ppoll(struct pollfd __user *ufds, | |||
1934 | rts.tv_nsec = jiffies_to_usecs(do_div((*(u64*)&timeout), HZ)) * | 1934 | rts.tv_nsec = jiffies_to_usecs(do_div((*(u64*)&timeout), HZ)) * |
1935 | 1000; | 1935 | 1000; |
1936 | rts.tv_sec = timeout; | 1936 | rts.tv_sec = timeout; |
1937 | if (compat_timespec_compare(&rts, &ts) < 0) | 1937 | if (compat_timespec_compare(&rts, &ts) >= 0) |
1938 | rts = ts; | 1938 | rts = ts; |
1939 | if (copy_to_user(tsp, &rts, sizeof(rts))) { | 1939 | if (copy_to_user(tsp, &rts, sizeof(rts))) { |
1940 | sticky: | 1940 | sticky: |
diff --git a/fs/select.c b/fs/select.c index 6ce68a9c8976..1815a57d2255 100644 --- a/fs/select.c +++ b/fs/select.c | |||
@@ -404,7 +404,7 @@ asmlinkage long sys_select(int n, fd_set __user *inp, fd_set __user *outp, | |||
404 | goto sticky; | 404 | goto sticky; |
405 | rtv.tv_usec = jiffies_to_usecs(do_div((*(u64*)&timeout), HZ)); | 405 | rtv.tv_usec = jiffies_to_usecs(do_div((*(u64*)&timeout), HZ)); |
406 | rtv.tv_sec = timeout; | 406 | rtv.tv_sec = timeout; |
407 | if (timeval_compare(&rtv, &tv) < 0) | 407 | if (timeval_compare(&rtv, &tv) >= 0) |
408 | rtv = tv; | 408 | rtv = tv; |
409 | if (copy_to_user(tvp, &rtv, sizeof(rtv))) { | 409 | if (copy_to_user(tvp, &rtv, sizeof(rtv))) { |
410 | sticky: | 410 | sticky: |
@@ -471,7 +471,7 @@ asmlinkage long sys_pselect7(int n, fd_set __user *inp, fd_set __user *outp, | |||
471 | rts.tv_nsec = jiffies_to_usecs(do_div((*(u64*)&timeout), HZ)) * | 471 | rts.tv_nsec = jiffies_to_usecs(do_div((*(u64*)&timeout), HZ)) * |
472 | 1000; | 472 | 1000; |
473 | rts.tv_sec = timeout; | 473 | rts.tv_sec = timeout; |
474 | if (timespec_compare(&rts, &ts) < 0) | 474 | if (timespec_compare(&rts, &ts) >= 0) |
475 | rts = ts; | 475 | rts = ts; |
476 | if (copy_to_user(tsp, &rts, sizeof(rts))) { | 476 | if (copy_to_user(tsp, &rts, sizeof(rts))) { |
477 | sticky: | 477 | sticky: |
@@ -775,7 +775,7 @@ asmlinkage long sys_ppoll(struct pollfd __user *ufds, unsigned int nfds, | |||
775 | rts.tv_nsec = jiffies_to_usecs(do_div((*(u64*)&timeout), HZ)) * | 775 | rts.tv_nsec = jiffies_to_usecs(do_div((*(u64*)&timeout), HZ)) * |
776 | 1000; | 776 | 1000; |
777 | rts.tv_sec = timeout; | 777 | rts.tv_sec = timeout; |
778 | if (timespec_compare(&rts, &ts) < 0) | 778 | if (timespec_compare(&rts, &ts) >= 0) |
779 | rts = ts; | 779 | rts = ts; |
780 | if (copy_to_user(tsp, &rts, sizeof(rts))) { | 780 | if (copy_to_user(tsp, &rts, sizeof(rts))) { |
781 | sticky: | 781 | sticky: |