poll()/select() timeout behavior
PATCH 2/4 poll()/select() timeout behavior
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
fs/select.c +2 -4
@@ -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 ; }
Quoted 3 lines · Bill Rugolsky Jr.
This patch cause
select()to return EINVAL when passed an un-normalized timeval usec
Why? The current behaviour is to do the right thing when passed a tv_usec which is greater than 1,000,000. Why not retain that?