Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

[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>

authored by

Andrew Morton and committed by
Linus Torvalds
74910e6c 200a4552

+6 -6
+3 -3
fs/compat.c
··· 1757 1757 goto sticky; 1758 1758 rtv.tv_usec = jiffies_to_usecs(do_div((*(u64*)&timeout), HZ)); 1759 1759 rtv.tv_sec = timeout; 1760 - if (compat_timeval_compare(&rtv, &tv) < 0) 1760 + if (compat_timeval_compare(&rtv, &tv) >= 0) 1761 1761 rtv = tv; 1762 1762 if (copy_to_user(tvp, &rtv, sizeof(rtv))) { 1763 1763 sticky: ··· 1834 1834 rts.tv_sec++; 1835 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 1838 rts = ts; 1839 1839 copy_to_user(tsp, &rts, sizeof(rts)); 1840 1840 } ··· 1934 1934 rts.tv_nsec = jiffies_to_usecs(do_div((*(u64*)&timeout), HZ)) * 1935 1935 1000; 1936 1936 rts.tv_sec = timeout; 1937 - if (compat_timespec_compare(&rts, &ts) < 0) 1937 + if (compat_timespec_compare(&rts, &ts) >= 0) 1938 1938 rts = ts; 1939 1939 if (copy_to_user(tsp, &rts, sizeof(rts))) { 1940 1940 sticky:
+3 -3
fs/select.c
··· 404 404 goto sticky; 405 405 rtv.tv_usec = jiffies_to_usecs(do_div((*(u64*)&timeout), HZ)); 406 406 rtv.tv_sec = timeout; 407 - if (timeval_compare(&rtv, &tv) < 0) 407 + if (timeval_compare(&rtv, &tv) >= 0) 408 408 rtv = tv; 409 409 if (copy_to_user(tvp, &rtv, sizeof(rtv))) { 410 410 sticky: ··· 471 471 rts.tv_nsec = jiffies_to_usecs(do_div((*(u64*)&timeout), HZ)) * 472 472 1000; 473 473 rts.tv_sec = timeout; 474 - if (timespec_compare(&rts, &ts) < 0) 474 + if (timespec_compare(&rts, &ts) >= 0) 475 475 rts = ts; 476 476 if (copy_to_user(tsp, &rts, sizeof(rts))) { 477 477 sticky: ··· 775 775 rts.tv_nsec = jiffies_to_usecs(do_div((*(u64*)&timeout), HZ)) * 776 776 1000; 777 777 rts.tv_sec = timeout; 778 - if (timespec_compare(&rts, &ts) < 0) 778 + if (timespec_compare(&rts, &ts) >= 0) 779 779 rts = ts; 780 780 if (copy_to_user(tsp, &rts, sizeof(rts))) { 781 781 sticky: