Messages in this thread | | | Date | Tue, 02 Dec 2008 01:15:08 +0100 | From | Andi Kleen <> | Subject | Re: BUG? "Call fasync() functions without the BKL" is racy |
| |
> Perhaps, we can add O_LOCK_FLAGS, then something like > > --- a/fs/fcntl.c > +++ b/fs/fcntl.c > @@ -175,6 +175,15 @@ static int setfl(int fd, struct file * f > if (error) > return error; > > + spin_lock(¤t->files->file_lock); > + if (!(filp->f_flags & O_LOCK_FLAGS)) > + filp->f_flags |= O_LOCK_FLAGS; > + else > + error = -EAGAIN; > + spin_unlock(¤t->files->file_lock); > + if (error) /* pretend ->f_flags was changed after us */ > + return 0; > + > if ((arg ^ filp->f_flags) & FASYNC) { > if (filp->f_op && filp->f_op->fasync) { > error = filp->f_op->fasync(fd, filp, (arg & FASYNC) != 0); > @@ -183,7 +192,8 @@ static int setfl(int fd, struct file * f > } > } > > - filp->f_flags = (arg & SETFL_MASK) | (filp->f_flags & ~SETFL_MASK); > + filp->f_flags = (arg & SETFL_MASK) | > + (filp->f_flags & ~(SETFL_MASK | O_LOCK_FLAGS)); > out: > return error; > } > > What do you think?
Looks reasonable. Just would need to make sure that O_LOCK_FLAGS doesn't leak out to user space.
-Andi
>
| |