The patch titled
poll(2) system call does not handle large timeout values correctly.
has been added to the -mm tree. Its filename is
poll2-system-call-does-not-handle-large-timeout-values-correctly.patch
Patches currently in -mm which might be from [EMAIL PROTECTED] are
poll2-system-call-does-not-handle-large-timeout-values-correctly.patch
From: <[EMAIL PROTECTED]>
From: [EMAIL PROTECTED]
http://bugzilla.kernel.org/show_bug.cgi?id=5132
The poll system call converts the timeout parameter from milliseconds to
internal (HZ based) clock ticks. The conditional contstruct to avoid the
signed long overflow assigns a too large maximum value in case of potential
overflow:
if (timeout) {
/* Careful about overflow in the intermediate values */
if ((unsigned long) timeout < MAX_SCHEDULE_TIMEOUT / HZ)
timeout = (unsigned long)(timeout*HZ+999)/1000+1;
else /* Negative or overflow */
timeout = MAX_SCHEDULE_TIMEOUT;
}
For timeout values < (MAX_SCHEDULE_TIMEOUT / HZ) (no overflow) the
conversion is correct and poll handles the timeout as expected. For values
above this limit, the timeout is set to MAX_SCHEDULE_TIMEOUT (defined to
LONG_MAX, i.e. 2147483647 on 32bit machines) instead of
(MAX_SCHEDULE_TIMEOUT / HZ). As a consequence, with HZ being 1000 (on an
i386 platform) timeouts longer than approximately 35 minutes and 47 seconds
are ``rounded up'' to 24 days, 20 hrs, 31 min, 23 seconds. (We did not
wait for this timeout to complete...)
Steps to reproduce:
Run the following program...
#include <stdlib.h>
#include <stdio.h>
#include <sys/poll.h>
int main(int argc, char **argv)
{
time_t stime = time(NULL);
time_t etime;
int timeout = (argc == 2)? atoi(argv[1]): 2200*1000;
struct pollfd ufds;
memset(&ufds, 0, sizeof(ufds));
(void) poll(&ufds, 0, timeout);
etime = time(NULL);
printf("etime - stime = %d\n", etime - stime);
return 0;
}
With one numeric argument less than 2147483 the program exits correctly
after that number of milliseconds, with no argument or one above that limit
it takes ``somewhat'' longer :-)
Signed-off-by: Andrew Morton <[EMAIL PROTECTED]>
---
fs/select.c | 2 +-
1 files changed, 1 insertion(+), 1 deletion(-)
diff -puN
fs/select.c~poll2-system-call-does-not-handle-large-timeout-values-correctly
fs/select.c
---
devel/fs/select.c~poll2-system-call-does-not-handle-large-timeout-values-correctly
2005-08-26 10:48:08.000000000 -0700
+++ devel-akpm/fs/select.c 2005-08-26 10:48:08.000000000 -0700
@@ -474,7 +474,7 @@ asmlinkage long sys_poll(struct pollfd _
if ((unsigned long) timeout < MAX_SCHEDULE_TIMEOUT / HZ)
timeout = (unsigned long)(timeout*HZ+999)/1000+1;
else /* Negative or overflow */
- timeout = MAX_SCHEDULE_TIMEOUT;
+ timeout = MAX_SCHEDULE_TIMEOUT / HZ;
}
poll_initwait(&table);
_
-
To unsubscribe from this list: send the line "unsubscribe mm-commits" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at http://vger.kernel.org/majordomo-info.html