lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Sat, 23 Oct 2010 13:37:33 +0200
From:	Alessio Igor Bogani <abogani@...ware.it>
To:	Arnd Bergmann <arnd@...db.de>
Cc:	Tim Bird <tim.bird@...sony.com>,
	LKML <linux-kernel@...r.kernel.org>,
	Alessio Igor Bogani <abogani@...ware.it>
Subject: [PATCH 6/6] udf: Replace BKL

The call to udf_truncate() is moved into i_mutex protected section.
So we can remove BKL from itself.

Replace BKL with i_mutex in udf_evict_inode() and in udf_block_map().

Remove BKL from udf_get_block() because alla code path calls that function
with i_mutex held.

In udf_write_inode() protect udf_update_inode() call only if it isn't called
with i_mutex already held.

This work was supported by a hardware donation from the CE Linux Forum.

Signed-off-by: Alessio Igor Bogani <abogani@...ware.it>
---
 fs/udf/inode.c |   27 ++++++++++++---------------
 1 files changed, 12 insertions(+), 15 deletions(-)

diff --git a/fs/udf/inode.c b/fs/udf/inode.c
index fc48f37..ecc8b61 100644
--- a/fs/udf/inode.c
+++ b/fs/udf/inode.c
@@ -31,7 +31,7 @@
 
 #include "udfdecl.h"
 #include <linux/mm.h>
-#include <linux/smp_lock.h>
+#include <linux/mutex.h>
 #include <linux/module.h>
 #include <linux/pagemap.h>
 #include <linux/buffer_head.h>
@@ -78,10 +78,10 @@ void udf_evict_inode(struct inode *inode)
 	if (!inode->i_nlink && !is_bad_inode(inode)) {
 		want_delete = 1;
 		inode->i_size = 0;
+		mutex_lock(&inode->i_mutex);
 		udf_truncate(inode);
-		lock_kernel();
 		udf_update_inode(inode, IS_SYNC(inode));
-		unlock_kernel();
+		mutex_unlock(&inode->i_mutex);
 	}
 	invalidate_inode_buffers(inode);
 	end_writeback(inode);
@@ -97,9 +97,9 @@ void udf_evict_inode(struct inode *inode)
 	kfree(iinfo->i_ext.i_data);
 	iinfo->i_ext.i_data = NULL;
 	if (want_delete) {
-		lock_kernel();
+		mutex_lock(&inode->i_mutex);
 		udf_free_inode(inode);
-		unlock_kernel();
+		mutex_unlock(&inode->i_mutex);
 	}
 }
 
@@ -303,8 +303,6 @@ static int udf_get_block(struct inode *inode, sector_t block,
 	new = 0;
 	bh = NULL;
 
-	lock_kernel();
-
 	iinfo = UDF_I(inode);
 	if (block == iinfo->i_next_alloc_block + 1) {
 		iinfo->i_next_alloc_block++;
@@ -324,7 +322,6 @@ static int udf_get_block(struct inode *inode, sector_t block,
 	map_bh(bh_result, inode->i_sb, phys);
 
 abort:
-	unlock_kernel();
 	return err;
 }
 
@@ -1022,7 +1019,6 @@ void udf_truncate(struct inode *inode)
 	if (IS_APPEND(inode) || IS_IMMUTABLE(inode))
 		return;
 
-	lock_kernel();
 	iinfo = UDF_I(inode);
 	if (iinfo->i_alloc_type == ICBTAG_FLAG_AD_IN_ICB) {
 		if (inode->i_sb->s_blocksize <
@@ -1031,7 +1027,6 @@ void udf_truncate(struct inode *inode)
 			udf_expand_file_adinicb(inode, inode->i_size, &err);
 			if (iinfo->i_alloc_type == ICBTAG_FLAG_AD_IN_ICB) {
 				inode->i_size = iinfo->i_lenAlloc;
-				unlock_kernel();
 				return;
 			} else
 				udf_truncate_extents(inode);
@@ -1053,7 +1048,6 @@ void udf_truncate(struct inode *inode)
 		udf_sync_inode(inode);
 	else
 		mark_inode_dirty(inode);
-	unlock_kernel();
 }
 
 static void __udf_read_inode(struct inode *inode)
@@ -1375,9 +1369,12 @@ int udf_write_inode(struct inode *inode, struct writeback_control *wbc)
 {
 	int ret;
 
-	lock_kernel();
+	if (wbc->sync_mode == WB_SYNC_ALL)
+		return udf_sync_inode(inode);
+
+	mutex_lock(&inode->i_mutex);
 	ret = udf_update_inode(inode, wbc->sync_mode == WB_SYNC_ALL);
-	unlock_kernel();
+	mutex_unlock(&inode->i_mutex);
 
 	return ret;
 }
@@ -2048,7 +2045,7 @@ long udf_block_map(struct inode *inode, sector_t block)
 	struct extent_position epos = {};
 	int ret;
 
-	lock_kernel();
+	mutex_lock(&inode->i_mutex);
 
 	if (inode_bmap(inode, block, &epos, &eloc, &elen, &offset) ==
 						(EXT_RECORDED_ALLOCATED >> 30))
@@ -2056,7 +2053,7 @@ long udf_block_map(struct inode *inode, sector_t block)
 	else
 		ret = 0;
 
-	unlock_kernel();
+	mutex_unlock(&inode->i_mutex);
 	brelse(epos.bh);
 
 	if (UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_VARCONV))
-- 
1.7.0.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists