lkml.org 
[lkml]   [2008]   [Dec]   [1]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    Date
    From
    SubjectRe: 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(&current->files->file_lock);
    > + if (!(filp->f_flags & O_LOCK_FLAGS))
    > + filp->f_flags |= O_LOCK_FLAGS;
    > + else
    > + error = -EAGAIN;
    > + spin_unlock(&current->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

    >


    \
     
     \ /
      Last update: 2008-12-02 01:17    [W:0.030 / U:0.864 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site