linux-nfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] nfsd/idmap: return nfserr_inval for zero length principals
@ 2017-02-05 14:02 Kinglong Mee
  2017-02-17 19:09 ` J. Bruce Fields
  0 siblings, 1 reply; 2+ messages in thread
From: Kinglong Mee @ 2017-02-05 14:02 UTC (permalink / raw)
  To: J. Bruce Fields, linux-nfs; +Cc: linux-nfs

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.

Signed-off-by: Kinglong Mee <kinglongmee@gmail.com>
---
 fs/nfsd/nfs4idmap.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/fs/nfsd/nfs4idmap.c b/fs/nfsd/nfs4idmap.c
index 5b20577..6b9b6cc 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,
 {
 	__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))
-- 
2.9.3


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] nfsd/idmap: return nfserr_inval for zero length principals
  2017-02-05 14:02 [PATCH] nfsd/idmap: return nfserr_inval for zero length principals Kinglong Mee
@ 2017-02-17 19:09 ` J. Bruce Fields
  0 siblings, 0 replies; 2+ messages in thread
From: J. Bruce Fields @ 2017-02-17 19:09 UTC (permalink / raw)
  To: Kinglong Mee; +Cc: linux-nfs

Thanks for taking care of this!  Applying.--b.

On Sun, Feb 05, 2017 at 10:02:01PM +0800, Kinglong Mee wrote:
> 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.
> 
> Signed-off-by: Kinglong Mee <kinglongmee@gmail.com>
> ---
>  fs/nfsd/nfs4idmap.c | 8 ++++++++
>  1 file changed, 8 insertions(+)
> 
> diff --git a/fs/nfsd/nfs4idmap.c b/fs/nfsd/nfs4idmap.c
> index 5b20577..6b9b6cc 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,
>  {
>  	__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))
> -- 
> 2.9.3

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-02-17 19:09 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-02-05 14:02 [PATCH] nfsd/idmap: return nfserr_inval for zero length principals Kinglong Mee
2017-02-17 19:09 ` J. Bruce Fields

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).