diff options
author | Fabian Frederick <fabf@skynet.be> | 2015-02-17 16:45:31 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2015-02-17 17:34:51 -0500 |
commit | ed3ad79f87f31beed64778af0b29aff3074f700e (patch) | |
tree | 6bf46242e32c441b0e16ff95295507c0323ee833 /fs/ufs | |
parent | 61da3ae241f4382e30beb6de06c4dacada37f520 (diff) |
fs/ufs/super.c: fix potential race condition
Let locking subsystem decide on mutex management. As reported by Andrew
Morton this patch fixes a bug:
: lock_ufs() is assuming that on non-preempt uniprocessor, the calling
: code will run atomically up to the matching unlock_ufs().
:
: But that isn't true. The very first site I looked at (ufs_frag_map)
: does sb_bread() under lock_ufs(). And sb_bread() will call schedule(),
: very commonly.
:
: The ->mutex_owner stuff is a bit hacky but should work OK.
Signed-off-by: Fabian Frederick <fabf@skynet.be>
Cc: Evgeniy Dushistov <dushistov@mail.ru>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs/ufs')
-rw-r--r-- | fs/ufs/super.c | 4 |
1 files changed, 0 insertions, 4 deletions
diff --git a/fs/ufs/super.c b/fs/ufs/super.c index e515e99a02f9..8092d3759a5e 100644 --- a/fs/ufs/super.c +++ b/fs/ufs/super.c | |||
@@ -95,22 +95,18 @@ | |||
95 | 95 | ||
96 | void lock_ufs(struct super_block *sb) | 96 | void lock_ufs(struct super_block *sb) |
97 | { | 97 | { |
98 | #if defined(CONFIG_SMP) || defined (CONFIG_PREEMPT) | ||
99 | struct ufs_sb_info *sbi = UFS_SB(sb); | 98 | struct ufs_sb_info *sbi = UFS_SB(sb); |
100 | 99 | ||
101 | mutex_lock(&sbi->mutex); | 100 | mutex_lock(&sbi->mutex); |
102 | sbi->mutex_owner = current; | 101 | sbi->mutex_owner = current; |
103 | #endif | ||
104 | } | 102 | } |
105 | 103 | ||
106 | void unlock_ufs(struct super_block *sb) | 104 | void unlock_ufs(struct super_block *sb) |
107 | { | 105 | { |
108 | #if defined(CONFIG_SMP) || defined (CONFIG_PREEMPT) | ||
109 | struct ufs_sb_info *sbi = UFS_SB(sb); | 106 | struct ufs_sb_info *sbi = UFS_SB(sb); |
110 | 107 | ||
111 | sbi->mutex_owner = NULL; | 108 | sbi->mutex_owner = NULL; |
112 | mutex_unlock(&sbi->mutex); | 109 | mutex_unlock(&sbi->mutex); |
113 | #endif | ||
114 | } | 110 | } |
115 | 111 | ||
116 | static struct inode *ufs_nfs_get_inode(struct super_block *sb, u64 ino, u32 generation) | 112 | static struct inode *ufs_nfs_get_inode(struct super_block *sb, u64 ino, u32 generation) |