Skip to content

Commit

Permalink
fs/ufs/super.c: fix potential race condition
Browse files Browse the repository at this point in the history
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 <[email protected]>
Cc: Evgeniy Dushistov <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
Fabian Frederick authored and torvalds committed Feb 17, 2015
1 parent 61da3ae commit ed3ad79
Showing 1 changed file with 0 additions and 4 deletions.
4 changes: 0 additions & 4 deletions fs/ufs/super.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit ed3ad79

Please sign in to comment.