summaryrefslogtreecommitdiffstats
path: root/fs/select.c
diff options
context:
space:
mode:
authorArjan van de Ven <arjan@linux.intel.com>2008-10-25 21:41:41 +0200
committerLinus Torvalds <torvalds@linux-foundation.org>2008-10-26 19:22:08 +0100
commit4d36a9e65d4966b433b2f3424d9457468bc80e00 (patch)
tree8c7b8e64ae40769a3f9f948491987ba93698ee3a /fs/select.c
parentwireless: fix regression caused by regulatory config option (diff)
downloadlinux-4d36a9e65d4966b433b2f3424d9457468bc80e00.tar.xz
linux-4d36a9e65d4966b433b2f3424d9457468bc80e00.zip
select: deal with math overflow from borderline valid userland data
Some userland apps seem to pass in a "0" for the seconds, and several seconds worth of usecs to select(). The old kernels accepted this just fine, so the new kernels must too. However, due to the upscaling of the microseconds to nanoseconds we had some cases where we got math overflow, and depending on the GCC version (due to inlining decisions) that actually resulted in an -EINVAL return. This patch fixes this by adding the excess microseconds to the seconds field. Also with thanks to Marcin Slusarz for spotting some implementation bugs in the diagnostics patches. Reported-by: Carlos R. Mafra <crmafra2@gmail.com> Signed-off-by: Arjan van de Ven <arjan@linux.intel.com> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs/select.c')
-rw-r--r--fs/select.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/fs/select.c b/fs/select.c
index 448e44001286..87df51eadcf2 100644
--- a/fs/select.c
+++ b/fs/select.c
@@ -519,8 +519,9 @@ asmlinkage long sys_select(int n, fd_set __user *inp, fd_set __user *outp,
return -EFAULT;
to = &end_time;
- if (poll_select_set_timeout(to, tv.tv_sec,
- tv.tv_usec * NSEC_PER_USEC))
+ if (poll_select_set_timeout(to,
+ tv.tv_sec + (tv.tv_usec / USEC_PER_SEC),
+ (tv.tv_usec % USEC_PER_SEC) * NSEC_PER_USEC))
return -EINVAL;
}