Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S966036AbbBCRDm (ORCPT ); Tue, 3 Feb 2015 12:03:42 -0500 Received: from mailrelay111.isp.belgacom.be ([195.238.20.138]:33318 "EHLO mailrelay111.isp.belgacom.be" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965602AbbBCRDk (ORCPT ); Tue, 3 Feb 2015 12:03:40 -0500 X-Belgacom-Dynamic: yes X-Cloudmark-SP-Filtered: true X-Cloudmark-SP-Result: v=1.1 cv=o+amxqHLy7+dd/uQ+LUqZyoNQm/aGJUjZTPtnbq5Ku0= c=1 sm=2 a=RgBw9RmQAAAA:8 a=Z4Rwk6OoAAAA:8 a=W3c4xNXbuUAXmOtq7ysA:9 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A2DrEQBg/tBU/xvP9FFagwaBK7I6BQEBAQEBAQUBdpc5gR9EAQEBAQF9hDovI4EaN4gZAxUBxkiKXhWGD4YEiSMBAU8dhBMFjmuJR5JfIoFFATwcgVE9MYELgTcBAQE From: Fabian Frederick To: linux-kernel@vger.kernel.org Cc: Fabian Frederick , Evgeniy Dushistov , Andrew Morton Subject: [PATCH 1/1 linux-next] fs/ufs/super.c: fix potential race condition Date: Tue, 3 Feb 2015 18:03:34 +0100 Message-Id: <1422983014-4090-1-git-send-email-fabf@skynet.be> X-Mailer: git-send-email 2.1.0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1550 Lines: 56 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 Cc: Andrew Morton Signed-off-by: Fabian Frederick --- 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 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/