浏览代码

[PATCH] fix posix lock on NFS

NFS client prevents mandatory lock, but there is a flaw on it; Locks are
possibly left if the mode is changed while locking.

This permits unlocking even if the mandatory lock bits are set.

Signed-off-by: ASANO Masahiro <masano@tnes.nec.co.jp>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
ASANO Masahiro 19 年之前
父节点
当前提交
0800c5f7a4
共有 1 个文件被更改,包括 2 次插入1 次删除
  1. 2 1
      fs/nfs/file.c

+ 2 - 1
fs/nfs/file.c

@@ -509,7 +509,8 @@ static int nfs_lock(struct file *filp, int cmd, struct file_lock *fl)
 		return -EINVAL;
 		return -EINVAL;
 
 
 	/* No mandatory locks over NFS */
 	/* No mandatory locks over NFS */
-	if ((inode->i_mode & (S_ISGID | S_IXGRP)) == S_ISGID)
+	if ((inode->i_mode & (S_ISGID | S_IXGRP)) == S_ISGID &&
+	    fl->fl_type != F_UNLCK)
 		return -ENOLCK;
 		return -ENOLCK;
 
 
 	if (IS_GETLK(cmd))
 	if (IS_GETLK(cmd))