Skip to content

Commit 9dc4e6c

Browse files
author
J. Bruce Fields
committed
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: [email protected] Reported-by: Orion Poplawski <[email protected]> Tested-by: Orion Poplawski <[email protected]> Signed-off-by: J. Bruce Fields <[email protected]>
1 parent 0034102 commit 9dc4e6c

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

fs/nfsd/nfs4proc.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -235,15 +235,15 @@ do_open_lookup(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_o
235235
*/
236236
if (open->op_createmode == NFS4_CREATE_EXCLUSIVE && status == 0)
237237
open->op_bmval[1] = (FATTR4_WORD1_TIME_ACCESS |
238-
FATTR4_WORD1_TIME_MODIFY);
238+
FATTR4_WORD1_TIME_MODIFY);
239239
} else {
240240
status = nfsd_lookup(rqstp, current_fh,
241241
open->op_fname.data, open->op_fname.len, resfh);
242242
fh_unlock(current_fh);
243-
if (status)
244-
goto out;
245-
status = nfsd_check_obj_isreg(resfh);
246243
}
244+
if (status)
245+
goto out;
246+
status = nfsd_check_obj_isreg(resfh);
247247
if (status)
248248
goto out;
249249

fs/nfsd/vfs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1458,7 +1458,7 @@ do_nfsd_create(struct svc_rqst *rqstp, struct svc_fh *fhp,
14581458
switch (createmode) {
14591459
case NFS3_CREATE_UNCHECKED:
14601460
if (! S_ISREG(dchild->d_inode->i_mode))
1461-
err = nfserr_exist;
1461+
goto out;
14621462
else if (truncp) {
14631463
/* in nfsv4, we need to treat this case a little
14641464
* differently. we don't want to truncate the

0 commit comments

Comments
 (0)