diff options
author | Kinglong Mee <kinglongmee@gmail.com> | 2017-02-05 09:02:01 -0500 |
---|---|---|
committer | J. Bruce Fields <bfields@redhat.com> | 2017-02-17 16:25:59 -0500 |
commit | c3821b3497aae1752cb2be72c32f650ef24c8820 (patch) | |
tree | d81308296a2279a0032c58e7313016f36bfdf659 | |
parent | d6fc8821c2d2aba4cc18447a467f543e46e7367d (diff) |
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>
-rw-r--r-- | fs/nfsd/nfs4idmap.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/fs/nfsd/nfs4idmap.c b/fs/nfsd/nfs4idmap.c index 5b20577dcdd2..6b9b6cca469f 100644 --- a/fs/nfsd/nfs4idmap.c +++ b/fs/nfsd/nfs4idmap.c | |||
@@ -628,6 +628,10 @@ nfsd_map_name_to_uid(struct svc_rqst *rqstp, const char *name, size_t namelen, | |||
628 | { | 628 | { |
629 | __be32 status; | 629 | __be32 status; |
630 | u32 id = -1; | 630 | u32 id = -1; |
631 | |||
632 | if (name == NULL || namelen == 0) | ||
633 | return nfserr_inval; | ||
634 | |||
631 | status = do_name_to_id(rqstp, IDMAP_TYPE_USER, name, namelen, &id); | 635 | status = do_name_to_id(rqstp, IDMAP_TYPE_USER, name, namelen, &id); |
632 | *uid = make_kuid(&init_user_ns, id); | 636 | *uid = make_kuid(&init_user_ns, id); |
633 | if (!uid_valid(*uid)) | 637 | if (!uid_valid(*uid)) |
@@ -641,6 +645,10 @@ nfsd_map_name_to_gid(struct svc_rqst *rqstp, const char *name, size_t namelen, | |||
641 | { | 645 | { |
642 | __be32 status; | 646 | __be32 status; |
643 | u32 id = -1; | 647 | u32 id = -1; |
648 | |||
649 | if (name == NULL || namelen == 0) | ||
650 | return nfserr_inval; | ||
651 | |||
644 | status = do_name_to_id(rqstp, IDMAP_TYPE_GROUP, name, namelen, &id); | 652 | status = do_name_to_id(rqstp, IDMAP_TYPE_GROUP, name, namelen, &id); |
645 | *gid = make_kgid(&init_user_ns, id); | 653 | *gid = make_kgid(&init_user_ns, id); |
646 | if (!gid_valid(*gid)) | 654 | if (!gid_valid(*gid)) |