diff options
author | J. Bruce Fields <bfields@redhat.com> | 2011-08-25 10:48:39 -0400 |
---|---|---|
committer | J. Bruce Fields <bfields@redhat.com> | 2011-08-27 14:20:20 -0400 |
commit | a043226bc140a2c1dde162246d68a67e5043e6b2 (patch) | |
tree | 8d2f2a52835d37150c0cae42787903793e57bd86 /fs/nfsd | |
parent | c10bd39d800d42adef55ed9016f802677cd0ab5f (diff) |
nfsd4: permit read opens of executable-only files
A client that wants to execute a file must be able to read it. Read
opens over nfs are therefore implicitly allowed for executable files
even when those files are not readable.
NFSv2/v3 get this right by using a passed-in NFSD_MAY_OWNER_OVERRIDE on
read requests, but NFSv4 has gotten this wrong ever since
dc730e173785e29b297aa605786c94adaffe2544 "nfsd4: fix owner-override on
open", when we realized that the file owner shouldn't override
permissions on non-reclaim NFSv4 opens.
So we can't use NFSD_MAY_OWNER_OVERRIDE to tell nfsd_permission to allow
reads of executable files.
So, do the same thing we do whenever we encounter another weird NFS
permission nit: define yet another NFSD_MAY_* flag.
The industry's future standardization on 128-bit processors will be
motivated primarily by the need for integers with enough bits for all
the NFSD_MAY_* flags.
Reported-by: Leonardo Borda <leonardoborda@gmail.com>
Cc: stable@kernel.org
Signed-off-by: J. Bruce Fields <bfields@redhat.com>
Diffstat (limited to 'fs/nfsd')
-rw-r--r-- | fs/nfsd/nfs4proc.c | 2 | ||||
-rw-r--r-- | fs/nfsd/vfs.c | 3 | ||||
-rw-r--r-- | fs/nfsd/vfs.h | 1 |
3 files changed, 5 insertions, 1 deletions
diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c index 479ffb185df..b5530984db9 100644 --- a/fs/nfsd/nfs4proc.c +++ b/fs/nfsd/nfs4proc.c | |||
@@ -156,6 +156,8 @@ do_open_permission(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfs | |||
156 | !(open->op_share_access & NFS4_SHARE_ACCESS_WRITE)) | 156 | !(open->op_share_access & NFS4_SHARE_ACCESS_WRITE)) |
157 | return nfserr_inval; | 157 | return nfserr_inval; |
158 | 158 | ||
159 | accmode |= NFSD_MAY_READ_IF_EXEC; | ||
160 | |||
159 | if (open->op_share_access & NFS4_SHARE_ACCESS_READ) | 161 | if (open->op_share_access & NFS4_SHARE_ACCESS_READ) |
160 | accmode |= NFSD_MAY_READ; | 162 | accmode |= NFSD_MAY_READ; |
161 | if (open->op_share_access & NFS4_SHARE_ACCESS_WRITE) | 163 | if (open->op_share_access & NFS4_SHARE_ACCESS_WRITE) |
diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c index 4c22870293e..75c35fa4615 100644 --- a/fs/nfsd/vfs.c +++ b/fs/nfsd/vfs.c | |||
@@ -2116,7 +2116,8 @@ nfsd_permission(struct svc_rqst *rqstp, struct svc_export *exp, | |||
2116 | 2116 | ||
2117 | /* Allow read access to binaries even when mode 111 */ | 2117 | /* Allow read access to binaries even when mode 111 */ |
2118 | if (err == -EACCES && S_ISREG(inode->i_mode) && | 2118 | if (err == -EACCES && S_ISREG(inode->i_mode) && |
2119 | acc == (NFSD_MAY_READ | NFSD_MAY_OWNER_OVERRIDE)) | 2119 | (acc == (NFSD_MAY_READ | NFSD_MAY_OWNER_OVERRIDE) || |
2120 | acc == (NFSD_MAY_READ | NFSD_MAY_READ_IF_EXEC))) | ||
2120 | err = inode_permission(inode, MAY_EXEC); | 2121 | err = inode_permission(inode, MAY_EXEC); |
2121 | 2122 | ||
2122 | return err? nfserrno(err) : 0; | 2123 | return err? nfserrno(err) : 0; |
diff --git a/fs/nfsd/vfs.h b/fs/nfsd/vfs.h index e0bbac04d1d..a22e40e2786 100644 --- a/fs/nfsd/vfs.h +++ b/fs/nfsd/vfs.h | |||
@@ -25,6 +25,7 @@ | |||
25 | #define NFSD_MAY_BYPASS_GSS_ON_ROOT 256 | 25 | #define NFSD_MAY_BYPASS_GSS_ON_ROOT 256 |
26 | #define NFSD_MAY_NOT_BREAK_LEASE 512 | 26 | #define NFSD_MAY_NOT_BREAK_LEASE 512 |
27 | #define NFSD_MAY_BYPASS_GSS 1024 | 27 | #define NFSD_MAY_BYPASS_GSS 1024 |
28 | #define NFSD_MAY_READ_IF_EXEC 2048 | ||
28 | 29 | ||
29 | #define NFSD_MAY_CREATE (NFSD_MAY_EXEC|NFSD_MAY_WRITE) | 30 | #define NFSD_MAY_CREATE (NFSD_MAY_EXEC|NFSD_MAY_WRITE) |
30 | #define NFSD_MAY_REMOVE (NFSD_MAY_EXEC|NFSD_MAY_WRITE|NFSD_MAY_TRUNC) | 31 | #define NFSD_MAY_REMOVE (NFSD_MAY_EXEC|NFSD_MAY_WRITE|NFSD_MAY_TRUNC) |