Skip to content

Commit c3821b3

Browse files
kinglongmeeJ. Bruce Fields
authored andcommitted
nfsd/idmap: return nfserr_inval for 0-length names
Tigran Mkrtchyan's new pynfs testcases for zero length principals fail: 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 returns nfserr_inval directly. It could check after decoding in nfs4xdr.c, but it's simpler to do it in nfsd_map_xxxx. Signed-off-by: Kinglong Mee <kinglongmee@gmail.com> Signed-off-by: J. Bruce Fields <bfields@redhat.com>
1 parent d6fc882 commit c3821b3

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

fs/nfsd/nfs4idmap.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -628,6 +628,10 @@ nfsd_map_name_to_uid(struct svc_rqst *rqstp, const char *name, size_t namelen,
628628
{
629629
__be32 status;
630630
u32 id = -1;
631+
632+
if (name == NULL || namelen == 0)
633+
return nfserr_inval;
634+
631635
status = do_name_to_id(rqstp, IDMAP_TYPE_USER, name, namelen, &id);
632636
*uid = make_kuid(&init_user_ns, id);
633637
if (!uid_valid(*uid))
@@ -641,6 +645,10 @@ nfsd_map_name_to_gid(struct svc_rqst *rqstp, const char *name, size_t namelen,
641645
{
642646
__be32 status;
643647
u32 id = -1;
648+
649+
if (name == NULL || namelen == 0)
650+
return nfserr_inval;
651+
644652
status = do_name_to_id(rqstp, IDMAP_TYPE_GROUP, name, namelen, &id);
645653
*gid = make_kgid(&init_user_ns, id);
646654
if (!gid_valid(*gid))

0 commit comments

Comments
 (0)