Skip to content
/ linux Public

Commit 42cc358

Browse files
Anthony IliopoulosSasha Levin
authored andcommitted
nfsd: fix return error code for nfsd_map_name_to_[ug]id
[ Upstream commit 404d779 ] idmap lookups can time out while the cache is waiting for a userspace upcall reply. In that case cache_check() returns -ETIMEDOUT to callers. The nfsd_map_name_to_[ug]id functions currently proceed with attempting to map the id to a kuid despite a potentially temporary failure to perform the idmap lookup. This results in the code returning the error NFSERR_BADOWNER which can cause client operations to return to userspace with failure. Fix this by returning the failure status before attempting kuid mapping. This will return NFSERR_JUKEBOX on idmap lookup timeout so that clients can retry the operation instead of aborting it. Fixes: 65e10f6 ("nfsd: Convert idmap to use kuids and kgids") Cc: stable@vger.kernel.org Signed-off-by: Anthony Iliopoulos <ailiop@suse.com> Reviewed-by: NeilBrown <neil@brown.name> Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent d3af624 commit 42cc358

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

fs/nfsd/nfs4idmap.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -672,6 +672,8 @@ __be32 nfsd_map_name_to_uid(struct svc_rqst *rqstp, const char *name,
672672
return nfserr_inval;
673673

674674
status = do_name_to_id(rqstp, IDMAP_TYPE_USER, name, namelen, &id);
675+
if (status)
676+
return status;
675677
*uid = make_kuid(nfsd_user_namespace(rqstp), id);
676678
if (!uid_valid(*uid))
677679
status = nfserr_badowner;
@@ -707,6 +709,8 @@ __be32 nfsd_map_name_to_gid(struct svc_rqst *rqstp, const char *name,
707709
return nfserr_inval;
708710

709711
status = do_name_to_id(rqstp, IDMAP_TYPE_GROUP, name, namelen, &id);
712+
if (status)
713+
return status;
710714
*gid = make_kgid(nfsd_user_namespace(rqstp), id);
711715
if (!gid_valid(*gid))
712716
status = nfserr_badowner;

0 commit comments

Comments
 (0)