aboutsummaryrefslogtreecommitdiffstats
path: root/fs/select.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/select.c')
-rw-r--r--fs/select.c15
1 files changed, 6 insertions, 9 deletions
diff --git a/fs/select.c b/fs/select.c
index 9c4f0f2604f1..dcbc1112b7ec 100644
--- a/fs/select.c
+++ b/fs/select.c
@@ -658,8 +658,6 @@ int do_sys_poll(struct pollfd __user *ufds, unsigned int nfds, s64 *timeout)
658 unsigned int i; 658 unsigned int i;
659 struct poll_list *head; 659 struct poll_list *head;
660 struct poll_list *walk; 660 struct poll_list *walk;
661 struct fdtable *fdt;
662 int max_fdset;
663 /* Allocate small arguments on the stack to save memory and be 661 /* Allocate small arguments on the stack to save memory and be
664 faster - use long to make sure the buffer is aligned properly 662 faster - use long to make sure the buffer is aligned properly
665 on 64 bit archs to avoid unaligned access */ 663 on 64 bit archs to avoid unaligned access */
@@ -667,11 +665,7 @@ int do_sys_poll(struct pollfd __user *ufds, unsigned int nfds, s64 *timeout)
667 struct poll_list *stack_pp = NULL; 665 struct poll_list *stack_pp = NULL;
668 666
669 /* Do a sanity check on nfds ... */ 667 /* Do a sanity check on nfds ... */
670 rcu_read_lock(); 668 if (nfds > current->signal->rlim[RLIMIT_NOFILE].rlim_cur)
671 fdt = files_fdtable(current->files);
672 max_fdset = fdt->max_fdset;
673 rcu_read_unlock();
674 if (nfds > max_fdset && nfds > OPEN_MAX)
675 return -EINVAL; 669 return -EINVAL;
676 670
677 poll_initwait(&table); 671 poll_initwait(&table);
@@ -746,9 +740,9 @@ out_fds:
746asmlinkage long sys_poll(struct pollfd __user *ufds, unsigned int nfds, 740asmlinkage long sys_poll(struct pollfd __user *ufds, unsigned int nfds,
747 long timeout_msecs) 741 long timeout_msecs)
748{ 742{
749 s64 timeout_jiffies = 0; 743 s64 timeout_jiffies;
750 744
751 if (timeout_msecs) { 745 if (timeout_msecs > 0) {
752#if HZ > 1000 746#if HZ > 1000
753 /* We can only overflow if HZ > 1000 */ 747 /* We can only overflow if HZ > 1000 */
754 if (timeout_msecs / 1000 > (s64)0x7fffffffffffffffULL / (s64)HZ) 748 if (timeout_msecs / 1000 > (s64)0x7fffffffffffffffULL / (s64)HZ)
@@ -756,6 +750,9 @@ asmlinkage long sys_poll(struct pollfd __user *ufds, unsigned int nfds,
756 else 750 else
757#endif 751#endif
758 timeout_jiffies = msecs_to_jiffies(timeout_msecs); 752 timeout_jiffies = msecs_to_jiffies(timeout_msecs);
753 } else {
754 /* Infinite (< 0) or no (0) timeout */
755 timeout_jiffies = timeout_msecs;
759 } 756 }
760 757
761 return do_sys_poll(ufds, nfds, &timeout_jiffies); 758 return do_sys_poll(ufds, nfds, &timeout_jiffies);