aboutsummaryrefslogtreecommitdiffstats
path: root/fs/file_table.c
diff options
context:
space:
mode:
authorWu Fengguang <fengguang.wu@intel.com>2010-03-05 16:42:01 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2010-03-06 14:26:25 -0500
commit42e49608683ab25fbbbf9c40edb944601e543882 (patch)
tree5cc8beee91f235cdaf6be986f90275e04137c2bc /fs/file_table.c
parent85f1fb72fa76eabc4481dc79f42d2b011df54762 (diff)
vfs: take f_lock on modifying f_mode after open time
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> Cc: <stable@kernel.org> [2.6.33.x] Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs/file_table.c')
-rw-r--r--fs/file_table.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/fs/file_table.c b/fs/file_table.c
index b98404b54383..32d12b78bac8 100644
--- a/fs/file_table.c
+++ b/fs/file_table.c
@@ -393,7 +393,9 @@ retry:
393 continue; 393 continue;
394 if (!(f->f_mode & FMODE_WRITE)) 394 if (!(f->f_mode & FMODE_WRITE))
395 continue; 395 continue;
396 spin_lock(&f->f_lock);
396 f->f_mode &= ~FMODE_WRITE; 397 f->f_mode &= ~FMODE_WRITE;
398 spin_unlock(&f->f_lock);
397 if (file_check_writeable(f) != 0) 399 if (file_check_writeable(f) != 0)
398 continue; 400 continue;
399 file_release_write(f); 401 file_release_write(f);