Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 2 Jun 2011 20:57:36 +0000 (UTC)
From:      Rick Macklem <rmacklem@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org
Subject:   svn commit: r222629 - in stable/8/sys: fs/nfsclient nfsclient
Message-ID:  <201106022057.p52KvakG033709@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: rmacklem
Date: Thu Jun  2 20:57:36 2011
New Revision: 222629
URL: http://svn.freebsd.org/changeset/base/222629

Log:
  MFC: r222075
  Add a sanity check for the existence of an "addr" option
  to both NFS clients. This avoids the crash reported by
  Sergey Kandaurov (pluknet@gmail.com) to the freebsd-fs@
  list with subject "[old nfsclient] different nmount()
  args passed from mount vs mount_nfs" dated May 17, 2011.

Modified:
  stable/8/sys/fs/nfsclient/nfs_clvfsops.c
  stable/8/sys/nfsclient/nfs_vfsops.c
Directory Properties:
  stable/8/sys/   (props changed)
  stable/8/sys/amd64/include/xen/   (props changed)
  stable/8/sys/cddl/contrib/opensolaris/   (props changed)
  stable/8/sys/contrib/dev/acpica/   (props changed)
  stable/8/sys/contrib/pf/   (props changed)

Modified: stable/8/sys/fs/nfsclient/nfs_clvfsops.c
==============================================================================
--- stable/8/sys/fs/nfsclient/nfs_clvfsops.c	Thu Jun  2 20:56:42 2011	(r222628)
+++ stable/8/sys/fs/nfsclient/nfs_clvfsops.c	Thu Jun  2 20:57:36 2011	(r222629)
@@ -1075,15 +1075,21 @@ nfs_mount(struct mount *mp)
 		dirpath[0] = '\0';
 	dirlen = strlen(dirpath);
 
-	if (has_nfs_args_opt == 0 && vfs_getopt(mp->mnt_optnew, "addr",
-	    (void **)&args.addr, &args.addrlen) == 0) {
-		if (args.addrlen > SOCK_MAXADDRLEN) {
-			error = ENAMETOOLONG;
+	if (has_nfs_args_opt == 0) {
+		if (vfs_getopt(mp->mnt_optnew, "addr",
+		    (void **)&args.addr, &args.addrlen) == 0) {
+			if (args.addrlen > SOCK_MAXADDRLEN) {
+				error = ENAMETOOLONG;
+				goto out;
+			}
+			nam = malloc(args.addrlen, M_SONAME, M_WAITOK);
+			bcopy(args.addr, nam, args.addrlen);
+			nam->sa_len = args.addrlen;
+		} else {
+			vfs_mount_error(mp, "No server address");
+			error = EINVAL;
 			goto out;
 		}
-		nam = malloc(args.addrlen, M_SONAME, M_WAITOK);
-		bcopy(args.addr, nam, args.addrlen);
-		nam->sa_len = args.addrlen;
 	}
 
 	args.fh = nfh;

Modified: stable/8/sys/nfsclient/nfs_vfsops.c
==============================================================================
--- stable/8/sys/nfsclient/nfs_vfsops.c	Thu Jun  2 20:56:42 2011	(r222628)
+++ stable/8/sys/nfsclient/nfs_vfsops.c	Thu Jun  2 20:57:36 2011	(r222629)
@@ -1147,6 +1147,10 @@ nfs_mount(struct mount *mp)
 				goto out;
 			}
 		}
+	} else if (has_addr_opt == 0) {
+		vfs_mount_error(mp, "No server address");
+		error = EINVAL;
+		goto out;
 	}
 	error = mountnfs(&args, mp, nam, args.hostname, &vp,
 	    curthread->td_ucred, negnametimeo);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201106022057.p52KvakG033709>