aboutsummaryrefslogtreecommitdiffstats
path: root/fs/select.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/select.c')
-rw-r--r--fs/select.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/fs/select.c b/fs/select.c
index b80e7eb0ac0d..2e56325c73c4 100644
--- a/fs/select.c
+++ b/fs/select.c
@@ -132,11 +132,13 @@ static int max_select_fd(unsigned long n, fd_set_bits *fds)
132 unsigned long *open_fds; 132 unsigned long *open_fds;
133 unsigned long set; 133 unsigned long set;
134 int max; 134 int max;
135 struct fdtable *fdt;
135 136
136 /* handle last in-complete long-word first */ 137 /* handle last in-complete long-word first */
137 set = ~(~0UL << (n & (__NFDBITS-1))); 138 set = ~(~0UL << (n & (__NFDBITS-1)));
138 n /= __NFDBITS; 139 n /= __NFDBITS;
139 open_fds = current->files->open_fds->fds_bits+n; 140 fdt = files_fdtable(current->files);
141 open_fds = fdt->open_fds->fds_bits+n;
140 max = 0; 142 max = 0;
141 if (set) { 143 if (set) {
142 set &= BITS(fds, n); 144 set &= BITS(fds, n);
@@ -299,6 +301,7 @@ sys_select(int n, fd_set __user *inp, fd_set __user *outp, fd_set __user *exp, s
299 char *bits; 301 char *bits;
300 long timeout; 302 long timeout;
301 int ret, size, max_fdset; 303 int ret, size, max_fdset;
304 struct fdtable *fdt;
302 305
303 timeout = MAX_SCHEDULE_TIMEOUT; 306 timeout = MAX_SCHEDULE_TIMEOUT;
304 if (tvp) { 307 if (tvp) {
@@ -326,7 +329,8 @@ sys_select(int n, fd_set __user *inp, fd_set __user *outp, fd_set __user *exp, s
326 goto out_nofds; 329 goto out_nofds;
327 330
328 /* max_fdset can increase, so grab it once to avoid race */ 331 /* max_fdset can increase, so grab it once to avoid race */
329 max_fdset = current->files->max_fdset; 332 fdt = files_fdtable(current->files);
333 max_fdset = fdt->max_fdset;
330 if (n > max_fdset) 334 if (n > max_fdset)
331 n = max_fdset; 335 n = max_fdset;
332 336
@@ -464,9 +468,11 @@ asmlinkage long sys_poll(struct pollfd __user * ufds, unsigned int nfds, long ti
464 unsigned int i; 468 unsigned int i;
465 struct poll_list *head; 469 struct poll_list *head;
466 struct poll_list *walk; 470 struct poll_list *walk;
471 struct fdtable *fdt;
467 472
468 /* Do a sanity check on nfds ... */ 473 /* Do a sanity check on nfds ... */
469 if (nfds > current->files->max_fdset && nfds > OPEN_MAX) 474 fdt = files_fdtable(current->files);
475 if (nfds > fdt->max_fdset && nfds > OPEN_MAX)
470 return -EINVAL; 476 return -EINVAL;
471 477
472 if (timeout) { 478 if (timeout) {