svn commit: r357216 - in releng: 11.3/sys/kern 12.0/sys/kern

Gordon Tetlow gordon at FreeBSD.org
Tue Jan 28 18:54:16 UTC 2020


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);


More information about the svn-src-all mailing list