Use f_lock to protect f_flags
Traditionally, changes to struct file->f_flags have been done under BKL protection, or with no protection at all. This patch causes all f_flags changes after file open/creation time to be done under protection of f_lock. This allows the removal of some BKL usage and fixes a number of longstanding (if microscopic) races. Reviewed-by: Christoph Hellwig <hch@lst.de> Cc: Al Viro <viro@ZenIV.linux.org.uk> Signed-off-by: Jonathan Corbet <corbet@lwn.net>
This commit is contained in:
@ -1156,10 +1156,12 @@ SYSCALL_DEFINE3(mq_getsetattr, mqd_t, mqdes,
|
||||
omqstat.mq_flags = filp->f_flags & O_NONBLOCK;
|
||||
if (u_mqstat) {
|
||||
audit_mq_getsetattr(mqdes, &mqstat);
|
||||
spin_lock(&filp->f_lock);
|
||||
if (mqstat.mq_flags & O_NONBLOCK)
|
||||
filp->f_flags |= O_NONBLOCK;
|
||||
else
|
||||
filp->f_flags &= ~O_NONBLOCK;
|
||||
spin_unlock(&filp->f_lock);
|
||||
|
||||
inode->i_atime = inode->i_ctime = CURRENT_TIME;
|
||||
}
|
||||
|
Reference in New Issue
Block a user