Module Name:    src
Committed By:   martin
Date:           Sat Apr  1 15:51:16 UTC 2023

Modified Files:
        src/sys/compat/netbsd32 [netbsd-9]: netbsd32_fs.c

Log Message:
Pull up following revision(s) (requested by riastradh in ticket #1620):

        sys/compat/netbsd32/netbsd32_fs.c: revision 1.89

data_len == 0 on mount means "the kernel knows". Fixes amd on compat32.


To generate a diff of this commit:
cvs rdiff -u -r1.82.4.3 -r1.82.4.4 src/sys/compat/netbsd32/netbsd32_fs.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/compat/netbsd32/netbsd32_fs.c
diff -u src/sys/compat/netbsd32/netbsd32_fs.c:1.82.4.3 src/sys/compat/netbsd32/netbsd32_fs.c:1.82.4.4
--- src/sys/compat/netbsd32/netbsd32_fs.c:1.82.4.3	Wed Aug  3 11:05:51 2022
+++ src/sys/compat/netbsd32/netbsd32_fs.c	Sat Apr  1 15:51:16 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: netbsd32_fs.c,v 1.82.4.3 2022/08/03 11:05:51 martin Exp $	*/
+/*	$NetBSD: netbsd32_fs.c,v 1.82.4.4 2023/04/01 15:51:16 martin Exp $	*/
 
 /*
  * Copyright (c) 1998, 2001 Matthew R. Green
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: netbsd32_fs.c,v 1.82.4.3 2022/08/03 11:05:51 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: netbsd32_fs.c,v 1.82.4.4 2023/04/01 15:51:16 martin Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -828,7 +828,7 @@ netbsd32___mount50(struct lwp *l, const 
 		return error;
 
 	if (strcmp(mtype, MOUNT_TMPFS) == 0) {
-		if (data_len < sizeof(fs_args32.tmpfs_args))
+		if (data_len != 0 && data_len < sizeof(fs_args32.tmpfs_args))
 			return EINVAL;
 		if ((flags & MNT_GETARGS) == 0) {
 			error = copyin(data, &fs_args32.tmpfs_args, 
@@ -852,7 +852,7 @@ netbsd32___mount50(struct lwp *l, const 
 		data = &fs_args.tmpfs_args;
 		data_len = sizeof(fs_args.tmpfs_args);
 	} else if (strcmp(mtype, MOUNT_MFS) == 0) {
-		if (data_len < sizeof(fs_args32.mfs_args))
+		if (data_len != 0 && data_len < sizeof(fs_args32.mfs_args))
 			return EINVAL;
 		if ((flags & MNT_GETARGS) == 0) {
 			error = copyin(data, &fs_args32.mfs_args, 
@@ -873,7 +873,7 @@ netbsd32___mount50(struct lwp *l, const 
 	} else if ((strcmp(mtype, MOUNT_UFS) == 0) ||
 		   (strcmp(mtype, MOUNT_EXT2FS) == 0) ||
 		   (strcmp(mtype, MOUNT_LFS) == 0)) {
-		if (data_len < sizeof(fs_args32.ufs_args))
+		if (data_len != 0 && data_len < sizeof(fs_args32.ufs_args))
 			return EINVAL;
 		if ((flags & MNT_GETARGS) == 0) {
 			error = copyin(data, &fs_args32.ufs_args, 
@@ -887,7 +887,7 @@ netbsd32___mount50(struct lwp *l, const 
 		data = &fs_args.ufs_args;
 		data_len = sizeof(fs_args.ufs_args);
 	} else if (strcmp(mtype, MOUNT_CD9660) == 0) {
-		if (data_len < sizeof(fs_args32.iso_args))
+		if (data_len != 0 && data_len < sizeof(fs_args32.iso_args))
 			return EINVAL;
 		if ((flags & MNT_GETARGS) == 0) {
 			error = copyin(data, &fs_args32.iso_args, 
@@ -968,7 +968,7 @@ netbsd32___mount50(struct lwp *l, const 
 		data = &fs_args.udf_args;
 		data_len = sizeof(fs_args.udf_args);
 	} else if (strcmp(mtype, MOUNT_NFS) == 0) {
-		if (data_len < sizeof(fs_args32.nfs_args))
+		if (data_len != 0 && data_len < sizeof(fs_args32.nfs_args))
 			return EINVAL;
 		/* XXX: NFS requires copyin even with MNT_GETARGS */
 		if ((flags & MNT_GETARGS) == 0) {
@@ -996,7 +996,7 @@ netbsd32___mount50(struct lwp *l, const 
 		data = &fs_args.nfs_args;
 		data_len = sizeof(fs_args.nfs_args);
 	} else if (strcmp(mtype, MOUNT_NULL) == 0) {
-		if (data_len < sizeof(fs_args32.null_args))
+		if (data_len != 0 && data_len < sizeof(fs_args32.null_args))
 			return EINVAL;
 		if ((flags & MNT_GETARGS) == 0) {
 			error = copyin(data, &fs_args32.null_args, 
@@ -1021,7 +1021,8 @@ netbsd32___mount50(struct lwp *l, const 
 	if (flags & MNT_GETARGS) {
 		data_len = *retval;
 		if (strcmp(mtype, MOUNT_TMPFS) == 0) {
-			if (data_len != sizeof(fs_args.tmpfs_args))
+			if (data_len != 0 &&
+			    data_len != sizeof(fs_args.tmpfs_args))
 				return EINVAL;
 			fs_args32.tmpfs_args.ta_version =
 			    fs_args.tmpfs_args.ta_version;
@@ -1039,7 +1040,8 @@ netbsd32___mount50(struct lwp *l, const 
 				    sizeof(fs_args32.tmpfs_args));
 			*retval = sizeof(fs_args32.tmpfs_args);
 		} else if (strcmp(mtype, MOUNT_MFS) == 0) {
-			if (data_len != sizeof(fs_args.mfs_args))
+			if (data_len != 0 &&
+			    data_len != sizeof(fs_args.mfs_args))
 				return EINVAL;
 			NETBSD32PTR32(fs_args32.mfs_args.fspec,
 			    fs_args.mfs_args.fspec);
@@ -1052,7 +1054,8 @@ netbsd32___mount50(struct lwp *l, const 
 				    sizeof(fs_args32.mfs_args));
 			*retval = sizeof(fs_args32.mfs_args);
 		} else if (strcmp(mtype, MOUNT_UFS) == 0) {
-			if (data_len != sizeof(fs_args.ufs_args))
+			if (data_len != 0 &&
+			    data_len != sizeof(fs_args.ufs_args))
 				return EINVAL;
 			NETBSD32PTR32(fs_args32.ufs_args.fspec,
 			    fs_args.ufs_args.fspec);
@@ -1060,7 +1063,8 @@ netbsd32___mount50(struct lwp *l, const 
 			    sizeof(fs_args32.ufs_args));
 			*retval = sizeof(fs_args32.ufs_args);
 		} else if (strcmp(mtype, MOUNT_CD9660) == 0) {
-			if (data_len != sizeof(fs_args.iso_args))
+			if (data_len != 0 &&
+			    data_len != sizeof(fs_args.iso_args))
 				return EINVAL;
 			NETBSD32PTR32(fs_args32.iso_args.fspec,
 			    fs_args.iso_args.fspec);
@@ -1100,7 +1104,8 @@ netbsd32___mount50(struct lwp *l, const 
 				    sizeof(fs_args32.udf_args));
 			*retval = sizeof(fs_args32.udf_args);
 		} else if (strcmp(mtype, MOUNT_NFS) == 0) {
-			if (data_len != sizeof(fs_args.nfs_args))
+			if (data_len != 0 &&
+			    data_len != sizeof(fs_args.nfs_args))
 				return EINVAL;
 			NETBSD32PTR32(fs_args32.nfs_args.addr,
 			    fs_args.nfs_args.addr);
@@ -1120,7 +1125,8 @@ netbsd32___mount50(struct lwp *l, const 
 			    sizeof(fs_args32.nfs_args));
 			*retval = sizeof(fs_args32.nfs_args);
 		} else if (strcmp(mtype, MOUNT_NULL) == 0) {
-			if (data_len != sizeof(fs_args.null_args))
+			if (data_len != 0 &&
+			    data_len != sizeof(fs_args.null_args))
 				return EINVAL;
 			NETBSD32PTR32(fs_args32.null_args.la.target,
 			    fs_args.null_args.la.target);

Reply via email to