提交 74910e6c 编写于 作者: A Andrew Morton 提交者: Linus Torvalds

[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: NAndrew Morton <akpm@osdl.org>
Signed-off-by: NLinus Torvalds <torvalds@osdl.org>
上级 200a4552
...@@ -1757,7 +1757,7 @@ asmlinkage long compat_sys_select(int n, compat_ulong_t __user *inp, ...@@ -1757,7 +1757,7 @@ asmlinkage long compat_sys_select(int n, compat_ulong_t __user *inp,
goto sticky; goto sticky;
rtv.tv_usec = jiffies_to_usecs(do_div((*(u64*)&timeout), HZ)); rtv.tv_usec = jiffies_to_usecs(do_div((*(u64*)&timeout), HZ));
rtv.tv_sec = timeout; rtv.tv_sec = timeout;
if (compat_timeval_compare(&rtv, &tv) < 0) if (compat_timeval_compare(&rtv, &tv) >= 0)
rtv = tv; rtv = tv;
if (copy_to_user(tvp, &rtv, sizeof(rtv))) { if (copy_to_user(tvp, &rtv, sizeof(rtv))) {
sticky: sticky:
...@@ -1834,7 +1834,7 @@ asmlinkage long compat_sys_pselect7(int n, compat_ulong_t __user *inp, ...@@ -1834,7 +1834,7 @@ asmlinkage long compat_sys_pselect7(int n, compat_ulong_t __user *inp,
rts.tv_sec++; rts.tv_sec++;
rts.tv_nsec -= NSEC_PER_SEC; rts.tv_nsec -= NSEC_PER_SEC;
} }
if (compat_timespec_compare(&rts, &ts) < 0) if (compat_timespec_compare(&rts, &ts) >= 0)
rts = ts; rts = ts;
copy_to_user(tsp, &rts, sizeof(rts)); copy_to_user(tsp, &rts, sizeof(rts));
} }
...@@ -1934,7 +1934,7 @@ asmlinkage long compat_sys_ppoll(struct pollfd __user *ufds, ...@@ -1934,7 +1934,7 @@ asmlinkage long compat_sys_ppoll(struct pollfd __user *ufds,
rts.tv_nsec = jiffies_to_usecs(do_div((*(u64*)&timeout), HZ)) * rts.tv_nsec = jiffies_to_usecs(do_div((*(u64*)&timeout), HZ)) *
1000; 1000;
rts.tv_sec = timeout; rts.tv_sec = timeout;
if (compat_timespec_compare(&rts, &ts) < 0) if (compat_timespec_compare(&rts, &ts) >= 0)
rts = ts; rts = ts;
if (copy_to_user(tsp, &rts, sizeof(rts))) { if (copy_to_user(tsp, &rts, sizeof(rts))) {
sticky: sticky:
......
...@@ -404,7 +404,7 @@ asmlinkage long sys_select(int n, fd_set __user *inp, fd_set __user *outp, ...@@ -404,7 +404,7 @@ asmlinkage long sys_select(int n, fd_set __user *inp, fd_set __user *outp,
goto sticky; goto sticky;
rtv.tv_usec = jiffies_to_usecs(do_div((*(u64*)&timeout), HZ)); rtv.tv_usec = jiffies_to_usecs(do_div((*(u64*)&timeout), HZ));
rtv.tv_sec = timeout; rtv.tv_sec = timeout;
if (timeval_compare(&rtv, &tv) < 0) if (timeval_compare(&rtv, &tv) >= 0)
rtv = tv; rtv = tv;
if (copy_to_user(tvp, &rtv, sizeof(rtv))) { if (copy_to_user(tvp, &rtv, sizeof(rtv))) {
sticky: sticky:
...@@ -471,7 +471,7 @@ asmlinkage long sys_pselect7(int n, fd_set __user *inp, fd_set __user *outp, ...@@ -471,7 +471,7 @@ asmlinkage long sys_pselect7(int n, fd_set __user *inp, fd_set __user *outp,
rts.tv_nsec = jiffies_to_usecs(do_div((*(u64*)&timeout), HZ)) * rts.tv_nsec = jiffies_to_usecs(do_div((*(u64*)&timeout), HZ)) *
1000; 1000;
rts.tv_sec = timeout; rts.tv_sec = timeout;
if (timespec_compare(&rts, &ts) < 0) if (timespec_compare(&rts, &ts) >= 0)
rts = ts; rts = ts;
if (copy_to_user(tsp, &rts, sizeof(rts))) { if (copy_to_user(tsp, &rts, sizeof(rts))) {
sticky: sticky:
...@@ -775,7 +775,7 @@ asmlinkage long sys_ppoll(struct pollfd __user *ufds, unsigned int nfds, ...@@ -775,7 +775,7 @@ asmlinkage long sys_ppoll(struct pollfd __user *ufds, unsigned int nfds,
rts.tv_nsec = jiffies_to_usecs(do_div((*(u64*)&timeout), HZ)) * rts.tv_nsec = jiffies_to_usecs(do_div((*(u64*)&timeout), HZ)) *
1000; 1000;
rts.tv_sec = timeout; rts.tv_sec = timeout;
if (timespec_compare(&rts, &ts) < 0) if (timespec_compare(&rts, &ts) >= 0)
rts = ts; rts = ts;
if (copy_to_user(tsp, &rts, sizeof(rts))) { if (copy_to_user(tsp, &rts, sizeof(rts))) {
sticky: sticky:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册