From: Andi Kleen <ak@linux.intel.com>
To: Oleg Nesterov <oleg@redhat.com>
Cc: Jonathan Corbet <corbet@lwn.net>,
Al Viro <viro@zeniv.linux.org.uk>,
Vitaly Mayatskikh <vmayatsk@redhat.com>,
linux-kernel@vger.kernel.org
Subject: Re: BUG? "Call fasync() functions without the BKL" is racy
Date: Tue, 02 Dec 2008 01:15:08 +0100 [thread overview]
Message-ID: <49347E0C.10106@linux.intel.com> (raw)
In-Reply-To: <20081201191555.GA21385@redhat.com>
> 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
>
prev parent reply other threads:[~2008-12-02 0:15 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-11-28 19:25 BUG? "Call fasync() functions without the BKL" is racy Oleg Nesterov
2008-12-01 11:34 ` Andi Kleen
2008-12-01 19:15 ` Oleg Nesterov
2008-12-01 19:34 ` Jonathan Corbet
2008-12-02 12:29 ` Oleg Nesterov
2008-12-02 16:30 ` Andi Kleen
2008-12-03 19:06 ` Oleg Nesterov
2008-12-03 21:21 ` Andi Kleen
2008-12-03 22:45 ` Jonathan Corbet
2008-12-04 14:34 ` Oleg Nesterov
2008-12-05 23:12 ` [PATCH 2.6.28] Fix FASYNC race Jonathan Corbet
2008-12-02 0:15 ` Andi Kleen [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=49347E0C.10106@linux.intel.com \
--to=ak@linux.intel.com \
--cc=corbet@lwn.net \
--cc=linux-kernel@vger.kernel.org \
--cc=oleg@redhat.com \
--cc=viro@zeniv.linux.org.uk \
--cc=vmayatsk@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox