[PATCH] v9fs: Skip check for mandatory locks when unlocking

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Sachin Prabhu
Date: Thursday, March 11, 2010 - 10:53 am

While investigating a bug, I came across a possible bug in v9fs. The problem is similar to the one reported for NFS by ASANO Masahiro in http://lkml.org/lkml/2005/12/21/334. 

v9fs_file_lock() will skip locks on file which has mode set to 02666. This is a problem in cases where the mode of the file is changed after a process has obtained a lock on the file. Such a lock will be skipped during unlock and the machine will end up with a BUG in locks_remove_flock().

v9fs_file_lock() should skip the check for mandatory locks when unlocking a file.

Signed-off-by: Sachin Prabhu <sprabhu@redhat.com>
diff -up linux-2.6/fs/9p/vfs_file.c.9p linux-2.6/fs/9p/vfs_file.c
--- linux-2.6/fs/9p/vfs_file.c.9p	2010-03-11 17:32:52.000000000 +0000
+++ linux-2.6/fs/9p/vfs_file.c	2010-03-11 17:33:11.000000000 +0000
@@ -114,7 +114,7 @@ static int v9fs_file_lock(struct file *f
 	P9_DPRINTK(P9_DEBUG_VFS, "filp: %p lock: %p\n", filp, fl);
 
 	/* No mandatory locks */
-	if (__mandatory_lock(inode))
+	if (__mandatory_lock(inode) && fl->fl_type != F_UNLCK)
 		return -ENOLCK;
 
 	if ((IS_SETLK(cmd) || IS_SETLKW(cmd)) && fl->fl_type != F_UNLCK) {
--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH] v9fs: Skip check for mandatory locks when unlocking, Sachin Prabhu, (Thu Mar 11, 10:53 am)