diff options
author | Wu Fengguang <fengguang.wu@intel.com> | 2010-03-05 13:42:01 -0800 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2010-03-15 08:49:37 -0700 |
commit | d9ee70916b2f1bb17ebdf993e591d2fd84e7e775 (patch) | |
tree | 83bc9b3f9b824dbef084c81173f50b16ade198b5 /fs/file_table.c | |
parent | 6e8b0197a96edcf0c650b508f2906e0245f73dee (diff) |
vfs: take f_lock on modifying f_mode after open time
commit 42e49608683ab25fbbbf9c40edb944601e543882 upstream.
We'll introduce FMODE_RANDOM which will be runtime modified. So protect
all runtime modification to f_mode with f_lock to avoid races.
Signed-off-by: Wu Fengguang <fengguang.wu@intel.com>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: Christoph Hellwig <hch@infradead.org>
Cc: Trond Myklebust <Trond.Myklebust@netapp.com>
Cc: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'fs/file_table.c')
-rw-r--r-- | fs/file_table.c | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/fs/file_table.c b/fs/file_table.c index 8eb44042e009..666c7ce1fc41 100644 --- a/fs/file_table.c +++ b/fs/file_table.c @@ -420,7 +420,9 @@ retry: continue; if (!(f->f_mode & FMODE_WRITE)) continue; + spin_lock(&f->f_lock); f->f_mode &= ~FMODE_WRITE; + spin_unlock(&f->f_lock); if (file_check_writeable(f) != 0) continue; file_release_write(f); |