Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 28 Jan 2020 18:54:15 +0000 (UTC)
From:      Gordon Tetlow <gordon@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-releng@freebsd.org
Subject:   svn commit: r357216 - in releng: 11.3/sys/kern 12.0/sys/kern
Message-ID:  <202001281854.00SIsFLG037695@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: gordon
Date: Tue Jan 28 18:54:15 2020
New Revision: 357216
URL: https://svnweb.freebsd.org/changeset/base/357216

Log:
  Fix nmount invalid pointer dereference
  
  Submitted by:	Andrew Turner
  Approved by:	so
  Security:	FreeBSD-EN-20:02.nmount

Modified:
  releng/11.3/sys/kern/vfs_mount.c
  releng/12.0/sys/kern/vfs_mount.c

Modified: releng/11.3/sys/kern/vfs_mount.c
==============================================================================
--- releng/11.3/sys/kern/vfs_mount.c	Tue Jan 28 18:53:14 2020	(r357215)
+++ releng/11.3/sys/kern/vfs_mount.c	Tue Jan 28 18:54:15 2020	(r357216)
@@ -591,7 +591,7 @@ vfs_donmount(struct thread *td, uint64_t fsflags, stru
 	 */
 	fstypelen = 0;
 	error = vfs_getopt(optlist, "fstype", (void **)&fstype, &fstypelen);
-	if (error || fstype[fstypelen - 1] != '\0') {
+	if (error || fstypelen <= 0 || fstype[fstypelen - 1] != '\0') {
 		error = EINVAL;
 		if (errmsg != NULL)
 			strncpy(errmsg, "Invalid fstype", errmsg_len);
@@ -599,7 +599,7 @@ vfs_donmount(struct thread *td, uint64_t fsflags, stru
 	}
 	fspathlen = 0;
 	error = vfs_getopt(optlist, "fspath", (void **)&fspath, &fspathlen);
-	if (error || fspath[fspathlen - 1] != '\0') {
+	if (error || fspathlen <= 0 || fspath[fspathlen - 1] != '\0') {
 		error = EINVAL;
 		if (errmsg != NULL)
 			strncpy(errmsg, "Invalid fspath", errmsg_len);

Modified: releng/12.0/sys/kern/vfs_mount.c
==============================================================================
--- releng/12.0/sys/kern/vfs_mount.c	Tue Jan 28 18:53:14 2020	(r357215)
+++ releng/12.0/sys/kern/vfs_mount.c	Tue Jan 28 18:54:15 2020	(r357216)
@@ -603,7 +603,7 @@ vfs_donmount(struct thread *td, uint64_t fsflags, stru
 	 */
 	fstypelen = 0;
 	error = vfs_getopt(optlist, "fstype", (void **)&fstype, &fstypelen);
-	if (error || fstype[fstypelen - 1] != '\0') {
+	if (error || fstypelen <= 0 || fstype[fstypelen - 1] != '\0') {
 		error = EINVAL;
 		if (errmsg != NULL)
 			strncpy(errmsg, "Invalid fstype", errmsg_len);
@@ -611,7 +611,7 @@ vfs_donmount(struct thread *td, uint64_t fsflags, stru
 	}
 	fspathlen = 0;
 	error = vfs_getopt(optlist, "fspath", (void **)&fspath, &fspathlen);
-	if (error || fspath[fspathlen - 1] != '\0') {
+	if (error || fspathlen <= 0 || fspath[fspathlen - 1] != '\0') {
 		error = EINVAL;
 		if (errmsg != NULL)
 			strncpy(errmsg, "Invalid fspath", errmsg_len);



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