[PATCH][2/4] poll()/select() timeout behavior

From: Bill Rugolsky Jr.
Date: Fri Feb 20 2004 - 16:09:15 EST


This patch cause select() to return EINVAL when passed an un-normalized
timeval usec, and fixes up the range check in preparation for the patch
that follows.

Please apply.

Bill Rugolsky

--- linux/fs/select.c 2004-02-20 14:22:53.641191351 -0500
+++ linux/fs/select.c 2004-02-20 14:23:01.891295743 -0500
@@ -291,8 +291,6 @@
* Update: ERESTARTSYS breaks at least the xview clock binary, so
* I'm trying ERESTARTNOHAND which restart only when you want to.
*/
-#define MAX_SELECT_SECONDS \
- ((unsigned long) (MAX_SCHEDULE_TIMEOUT / HZ)-1)

asmlinkage long
sys_select(int n, fd_set __user *inp, fd_set __user *outp, fd_set __user *exp, struct timeval __user *tvp)
@@ -312,10 +310,10 @@
goto out_nofds;

ret = -EINVAL;
- if (sec < 0 || usec < 0)
+ if (sec < 0 || usec < 0 || usec >= 1000000)
goto out_nofds;

- if ((unsigned long) sec < MAX_SELECT_SECONDS) {
+ if ((unsigned long) sec < (MAX_SCHEDULE_TIMEOUT-1) / HZ - 1) {
timeout = ROUND_UP(usec, 1000000/HZ);
timeout += sec * (unsigned long) HZ;
}
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/