diff options
author | J. Bruce Fields <bfields@redhat.com> | 2012-04-09 18:06:49 -0400 |
---|---|---|
committer | J. Bruce Fields <bfields@redhat.com> | 2012-04-11 17:49:52 -0400 |
commit | 9dc4e6c4d1182d34604ea40fef641775f5b15456 (patch) | |
tree | 22b055349ea646026a97ea0b0cc7da32c18f26dd /fs/nfsd | |
parent | 0034102808e0dbbf3a2394b82b1bb40b5778de9e (diff) |
nfsd: don't fail unchecked creates of non-special files
Allow a v3 unchecked open of a non-regular file succeed as if it were a
lookup; typically a client in such a case will want to fall back on a
local open, so succeeding and giving it the filehandle is more useful
than failing with nfserr_exist, which makes it appear that nothing at
all exists by that name.
Similarly for v4, on an open-create, return the same errors we would on
an attempt to open a non-regular file, instead of returning
nfserr_exist.
This fixes a problem found doing a v4 open of a symlink with
O_RDONLY|O_CREAT, which resulted in the current client returning EEXIST.
Thanks also to Trond for analysis.
Cc: stable@kernel.org
Reported-by: Orion Poplawski <orion@cora.nwra.com>
Tested-by: Orion Poplawski <orion@cora.nwra.com>
Signed-off-by: J. Bruce Fields <bfields@redhat.com>
Diffstat (limited to 'fs/nfsd')
-rw-r--r-- | fs/nfsd/nfs4proc.c | 8 | ||||
-rw-r--r-- | fs/nfsd/vfs.c | 2 |
2 files changed, 5 insertions, 5 deletions
diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c index 2ed14dfd00a2..8256efda3638 100644 --- a/fs/nfsd/nfs4proc.c +++ b/fs/nfsd/nfs4proc.c | |||
@@ -235,17 +235,17 @@ do_open_lookup(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_o | |||
235 | */ | 235 | */ |
236 | if (open->op_createmode == NFS4_CREATE_EXCLUSIVE && status == 0) | 236 | if (open->op_createmode == NFS4_CREATE_EXCLUSIVE && status == 0) |
237 | open->op_bmval[1] = (FATTR4_WORD1_TIME_ACCESS | | 237 | open->op_bmval[1] = (FATTR4_WORD1_TIME_ACCESS | |
238 | FATTR4_WORD1_TIME_MODIFY); | 238 | FATTR4_WORD1_TIME_MODIFY); |
239 | } else { | 239 | } else { |
240 | status = nfsd_lookup(rqstp, current_fh, | 240 | status = nfsd_lookup(rqstp, current_fh, |
241 | open->op_fname.data, open->op_fname.len, resfh); | 241 | open->op_fname.data, open->op_fname.len, resfh); |
242 | fh_unlock(current_fh); | 242 | fh_unlock(current_fh); |
243 | if (status) | ||
244 | goto out; | ||
245 | status = nfsd_check_obj_isreg(resfh); | ||
246 | } | 243 | } |
247 | if (status) | 244 | if (status) |
248 | goto out; | 245 | goto out; |
246 | status = nfsd_check_obj_isreg(resfh); | ||
247 | if (status) | ||
248 | goto out; | ||
249 | 249 | ||
250 | if (is_create_with_attrs(open) && open->op_acl != NULL) | 250 | if (is_create_with_attrs(open) && open->op_acl != NULL) |
251 | do_set_nfs4_acl(rqstp, resfh, open->op_acl, open->op_bmval); | 251 | do_set_nfs4_acl(rqstp, resfh, open->op_acl, open->op_bmval); |
diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c index 296d671654d6..568666156ea4 100644 --- a/fs/nfsd/vfs.c +++ b/fs/nfsd/vfs.c | |||
@@ -1458,7 +1458,7 @@ do_nfsd_create(struct svc_rqst *rqstp, struct svc_fh *fhp, | |||
1458 | switch (createmode) { | 1458 | switch (createmode) { |
1459 | case NFS3_CREATE_UNCHECKED: | 1459 | case NFS3_CREATE_UNCHECKED: |
1460 | if (! S_ISREG(dchild->d_inode->i_mode)) | 1460 | if (! S_ISREG(dchild->d_inode->i_mode)) |
1461 | err = nfserr_exist; | 1461 | goto out; |
1462 | else if (truncp) { | 1462 | else if (truncp) { |
1463 | /* in nfsv4, we need to treat this case a little | 1463 | /* in nfsv4, we need to treat this case a little |
1464 | * differently. we don't want to truncate the | 1464 | * differently. we don't want to truncate the |