aboutsummaryrefslogtreecommitdiffstats
path: root/fs/exportfs/expfs.c
diff options
context:
space:
mode:
authorNeilBrown <neilb@suse.com>2016-08-03 20:19:06 -0400
committerJ. Bruce Fields <bfields@redhat.com>2016-10-06 09:07:44 -0400
commit09bb8bfffd29c3dffb72bc2c69a062dfb1ae624c (patch)
tree44c4f7a56072f73b85088225a408a91bdb33b567 /fs/exportfs/expfs.c
parent7d22fc11c7edeeac6f1c3f1ae0edcef4de08c6e0 (diff)
exportfs: be careful to only return expected errors.
When nfsd calls fh_to_dentry, it expect ESTALE or ENOMEM as errors. In particular it can be tempting to return ENOENT, but this is not handled well by nfsd. Rather than requiring strict adherence to error code code filesystems, treat all unexpected error codes the same as ESTALE. This is safest. Signed-off-by: NeilBrown <neilb@suse.com> Signed-off-by: J. Bruce Fields <bfields@redhat.com>
Diffstat (limited to 'fs/exportfs/expfs.c')
-rw-r--r--fs/exportfs/expfs.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/fs/exportfs/expfs.c b/fs/exportfs/expfs.c
index 207ba8d627ca..a4b531be9168 100644
--- a/fs/exportfs/expfs.c
+++ b/fs/exportfs/expfs.c
@@ -428,10 +428,10 @@ struct dentry *exportfs_decode_fh(struct vfsmount *mnt, struct fid *fid,
428 if (!nop || !nop->fh_to_dentry) 428 if (!nop || !nop->fh_to_dentry)
429 return ERR_PTR(-ESTALE); 429 return ERR_PTR(-ESTALE);
430 result = nop->fh_to_dentry(mnt->mnt_sb, fid, fh_len, fileid_type); 430 result = nop->fh_to_dentry(mnt->mnt_sb, fid, fh_len, fileid_type);
431 if (!result) 431 if (PTR_ERR(result) == -ENOMEM)
432 result = ERR_PTR(-ESTALE); 432 return ERR_CAST(result);
433 if (IS_ERR(result)) 433 if (IS_ERR_OR_NULL(result))
434 return result; 434 return ERR_PTR(-ESTALE);
435 435
436 if (d_is_dir(result)) { 436 if (d_is_dir(result)) {
437 /* 437 /*
@@ -541,6 +541,8 @@ struct dentry *exportfs_decode_fh(struct vfsmount *mnt, struct fid *fid,
541 541
542 err_result: 542 err_result:
543 dput(result); 543 dput(result);
544 if (err != -ENOMEM)
545 err = -ESTALE;
544 return ERR_PTR(err); 546 return ERR_PTR(err);
545} 547}
546EXPORT_SYMBOL_GPL(exportfs_decode_fh); 548EXPORT_SYMBOL_GPL(exportfs_decode_fh);