lkml.org 
[lkml]   [2015]   [Feb]   [3]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 1/1 linux-next] fs/ufs/super.c: fix potential race condition
Date
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.
"

Cc: Evgeniy Dushistov <dushistov@mail.ru>
Cc: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Fabian Frederick <fabf@skynet.be>
---
fs/ufs/super.c | 4 ----
1 file changed, 4 deletions(-)

diff --git a/fs/ufs/super.c b/fs/ufs/super.c
index e515e99..8092d37 100644
--- a/fs/ufs/super.c
+++ b/fs/ufs/super.c
@@ -95,22 +95,18 @@

void lock_ufs(struct super_block *sb)
{
-#if defined(CONFIG_SMP) || defined (CONFIG_PREEMPT)
struct ufs_sb_info *sbi = UFS_SB(sb);

mutex_lock(&sbi->mutex);
sbi->mutex_owner = current;
-#endif
}

void unlock_ufs(struct super_block *sb)
{
-#if defined(CONFIG_SMP) || defined (CONFIG_PREEMPT)
struct ufs_sb_info *sbi = UFS_SB(sb);

sbi->mutex_owner = NULL;
mutex_unlock(&sbi->mutex);
-#endif
}

static struct inode *ufs_nfs_get_inode(struct super_block *sb, u64 ino, u32 generation)
--
2.1.0


\
 
 \ /
  Last update: 2015-02-03 18:21    [W:0.132 / U:0.144 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site