nfsd/idmap: return nfserr_inval for zero length principals
Subsystems (2)
PATCH 1/1 nfsd/idmap: return nfserr_inval for zero length principals
Tigran Mkrtchyan's pynfs testcase for zero length principals fail as,
SATT16 st_setattr.testEmptyPrincipal : FAILURE
Setting empty owner should return NFS4ERR_INVAL, instead got NFS4ERR_BADOWNER
SATT17 st_setattr.testEmptyGroupPrincipal : FAILURE
Setting empty owner_group should return NFS4ERR_INVAL, instead got NFS4ERR_BADOWNER
This patch checks the principal and return nfserr_inval directly. It should be check after decoding in nfs4xdr.c, but it's simple before process in nfsd_map_xxxx, so adds it in nfs4idmap.c.
--- fs/nfsd/nfs4idmap.c | 8 ++++++++ 1 file changed, 8 insertions(+)
fs/nfsd/nfs4idmap.c +8 -0
@@ -628,6 +628,10 @@ nfsd_map_name_to_uid(struct svc_rqst *rqstp, const char *name, size_t namelen, {__be32 status;u32 id =-1 ; + +if (name ==NULL || namelen ==0 ) +return nfserr_inval; + status =do_name_to_id (rqstp,IDMAP_TYPE_USER , name, namelen, &id); *uid =make_kuid (&init_user_ns, id);if (!uid_valid (*uid))
@@ -641,6 +645,10 @@ nfsd_map_name_to_gid(struct svc_rqst *rqstp, const char *name, size_t namelen, {__be32 status;u32 id =-1 ; + +if (name ==NULL || namelen ==0 ) +return nfserr_inval; + status =do_name_to_id (rqstp,IDMAP_TYPE_GROUP , name, namelen, &id); *gid =make_kgid (&init_user_ns, id);if (!gid_valid (*gid))
Signature · 1 line
2.9.3
Thanks for taking care of this! Applying.--b.
Quoted 46 lines · Kinglong Mee
Tigran Mkrtchyan's pynfs testcase for zero length principals fail as,
SATT16 st_setattr.testEmptyPrincipal : FAILURE
Setting empty owner should returnNFS4ERR_INVAL, instead gotNFS4ERR_BADOWNER
SATT17 st_setattr.testEmptyGroupPrincipal : FAILURE
Setting emptyowner_groupshould returnNFS4ERR_INVAL, instead gotNFS4ERR_BADOWNERThis patch checks the principal and return
nfserr_invaldirectly. It should be check after decoding innfs4xdr.c, but it's simple before process innfsd_map_xxxx, so adds it innfs4idmap.c.Signed-off-by Kinglong Mee <[email protected]>--- fs/nfsd/nfs4idmap.c | 8 ++++++++ 1 file changed, 8 insertions(+)fs/nfsd/nfs4idmap.c +8
-0@@ -628,6 +628,10 @@ nfsd_map_name_to_uid(struct svc_rqst *rqstp, const char *name, size_t namelen, {__be32 status;u32 id =-1 ; + +if (name ==NULL || namelen ==0 ) +return nfserr_inval; + status =do_name_to_id (rqstp,IDMAP_TYPE_USER , name, namelen, &id); *uid =make_kuid (&init_user_ns, id);if (!uid_valid (*uid))@@ -641,6 +645,10 @@ nfsd_map_name_to_gid(struct svc_rqst *rqstp, const char *name, size_t namelen, {__be32 status;u32 id =-1 ; + +if (name ==NULL || namelen ==0 ) +return nfserr_inval; + status =do_name_to_id (rqstp,IDMAP_TYPE_GROUP , name, namelen, &id); *gid =make_kgid (&init_user_ns, id);if (!gid_valid (*gid))Signature · 1 line
2.9.3