Commit 657732b7 authored by Anton Blanchard's avatar Anton Blanchard

ppc64: fix sys32_select race with max_fdset

parent 1ed3b323
...@@ -213,7 +213,7 @@ asmlinkage long sys32_readv(u32 fd, struct iovec32 *vector, u32 count) ...@@ -213,7 +213,7 @@ asmlinkage long sys32_readv(u32 fd, struct iovec32 *vector, u32 count)
goto bad_file; goto bad_file;
if (file->f_op && (file->f_mode & FMODE_READ) && if (file->f_op && (file->f_mode & FMODE_READ) &&
(file->f_op->readv || file->f_op->read)) (file->f_op->readv || file->f_op->read))
ret = do_readv_writev32(VERIFY_WRITE, file, vector, count); ret = do_readv_writev32(VERIFY_WRITE, file, vector, count);
fput(file); fput(file);
...@@ -238,8 +238,6 @@ asmlinkage long sys32_writev(u32 fd, struct iovec32 *vector, u32 count) ...@@ -238,8 +238,6 @@ asmlinkage long sys32_writev(u32 fd, struct iovec32 *vector, u32 count)
return ret; return ret;
} }
static inline int get_flock(struct flock *kfl, struct flock32 *ufl) static inline int get_flock(struct flock *kfl, struct flock32 *ufl)
{ {
int err; int err;
...@@ -656,8 +654,8 @@ asmlinkage long sys32_select(int n, u32 *inp, u32 *outp, u32 *exp, u32 tvp_x) ...@@ -656,8 +654,8 @@ asmlinkage long sys32_select(int n, u32 *inp, u32 *outp, u32 *exp, u32 tvp_x)
char *bits; char *bits;
unsigned long nn; unsigned long nn;
long timeout; long timeout;
int ret, size; int ret, size, max_fdset;
timeout = MAX_SCHEDULE_TIMEOUT; timeout = MAX_SCHEDULE_TIMEOUT;
if (tvp) { if (tvp) {
time_t sec, usec; time_t sec, usec;
...@@ -679,8 +677,11 @@ asmlinkage long sys32_select(int n, u32 *inp, u32 *outp, u32 *exp, u32 tvp_x) ...@@ -679,8 +677,11 @@ asmlinkage long sys32_select(int n, u32 *inp, u32 *outp, u32 *exp, u32 tvp_x)
ret = -EINVAL; ret = -EINVAL;
if (n < 0) if (n < 0)
goto out_nofds; goto out_nofds;
if (n > current->files->max_fdset)
n = current->files->max_fdset; /* max_fdset can increase, so grab it once to avoid race */
max_fdset = current->files->max_fdset;
if (n > max_fdset)
n = max_fdset;
/* /*
* We need 6 bitmaps (in/out/ex for both incoming and outgoing), * We need 6 bitmaps (in/out/ex for both incoming and outgoing),
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment