nfs: Fix NFS v4 client handling of MAY_EXEC in nfs_permission.
authorFrank Filz <ffilzlnx@us.ibm.com>
Mon, 18 May 2009 21:41:40 +0000 (17:41 -0400)
committerLinus Torvalds <torvalds@linux-foundation.org>
Tue, 19 May 2009 03:11:12 +0000 (20:11 -0700)
The problem is that permission checking is skipped if atomic open is
possible, but when exec opens a file, it just opens it O_READONLY which
means EXEC permission will not be checked at that time.

This problem is observed by the following sequence (executed as root):

  mount -t nfs4 server:/ /mnt4
  echo "ls" >/mnt4/foo
  chmod 744 /mnt4/foo
  su guest -c "mnt4/foo"

Signed-off-by: Frank Filz <ffilzlnx@us.ibm.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Cc: stable@kernel.org
Tested-by: Eugene Teo <eugeneteo@kernel.sg>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
fs/nfs/dir.c

index 370b190a09d1d7ac7d03fe1cd45457ec866749a4..89f98e9a024b73accbfce55d575834e9357be491 100644 (file)
@@ -1943,7 +1943,8 @@ int nfs_permission(struct inode *inode, int mask)
                case S_IFREG:
                        /* NFSv4 has atomic_open... */
                        if (nfs_server_capable(inode, NFS_CAP_ATOMIC_OPEN)
-                                       && (mask & MAY_OPEN))
+                                       && (mask & MAY_OPEN)
+                                       && !(mask & MAY_EXEC))
                                goto out;
                        break;
                case S_IFDIR: