Skip to contentSkip to conversation

fs/9p/: don't treat error as status value in file locking

PATCH In review Sasha Levin 2 participants 3 messages Jun 22, 2014 – Aug 10, 2014 9P file system

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fs/9p/: don't treat error as status value in file locking

When trying to lock a file we didn't properly handle the case where a failure in p9_client_lock_dotl() occurs and treated the status value as valid instead of discarding it due to the error.

This would usually trigger a BUG() since the status value would just be stack garbage.

---
 fs/9p/vfs_file.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/9p/vfs_file.c +1 -1
index 520c11c..06077f3 100644
@@ -194,7 +194,7 @@ static int v9fs_file_do_lock(struct file *filp, int cmd, struct file_lock *fl)
 	for (;;) {
 		res = p9_client_lock_dotl(fid, &flock, &status);
 		if (res < 0)
-			break;
+			return res;
 
 		if (status != P9_LOCK_BLOCKED)
 			break;
Signature · 1 line
1.7.10.4
#1 lore raw

Ping?

Quoted 26 lines · Sasha Levin

When trying to lock a file we didn't properly handle the case where a failure in p9_client_lock_dotl() occurs and treated the status value as valid instead of discarding it due to the error.

This would usually trigger a BUG() since the status value would just be stack garbage.

---
 fs/9p/vfs_file.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/9p/vfs_file.c +1 -1
index 520c11c..06077f3 100644
@@ -194,7 +194,7 @@ static int v9fs_file_do_lock(struct file *filp, int cmd, struct file_lock *fl)
 	for (;;) {
 		res = p9_client_lock_dotl(fid, &flock, &status);
 		if (res < 0)
-			break;
+			return res;
 
 		if (status != P9_LOCK_BLOCKED)
 			break;
#2 lore raw
In reply to Sasha Levin
Quoted 17 lines · Sasha Levin

When trying to lock a file we didn't properly handle the case where a failure in p9_client_lock_dotl() occurs and treated the status value as valid instead of discarding it due to the error.

This would usually trigger a BUG() since the status value would just be stack garbage.

---
 fs/9p/vfs_file.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/9p/vfs_file.c +0 -0
index 520c11c..06077f3 100644

fs/9p/vfs_file.c static int v9fs_file_do_lock(struct file *filp, int cmd, struct file_lock *fl) · line 200

Quoted 8 lines
fs/9p/vfs_file.c +1 -1
@@ -194,7 +194,7 @@ static int v9fs_file_do_lock(struct file *filp, int cmd, struct file_lock *fl)
 	for (;;) {
 		res = p9_client_lock_dotl(fid, &flock, &status);
 		if (res < 0)
-			break;
+			return res;
 
 		if (status != P9_LOCK_BLOCKED)
 			break;

We may want to do the local revert of the posix lock held. ie,

fs/9p/vfs_file.c +2 -1
index 520c11c2dcca..20ed603e60b2 100644
@@ -194,7 +194,7 @@ static int v9fs_file_do_lock(struct file *filp, int cmd, struct file_lock *fl)
 	for (;;) {
 		res = p9_client_lock_dotl(fid, &flock, &status);
 		if (res < 0)
-			break;
+			goto err_out;
 
 		if (status != P9_LOCK_BLOCKED)
 			break;
@@ -220,6 +220,7 @@ static int v9fs_file_do_lock(struct file *filp, int cmd, struct file_lock *fl)
 		BUG();
 	}
 
+err_out:
 	/*
 	 * incase server returned error for lock request, revert
 	 * it locally