+ bug-nfsd-nfs4xdrc-misuse-of-err_ptr.patch added to -mm tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The patch titled

     bug: nfsd/nfs4xdr.c misuse of ERR_PTR()

has been added to the -mm tree.  Its filename is

     bug-nfsd-nfs4xdrc-misuse-of-err_ptr.patch

See http://www.zip.com.au/~akpm/linux/patches/stuff/added-to-mm.txt to find
out what to do about this

------------------------------------------------------
Subject: bug: nfsd/nfs4xdr.c misuse of ERR_PTR()
From: Al Viro <viro@xxxxxxxxxxxxxxxx>

	a) ERR_PTR(nfserr_something) is a bad idea;
IS_ERR() will be false for it.
	b) mixing nfserr_.... with -EOPNOTSUPP is
even worse idea.

nfsd4_path() does both; caller expects to get NFS protocol error out it if
anything goes wrong, but if it does we either do not notice (see (a)) or get
host-endian negative (see (b)).

IOW, that's a case when we can't use ERR_PTR() to return error, even though we
return a pointer in case of success.

Signed-off-by: Al Viro <viro@xxxxxxxxxxxxxxxxxx>
Signed-off-by: Andrew Morton <akpm@xxxxxxxx>
---

 fs/nfsd/nfs4xdr.c |   21 +++++++++++----------
 1 file changed, 11 insertions(+), 10 deletions(-)

diff -puN fs/nfsd/nfs4xdr.c~bug-nfsd-nfs4xdrc-misuse-of-err_ptr fs/nfsd/nfs4xdr.c
--- a/fs/nfsd/nfs4xdr.c~bug-nfsd-nfs4xdrc-misuse-of-err_ptr
+++ a/fs/nfsd/nfs4xdr.c
@@ -1292,16 +1292,15 @@ static int nfsd4_encode_fs_location4(str
  * Returned string is safe to use as long as the caller holds a reference
  * to @exp.
  */
-static char *nfsd4_path(struct svc_rqst *rqstp, struct svc_export *exp)
+static char *nfsd4_path(struct svc_rqst *rqstp, struct svc_export *exp, u32 *stat)
 {
 	struct svc_fh tmp_fh;
 	char *path, *rootpath;
-	int stat;
 
 	fh_init(&tmp_fh, NFS4_FHSIZE);
-	stat = exp_pseudoroot(rqstp->rq_client, &tmp_fh, &rqstp->rq_chandle);
-	if (stat)
-		return ERR_PTR(stat);
+	*stat = exp_pseudoroot(rqstp->rq_client, &tmp_fh, &rqstp->rq_chandle);
+	if (*stat)
+		return NULL;
 	rootpath = tmp_fh.fh_export->ex_path;
 
 	path = exp->ex_path;
@@ -1309,7 +1308,8 @@ static char *nfsd4_path(struct svc_rqst 
 	if (strncmp(path, rootpath, strlen(rootpath))) {
 		printk("nfsd: fs_locations failed;"
 			"%s is not contained in %s\n", path, rootpath);
-		return ERR_PTR(-EOPNOTSUPP);
+		*stat = nfserr_notsupp;
+		return NULL;
 	}
 
 	return path + strlen(rootpath);
@@ -1322,13 +1322,14 @@ static int nfsd4_encode_fs_locations(str
 				     struct svc_export *exp,
 				     u32 **pp, int *buflen)
 {
-	int status, i;
+	u32 status;
+	int i;
 	u32 *p = *pp;
 	struct nfsd4_fs_locations *fslocs = &exp->ex_fslocs;
-	char *root = nfsd4_path(rqstp, exp);
+	char *root = nfsd4_path(rqstp, exp, &status);
 
-	if (IS_ERR(root))
-		return PTR_ERR(root);
+	if (status)
+		return status;
 	status = nfsd4_encode_components('/', root, &p, buflen);
 	if (status)
 		return status;
_

Patches currently in -mm which might be from viro@xxxxxxxxxxxxxxxx are

origin.patch
git-netdev-all.patch
bug-nfsd-nfs4xdrc-misuse-of-err_ptr.patch
fix-svc_procfunc-declaration.patch
lockd-endianness-annotations.patch
xdr-annotations-nfsv2.patch
xdr-annotations-nfsv3.patch
xdr-annotations-nfsv4.patch
xdr-annotations-nfs-readdir-entries.patch
fs-nfs-callback-passes-error-values-big-endian.patch
xdr-annotations-fs-nfs-callback.patch
nfs-verifier-is-network-endian.patch
xdr-annotations-mount_clnt.patch
nfs_common-endianness-annotations.patch
nfsd-nfserrno-endianness-annotations.patch
nfsfh-simple-endianness-annotations.patch
xdr-annotations-nfsd_dispatch.patch
xdr-annotations-nfsv2-server.patch
xdr-annotations-nfsv3-server.patch
xdr-annotations-nfsv4-server.patch
nfsd-vfsc-endianness-annotations.patch
nfsd-nfs4-code-returns-error-values-in-net-endian.patch
nfsd-nfsv23-trivial-endianness-annotations-for-error-values.patch
nfsd-nfsv4-errno-endianness-annotations.patch
xdr-annotations-nfsd-callback.patch
nfsd-misc-endianness-annotations.patch
nfsd-nfs_replay_me.patch
slab-leaks3-default-y.patch

-
To unsubscribe from this list: send the line "unsubscribe mm-commits" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Kernel Newbies FAQ]     [Kernel Archive]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Photo]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]

  Powered by Linux