From 7aebcc3f1118b74556fcbc2970858c5eac56f10e Mon Sep 17 00:00:00 2001 From: Andrew Morton Date: Sun, 18 Jan 2004 18:39:23 -0800 Subject: [PATCH] [PATCH] nfs: Fix readonly mounts From: Trond Myklebust The nfs_permission() code needs to check for "local" mount flags such as "ro" *before* it decides to optimize away any permissions tests. --- fs/nfs/dir.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c index 33c2aa940c920..0796bd6a3ac01 100644 --- a/fs/nfs/dir.c +++ b/fs/nfs/dir.c @@ -1281,13 +1281,8 @@ nfs_permission(struct inode *inode, int mask, struct nameidata *nd) int mode = inode->i_mode; int res; - /* Are we checking permissions on anything other than lookup? */ - if (!(mask & MAY_EXEC)) { - /* We only need to check permissions on file open() and access() */ - if (!nd || !(nd->flags & (LOOKUP_OPEN|LOOKUP_ACCESS))) - return 0; - } - + if (mask == 0) + return 0; if (mask & MAY_WRITE) { /* * @@ -1306,6 +1301,12 @@ nfs_permission(struct inode *inode, int mask, struct nameidata *nd) if (IS_IMMUTABLE(inode)) return -EACCES; } + /* Are we checking permissions on anything other than lookup/execute? */ + if ((mask & MAY_EXEC) == 0) { + /* We only need to check permissions on file open() and access() */ + if (!nd || !(nd->flags & (LOOKUP_OPEN|LOOKUP_ACCESS))) + return 0; + } lock_kernel(); -- 2.53.0