CVS commit: [netbsd-9] src/sys/compat/netbsd32

2023-04-01 Thread Martin Husemann
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 
-__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 
 #include 
@@ -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, _args32.tmpfs_args, 
@@ -852,7 +852,7 @@ netbsd32___mount50(struct lwp *l, const 
 		data = _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, _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, _args32.ufs_args, 
@@ -887,7 +887,7 @@ netbsd32___mount50(struct lwp *l, const 
 		data = _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, _args32.iso_args, 
@@ -968,7 +968,7 @@ netbsd32___mount50(struct lwp *l, const 
 		data = _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 = _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, _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 

CVS commit: [netbsd-9] src/sys/compat/netbsd32

2023-04-01 Thread Martin Husemann
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.



CVS commit: [netbsd-9] src/sys/compat/netbsd32

2022-08-03 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Aug  3 11:05:51 UTC 2022

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

Log Message:
Pull up following revision(s), all via patch
(requested by riastradh in ticket #1489):

sys/compat/netbsd32/netbsd32_netbsd.c: revision 1.232
sys/compat/netbsd32/netbsd32_socket.c: revision 1.56
sys/compat/netbsd32/netbsd32_conv.h: revision 1.45
sys/compat/netbsd32/netbsd32_fs.c: revision 1.92
sys/compat/netbsd32/netbsd32.h: revision 1.137

The read/write/send/recv system calls return ssize_t because -1 is
returned on error.  Therefore we must restrict the lengths of any
buffers to NETBSD32_SSIZE_MAX with compat32 to avoid garbage return
values.

Fixes ATF lib/libc/sys/t_write:write_err.


To generate a diff of this commit:
cvs rdiff -u -r1.123.4.2 -r1.123.4.3 src/sys/compat/netbsd32/netbsd32.h
cvs rdiff -u -r1.38 -r1.38.4.1 src/sys/compat/netbsd32/netbsd32_conv.h
cvs rdiff -u -r1.82.4.2 -r1.82.4.3 src/sys/compat/netbsd32/netbsd32_fs.c
cvs rdiff -u -r1.228 -r1.228.2.1 src/sys/compat/netbsd32/netbsd32_netbsd.c
cvs rdiff -u -r1.49 -r1.49.4.1 src/sys/compat/netbsd32/netbsd32_socket.c

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



CVS commit: [netbsd-9] src/sys/compat/netbsd32

2022-08-03 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Aug  3 11:05:51 UTC 2022

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

Log Message:
Pull up following revision(s), all via patch
(requested by riastradh in ticket #1489):

sys/compat/netbsd32/netbsd32_netbsd.c: revision 1.232
sys/compat/netbsd32/netbsd32_socket.c: revision 1.56
sys/compat/netbsd32/netbsd32_conv.h: revision 1.45
sys/compat/netbsd32/netbsd32_fs.c: revision 1.92
sys/compat/netbsd32/netbsd32.h: revision 1.137

The read/write/send/recv system calls return ssize_t because -1 is
returned on error.  Therefore we must restrict the lengths of any
buffers to NETBSD32_SSIZE_MAX with compat32 to avoid garbage return
values.

Fixes ATF lib/libc/sys/t_write:write_err.


To generate a diff of this commit:
cvs rdiff -u -r1.123.4.2 -r1.123.4.3 src/sys/compat/netbsd32/netbsd32.h
cvs rdiff -u -r1.38 -r1.38.4.1 src/sys/compat/netbsd32/netbsd32_conv.h
cvs rdiff -u -r1.82.4.2 -r1.82.4.3 src/sys/compat/netbsd32/netbsd32_fs.c
cvs rdiff -u -r1.228 -r1.228.2.1 src/sys/compat/netbsd32/netbsd32_netbsd.c
cvs rdiff -u -r1.49 -r1.49.4.1 src/sys/compat/netbsd32/netbsd32_socket.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.h
diff -u src/sys/compat/netbsd32/netbsd32.h:1.123.4.2 src/sys/compat/netbsd32/netbsd32.h:1.123.4.3
--- src/sys/compat/netbsd32/netbsd32.h:1.123.4.2	Sun Apr 24 16:39:00 2022
+++ src/sys/compat/netbsd32/netbsd32.h	Wed Aug  3 11:05:51 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: netbsd32.h,v 1.123.4.2 2022/04/24 16:39:00 martin Exp $	*/
+/*	$NetBSD: netbsd32.h,v 1.123.4.3 2022/08/03 11:05:51 martin Exp $	*/
 
 /*
  * Copyright (c) 1998, 2001, 2008, 2015 Matthew R. Green
@@ -57,7 +57,7 @@
 #include 
 
 /*
- * first, define the basic types we need.
+ * first define the basic types we need, and any applicable limits.
  */
 
 typedef int32_t netbsd32_long;
@@ -72,6 +72,9 @@ typedef int32_t netbsd32_key_t;
 typedef int32_t netbsd32_intptr_t;
 typedef uint32_t netbsd32_uintptr_t;
 
+/* Note: 32-bit sparc defines ssize_t as long but still has same size as int. */
+#define	NETBSD32_SSIZE_MAX	INT32_MAX
+
 /* netbsd32_[u]int64 are machine dependent and defined below */
 
 /*

Index: src/sys/compat/netbsd32/netbsd32_conv.h
diff -u src/sys/compat/netbsd32/netbsd32_conv.h:1.38 src/sys/compat/netbsd32/netbsd32_conv.h:1.38.4.1
--- src/sys/compat/netbsd32/netbsd32_conv.h:1.38	Thu Feb 21 03:37:19 2019
+++ src/sys/compat/netbsd32/netbsd32_conv.h	Wed Aug  3 11:05:51 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: netbsd32_conv.h,v 1.38 2019/02/21 03:37:19 mrg Exp $	*/
+/*	$NetBSD: netbsd32_conv.h,v 1.38.4.1 2022/08/03 11:05:51 martin Exp $	*/
 
 /*
  * Copyright (c) 1998, 2001 Matthew R. Green
@@ -245,14 +245,16 @@ netbsd32_to_iovecin(const struct netbsd3
 int len)
 {
 	int i, error=0;
-	u_int32_t iov_base;
-	u_int32_t iov_len;
+	uint32_t iov_base;
+	uint32_t iov_len, total_iov_len;
+
 	/*
 	 * We could allocate an iov32p, do a copyin, and translate
 	 * each field and then free it all up, or we could copyin
 	 * each field separately.  I'm doing the latter to reduce
 	 * the number of MALLOC()s.
 	 */
+	total_iov_len = 0;
 	for (i = 0; i < len; i++, iovp++, iov32p++) {
 		if ((error = copyin(>iov_base, _base, sizeof(iov_base
 		return (error);
@@ -260,6 +262,19 @@ netbsd32_to_iovecin(const struct netbsd3
 		return (error);
 		iovp->iov_base = (void *)(u_long)iov_base;
 		iovp->iov_len = (size_t)iov_len;
+
+		/*
+		 * System calls return ssize_t because -1 is returned
+		 * on error.  Therefore we must restrict the length to
+		 * SSIZE_MAX (NETBSD32_SSIZE_MAX with compat32) to
+		 * avoid garbage return values.
+		 */
+		total_iov_len += iov_len;
+		if (iov_len > NETBSD32_SSIZE_MAX ||
+		total_iov_len > NETBSD32_SSIZE_MAX) {
+			return EINVAL;
+			break;
+		}
 	}
 	return error;
 }

Index: src/sys/compat/netbsd32/netbsd32_fs.c
diff -u src/sys/compat/netbsd32/netbsd32_fs.c:1.82.4.2 src/sys/compat/netbsd32/netbsd32_fs.c:1.82.4.3
--- src/sys/compat/netbsd32/netbsd32_fs.c:1.82.4.2	Sun Apr 24 16:39:00 2022
+++ src/sys/compat/netbsd32/netbsd32_fs.c	Wed Aug  3 11:05:51 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: netbsd32_fs.c,v 1.82.4.2 2022/04/24 16:39:00 martin Exp $	*/
+/*	$NetBSD: netbsd32_fs.c,v 1.82.4.3 2022/08/03 11:05:51 martin Exp $	*/
 
 /*
  * Copyright (c) 1998, 2001 Matthew R. Green
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: netbsd32_fs.c,v 1.82.4.2 2022/04/24 16:39:00 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: netbsd32_fs.c,v 1.82.4.3 2022/08/03 11:05:51 martin Exp $");
 
 #include 
 #include 
@@ -176,7 +176,8 @@ dofilereadv32(int fd, struct file *fp, s
 		 * Therefore we must restrict the length to SSIZE_MAX to
 		 * avoid garbage return values.
 		 */
-		if (iov->iov_len > 

CVS commit: [netbsd-9] src/sys/compat/netbsd32

2022-08-03 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Aug  3 10:58:58 UTC 2022

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

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

sys/compat/netbsd32/netbsd32_nfssvc.c: revision 1.7

compat_netbsd32: Copy out 32-bit version in nfssvc32_nsd_out.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.6.4.1 src/sys/compat/netbsd32/netbsd32_nfssvc.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_nfssvc.c
diff -u src/sys/compat/netbsd32/netbsd32_nfssvc.c:1.6 src/sys/compat/netbsd32/netbsd32_nfssvc.c:1.6.4.1
--- src/sys/compat/netbsd32/netbsd32_nfssvc.c:1.6	Sun Jan 27 02:08:40 2019
+++ src/sys/compat/netbsd32/netbsd32_nfssvc.c	Wed Aug  3 10:58:58 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: netbsd32_nfssvc.c,v 1.6 2019/01/27 02:08:40 pgoyette Exp $	*/
+/*	$NetBSD: netbsd32_nfssvc.c,v 1.6.4.1 2022/08/03 10:58:58 martin Exp $	*/
 
 /*
  * Copyright (c) 2015 Matthew R. Green
@@ -29,7 +29,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: netbsd32_nfssvc.c,v 1.6 2019/01/27 02:08:40 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: netbsd32_nfssvc.c,v 1.6.4.1 2022/08/03 10:58:58 martin Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_nfs.h"
@@ -134,7 +134,7 @@ nfssvc32_nsd_out(void *argp, const struc
 	args32.nsd_key[0] = nsd->nsd_key[0];
 	args32.nsd_key[1] = nsd->nsd_key[1];
 
-	return copyout(nsd, argp, sizeof *nsd);
+	return copyout(, argp, sizeof args32);
 }
 
 static int



CVS commit: [netbsd-9] src/sys/compat/netbsd32

2022-08-03 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Aug  3 10:58:58 UTC 2022

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

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

sys/compat/netbsd32/netbsd32_nfssvc.c: revision 1.7

compat_netbsd32: Copy out 32-bit version in nfssvc32_nsd_out.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.6.4.1 src/sys/compat/netbsd32/netbsd32_nfssvc.c

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



CVS commit: [netbsd-9] src/sys/compat/netbsd32

2020-03-09 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Mar  9 09:55:52 UTC 2020

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

Log Message:
Pull up following revision(s) (requested by pgoyette in ticket #770):

sys/compat/netbsd32/netbsd32_mod.c: revision 1.19

If a syscall requires a module to be autoloaded, the initial invocation
of that syscall will return ERESTART.  For amd64's netbsd32_syscall()
that means we need to back up the PC saved in the trap frame so we can
re-issue the syscall instruction.  For "normal" syscall traps, we saved
the instruction length in the trap frame, but this was missing for the
oosyscall/lcall path.  Since the PC was not backed up, the kernel-only
value ERESTART was returned to userland, causing all sort of grief for
old compat_netbsd32 executables!

XXX Pullup-9


To generate a diff of this commit:
cvs rdiff -u -r1.15.4.2 -r1.15.4.3 src/sys/compat/netbsd32/netbsd32_mod.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_mod.c
diff -u src/sys/compat/netbsd32/netbsd32_mod.c:1.15.4.2 src/sys/compat/netbsd32/netbsd32_mod.c:1.15.4.3
--- src/sys/compat/netbsd32/netbsd32_mod.c:1.15.4.2	Mon Mar  9 05:36:24 2020
+++ src/sys/compat/netbsd32/netbsd32_mod.c	Mon Mar  9 09:55:52 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: netbsd32_mod.c,v 1.15.4.2 2020/03/09 05:36:24 martin Exp $	*/
+/*	$NetBSD: netbsd32_mod.c,v 1.15.4.3 2020/03/09 09:55:52 martin Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -59,7 +59,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: netbsd32_mod.c,v 1.15.4.2 2020/03/09 05:36:24 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: netbsd32_mod.c,v 1.15.4.3 2020/03/09 09:55:52 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_execfmt.h"
@@ -148,8 +148,9 @@ amd64_oosyscall_handle(struct proc *p, s
 	copyin((void *)frame->tf_rip, tmp, sz) == 0 &&
 	memcmp(tmp, lcall, sz) == 0) {
 
-		/* Advance past the lcall. */
+		/* Advance past the lcall and save instruction size. */
 		frame->tf_rip += sz;
+		frame->tf_err = sz;
 
 		/* Do the syscall */
 		p->p_md.md_syscall(frame);
@@ -157,7 +158,7 @@ amd64_oosyscall_handle(struct proc *p, s
 	} else
 		return EPASSTHROUGH;
 }
-#endif
+#endif /* defined(__amd64__) */
 
 static int
 compat_netbsd32_modcmd(modcmd_t cmd, void *arg)
@@ -175,14 +176,14 @@ compat_netbsd32_modcmd(modcmd_t cmd, voi
 #if defined(__amd64__)
 			MODULE_HOOK_SET(amd64_oosyscall_hook, "nb32oo",
 			amd64_oosyscall_handle);
-#endif
+#endif /* defined(__amd64__) */
 		}
 		return error;
 
 	case MODULE_CMD_FINI:
 #if defined(__amd64__)
 		MODULE_HOOK_UNSET(amd64_oosyscall_hook);
-#endif
+#endif /* defined(__amd64__) */
 		netbsd32_machdep_md_fini();
 		netbsd32_sysctl_fini();
 		netbsd32_kern_proc_32_fini();
@@ -196,7 +197,7 @@ compat_netbsd32_modcmd(modcmd_t cmd, voi
 #if defined(__amd64__)
 			MODULE_HOOK_SET(amd64_oosyscall_hook, "nb32oo",
 			amd64_oosyscall_handle);
-#endif
+#endif /* defined(__amd64__) */
 		}
 		return error;
 



CVS commit: [netbsd-9] src/sys/compat/netbsd32

2020-03-09 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Mar  9 09:55:52 UTC 2020

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

Log Message:
Pull up following revision(s) (requested by pgoyette in ticket #770):

sys/compat/netbsd32/netbsd32_mod.c: revision 1.19

If a syscall requires a module to be autoloaded, the initial invocation
of that syscall will return ERESTART.  For amd64's netbsd32_syscall()
that means we need to back up the PC saved in the trap frame so we can
re-issue the syscall instruction.  For "normal" syscall traps, we saved
the instruction length in the trap frame, but this was missing for the
oosyscall/lcall path.  Since the PC was not backed up, the kernel-only
value ERESTART was returned to userland, causing all sort of grief for
old compat_netbsd32 executables!

XXX Pullup-9


To generate a diff of this commit:
cvs rdiff -u -r1.15.4.2 -r1.15.4.3 src/sys/compat/netbsd32/netbsd32_mod.c

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



CVS commit: [netbsd-9] src/sys/compat/netbsd32

2020-03-08 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Mar  9 05:36:24 UTC 2020

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

Log Message:
Apply patch, requested by pgoyette in ticket #775 to fix fallout from
ticket #762:

sys/compat/netbsd32/netbsd32_mod.c  (patched)

Fiy arguments to MODULE_HOOK_SET for the new amd64_oosyscall_hook.


To generate a diff of this commit:
cvs rdiff -u -r1.15.4.1 -r1.15.4.2 src/sys/compat/netbsd32/netbsd32_mod.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_mod.c
diff -u src/sys/compat/netbsd32/netbsd32_mod.c:1.15.4.1 src/sys/compat/netbsd32/netbsd32_mod.c:1.15.4.2
--- src/sys/compat/netbsd32/netbsd32_mod.c:1.15.4.1	Sun Mar  8 10:54:43 2020
+++ src/sys/compat/netbsd32/netbsd32_mod.c	Mon Mar  9 05:36:24 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: netbsd32_mod.c,v 1.15.4.1 2020/03/08 10:54:43 martin Exp $	*/
+/*	$NetBSD: netbsd32_mod.c,v 1.15.4.2 2020/03/09 05:36:24 martin Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -59,7 +59,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: netbsd32_mod.c,v 1.15.4.1 2020/03/08 10:54:43 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: netbsd32_mod.c,v 1.15.4.2 2020/03/09 05:36:24 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_execfmt.h"
@@ -173,7 +173,7 @@ compat_netbsd32_modcmd(modcmd_t cmd, voi
 			netbsd32_machdep_md_init();
 			netbsd32_kern_proc_32_init();
 #if defined(__amd64__)
-			MODULE_HOOK_SET(amd64_oosyscall_hook,
+			MODULE_HOOK_SET(amd64_oosyscall_hook, "nb32oo",
 			amd64_oosyscall_handle);
 #endif
 		}
@@ -194,7 +194,7 @@ compat_netbsd32_modcmd(modcmd_t cmd, voi
 			netbsd32_sysctl_init();
 			netbsd32_machdep_md_init();
 #if defined(__amd64__)
-			MODULE_HOOK_SET(amd64_oosyscall_hook,
+			MODULE_HOOK_SET(amd64_oosyscall_hook, "nb32oo",
 			amd64_oosyscall_handle);
 #endif
 		}



CVS commit: [netbsd-9] src/sys/compat/netbsd32

2020-03-08 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Mar  9 05:36:24 UTC 2020

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

Log Message:
Apply patch, requested by pgoyette in ticket #775 to fix fallout from
ticket #762:

sys/compat/netbsd32/netbsd32_mod.c  (patched)

Fiy arguments to MODULE_HOOK_SET for the new amd64_oosyscall_hook.


To generate a diff of this commit:
cvs rdiff -u -r1.15.4.1 -r1.15.4.2 src/sys/compat/netbsd32/netbsd32_mod.c

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



CVS commit: [netbsd-9] src/sys/compat/netbsd32

2020-03-08 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Mar  8 10:38:10 UTC 2020

Modified Files:
src/sys/compat/netbsd32 [netbsd-9]: netbsd32_syscall.h
netbsd32_syscallargs.h netbsd32_syscalls.c
netbsd32_syscalls_autoload.c netbsd32_sysent.c
netbsd32_systrace_args.c

Log Message:
Regen (for ticket #761)


To generate a diff of this commit:
cvs rdiff -u -r1.142.2.1 -r1.142.2.2 \
src/sys/compat/netbsd32/netbsd32_syscall.h
cvs rdiff -u -r1.141.2.1 -r1.141.2.2 \
src/sys/compat/netbsd32/netbsd32_syscallargs.h \
src/sys/compat/netbsd32/netbsd32_syscalls.c
cvs rdiff -u -r1.21.2.1 -r1.21.2.2 \
src/sys/compat/netbsd32/netbsd32_syscalls_autoload.c
cvs rdiff -u -r1.140.2.1 -r1.140.2.2 \
src/sys/compat/netbsd32/netbsd32_sysent.c
cvs rdiff -u -r1.32.2.1 -r1.32.2.2 \
src/sys/compat/netbsd32/netbsd32_systrace_args.c

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



CVS commit: [netbsd-9] src/sys/compat/netbsd32

2020-03-08 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Mar  8 10:38:10 UTC 2020

Modified Files:
src/sys/compat/netbsd32 [netbsd-9]: netbsd32_syscall.h
netbsd32_syscallargs.h netbsd32_syscalls.c
netbsd32_syscalls_autoload.c netbsd32_sysent.c
netbsd32_systrace_args.c

Log Message:
Regen (for ticket #761)


To generate a diff of this commit:
cvs rdiff -u -r1.142.2.1 -r1.142.2.2 \
src/sys/compat/netbsd32/netbsd32_syscall.h
cvs rdiff -u -r1.141.2.1 -r1.141.2.2 \
src/sys/compat/netbsd32/netbsd32_syscallargs.h \
src/sys/compat/netbsd32/netbsd32_syscalls.c
cvs rdiff -u -r1.21.2.1 -r1.21.2.2 \
src/sys/compat/netbsd32/netbsd32_syscalls_autoload.c
cvs rdiff -u -r1.140.2.1 -r1.140.2.2 \
src/sys/compat/netbsd32/netbsd32_sysent.c
cvs rdiff -u -r1.32.2.1 -r1.32.2.2 \
src/sys/compat/netbsd32/netbsd32_systrace_args.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_syscall.h
diff -u src/sys/compat/netbsd32/netbsd32_syscall.h:1.142.2.1 src/sys/compat/netbsd32/netbsd32_syscall.h:1.142.2.2
--- src/sys/compat/netbsd32/netbsd32_syscall.h:1.142.2.1	Mon Nov  4 14:47:33 2019
+++ src/sys/compat/netbsd32/netbsd32_syscall.h	Sun Mar  8 10:38:10 2020
@@ -1,10 +1,10 @@
-/* $NetBSD: netbsd32_syscall.h,v 1.142.2.1 2019/11/04 14:47:33 martin Exp $ */
+/* $NetBSD: netbsd32_syscall.h,v 1.142.2.2 2020/03/08 10:38:10 martin Exp $ */
 
 /*
  * System call numbers.
  *
  * DO NOT EDIT-- this file is automatically generated.
- * created from	NetBSD: syscalls.master,v 1.127.2.1 2019/11/04 14:46:57 martin Exp
+ * created from	NetBSD: syscalls.master,v 1.127.2.2 2020/03/08 10:36:38 martin Exp
  */
 
 #ifndef _NETBSD32_SYS_SYSCALL_H_
@@ -432,13 +432,10 @@
 /* syscall: "compat_50_netbsd32_quotactl" ret: "int" args: "netbsd32_charp" "int" "int" "netbsd32_voidp" */
 #define	NETBSD32_SYS_compat_50_netbsd32_quotactl	148
 
-/* syscall: "compat_43_oquota" ret: "int" args: */
-#define	NETBSD32_SYS_compat_43_oquota	149
-
 #else
 /* 148 is excluded compat_netbsd32_quotactl */
-/* 149 is excluded compat_netbsd32_quota */
 #endif
+/* 149 is excluded compat_netbsd32_quota */
 /* syscall: "compat_43_netbsd32_ogetsockname" ret: "int" args: "int" "netbsd32_voidp" "netbsd32_intp" */
 #define	NETBSD32_SYS_compat_43_netbsd32_ogetsockname	150
 

Index: src/sys/compat/netbsd32/netbsd32_syscallargs.h
diff -u src/sys/compat/netbsd32/netbsd32_syscallargs.h:1.141.2.1 src/sys/compat/netbsd32/netbsd32_syscallargs.h:1.141.2.2
--- src/sys/compat/netbsd32/netbsd32_syscallargs.h:1.141.2.1	Mon Nov  4 14:47:33 2019
+++ src/sys/compat/netbsd32/netbsd32_syscallargs.h	Sun Mar  8 10:38:10 2020
@@ -1,10 +1,10 @@
-/* $NetBSD: netbsd32_syscallargs.h,v 1.141.2.1 2019/11/04 14:47:33 martin Exp $ */
+/* $NetBSD: netbsd32_syscallargs.h,v 1.141.2.2 2020/03/08 10:38:10 martin Exp $ */
 
 /*
  * System call argument lists.
  *
  * DO NOT EDIT-- this file is automatically generated.
- * created from	NetBSD: syscalls.master,v 1.127.2.1 2019/11/04 14:46:57 martin Exp
+ * created from	NetBSD: syscalls.master,v 1.127.2.2 2020/03/08 10:36:38 martin Exp
  */
 
 #ifndef _NETBSD32_SYS_SYSCALLARGS_H_
@@ -2899,8 +2899,6 @@ int	sys_setsid(struct lwp *, const void 
 #if defined(QUOTA) || !defined(_KERNEL_OPT)
 int	compat_50_netbsd32_quotactl(struct lwp *, const struct compat_50_netbsd32_quotactl_args *, register_t *);
 
-int	compat_43_sys_quota(struct lwp *, const void *, register_t *);
-
 #else
 #endif
 int	compat_43_netbsd32_ogetsockname(struct lwp *, const struct compat_43_netbsd32_ogetsockname_args *, register_t *);
Index: src/sys/compat/netbsd32/netbsd32_syscalls.c
diff -u src/sys/compat/netbsd32/netbsd32_syscalls.c:1.141.2.1 src/sys/compat/netbsd32/netbsd32_syscalls.c:1.141.2.2
--- src/sys/compat/netbsd32/netbsd32_syscalls.c:1.141.2.1	Mon Nov  4 14:47:33 2019
+++ src/sys/compat/netbsd32/netbsd32_syscalls.c	Sun Mar  8 10:38:10 2020
@@ -1,14 +1,14 @@
-/* $NetBSD: netbsd32_syscalls.c,v 1.141.2.1 2019/11/04 14:47:33 martin Exp $ */
+/* $NetBSD: netbsd32_syscalls.c,v 1.141.2.2 2020/03/08 10:38:10 martin Exp $ */
 
 /*
  * System call names.
  *
  * DO NOT EDIT-- this file is automatically generated.
- * created from	NetBSD: syscalls.master,v 1.127.2.1 2019/11/04 14:46:57 martin Exp
+ * created from	NetBSD: syscalls.master,v 1.127.2.2 2020/03/08 10:36:38 martin Exp
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: netbsd32_syscalls.c,v 1.141.2.1 2019/11/04 14:47:33 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: netbsd32_syscalls.c,v 1.141.2.2 2020/03/08 10:38:10 martin Exp $");
 
 #if defined(_KERNEL_OPT)
 #if defined(_KERNEL_OPT)
@@ -180,11 +180,10 @@ const char *const netbsd32_syscallnames[
 	/* 147 */	"setsid",
 #if defined(QUOTA) || !defined(_KERNEL_OPT)
 	/* 148 */	"compat_50_netbsd32_quotactl",
-	/* 149 */	"compat_43_oquota",
 #else
 	/* 148 */	"#148 (excluded compat_netbsd32_quotactl)",
-	/* 149 */	

CVS commit: [netbsd-9] src/sys/compat/netbsd32

2020-03-08 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Mar  8 10:36:38 UTC 2020

Modified Files:
src/sys/compat/netbsd32 [netbsd-9]: netbsd32_compat_43.c
syscalls.master

Log Message:
Pull up following revision(s) (requested by pgoyette in ticket #761):

sys/compat/netbsd32/syscalls.master: revision 1.132
sys/compat/netbsd32/netbsd32_compat_43.c: revision 1.60

Properly mark netbsd32_compat_43 syscalls that are directly implemented
by calling their compat_43 equivalents.  With these changes, and with
built-in versions of COMPAT_NETBSD32, COMPAT_NOMID, and COMPAT_09, I can
now run a netbsd-0.9 statically linked i386 (32-bit) version of /bin/ls
on a 9.99.x amd64 host!

Addresses PR kern/55047 but more changes coming to handle non-built-in
modules.

XXX pullup-9


To generate a diff of this commit:
cvs rdiff -u -r1.57.4.2 -r1.57.4.3 \
src/sys/compat/netbsd32/netbsd32_compat_43.c
cvs rdiff -u -r1.127.2.1 -r1.127.2.2 src/sys/compat/netbsd32/syscalls.master

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_compat_43.c
diff -u src/sys/compat/netbsd32/netbsd32_compat_43.c:1.57.4.2 src/sys/compat/netbsd32/netbsd32_compat_43.c:1.57.4.3
--- src/sys/compat/netbsd32/netbsd32_compat_43.c:1.57.4.2	Thu Jan  2 09:50:34 2020
+++ src/sys/compat/netbsd32/netbsd32_compat_43.c	Sun Mar  8 10:36:38 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: netbsd32_compat_43.c,v 1.57.4.2 2020/01/02 09:50:34 martin Exp $	*/
+/*	$NetBSD: netbsd32_compat_43.c,v 1.57.4.3 2020/03/08 10:36:38 martin Exp $	*/
 
 /*
  * Copyright (c) 1998, 2001 Matthew R. Green
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: netbsd32_compat_43.c,v 1.57.4.2 2020/01/02 09:50:34 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: netbsd32_compat_43.c,v 1.57.4.3 2020/03/08 10:36:38 martin Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_compat_43.h"
@@ -769,6 +769,26 @@ static struct syscall_package compat_net
 	(sy_call_t *)compat_43_netbsd32_sigsetmask },
 	{ NETBSD32_SYS_compat_43_netbsd32_osigstack, 0,
 	(sy_call_t *)compat_43_netbsd32_osigstack },
+/*
+ * These syscalls are provided by emul_netbsd compat_43 code, but their
+ * entry points must still be loaded in the emul_netbsd32 disatch table
+ */
+	{ NETBSD32_SYS_compat_43_ogetpagesize, 0,
+	(sy_call_t *)compat_43_sys_getpagesize },
+	{ NETBSD32_SYS_compat_43_ogetdtablesize, 0,
+	(sy_call_t *)compat_43_sys_getdtablesize},
+	{ NETBSD32_SYS_compat_43_ogethostid, 0,
+	(sy_call_t *)compat_43_sys_gethostid },
+	{ NETBSD32_SYS_compat_43_owait, 0,
+	(sy_call_t *)compat_43_sys_wait },
+/*
+ * Skip oquota since it isn't part of compat_43
+ *	{ NETBSD32_SYS_compat_43_oquota, 0,
+ *	(sy_call_t *)compat_43_sys_quota },
+ */
+
+/* End of compat_43 syscalls */
+
 	{ 0, 0, NULL }
 }; 
 

Index: src/sys/compat/netbsd32/syscalls.master
diff -u src/sys/compat/netbsd32/syscalls.master:1.127.2.1 src/sys/compat/netbsd32/syscalls.master:1.127.2.2
--- src/sys/compat/netbsd32/syscalls.master:1.127.2.1	Mon Nov  4 14:46:57 2019
+++ src/sys/compat/netbsd32/syscalls.master	Sun Mar  8 10:36:38 2020
@@ -1,4 +1,4 @@
-	$NetBSD: syscalls.master,v 1.127.2.1 2019/11/04 14:46:57 martin Exp $
+	$NetBSD: syscalls.master,v 1.127.2.2 2020/03/08 10:36:38 martin Exp $
 
 ;	from: NetBSD: syscalls.master,v 1.81 1998/07/05 08:49:50 jonathan Exp
 ;	@(#)syscalls.master	8.2 (Berkeley) 1/13/94
@@ -183,7 +183,7 @@
 			{ int|netbsd32||ogetkerninfo(int op, \
 			netbsd32_charp where, netbsd32_intp size, \
 			int arg); }
-64	COMPAT_43 MODULAR compat_netbsd32_43	\
+64	COMPAT_43 MODULAR compat_43	\
 			{ int|sys||getpagesize(void); } ogetpagesize
 65	COMPAT_12 MODULAR compat_netbsd32_12	\
 			{ int|netbsd32||msync(netbsd32_voidp addr, \
@@ -219,7 +219,7 @@
 			{ int|netbsd32||setitimer(int which, \
 			netbsd32_itimerval50p_t itv, \
 			netbsd32_itimerval50p_t oitv); }
-84	COMPAT_43 MODULAR compat_netbsd32_43	\
+84	COMPAT_43 MODULAR compat_43	\
 			{ int|sys||wait(void); } owait
 85	COMPAT_12 MODULAR compat_netbsd32_12	\
 			{ int|netbsd32||oswapon(netbsd32_charp name); }
@@ -232,7 +232,7 @@
 88	COMPAT_43 MODULAR compat_netbsd32_43	\
 			{ int|netbsd32||osethostname(netbsd32_charp hostname, \
 			u_int len); }
-89	COMPAT_43 MODULAR compat_netbsd32_43	\
+89	COMPAT_43 MODULAR compat_43	\
 			{ int|sys||getdtablesize(void); } ogetdtablesize
 90	STD		{ int|netbsd32||dup2(int from, int to); }
 91	UNIMPL		getdopt
@@ -343,7 +343,7 @@
 141	COMPAT_43 MODULAR compat_netbsd32_43	\
 			{ int|netbsd32||ogetpeername(int fdes, \
 			netbsd32_voidp asa, netbsd32_intp alen); }
-142	COMPAT_43 MODULAR compat_netbsd32_43	\
+142	COMPAT_43 MODULAR compat_43	\
 			{ int32_t|sys||gethostid(void); } ogethostid
 143	COMPAT_43 MODULAR compat_netbsd32_43	\
 			{ int|netbsd32||sethostid(int32_t hostid); }
@@ -360,12 +360,10 @@
 148	COMPAT_50 MODULAR compat_netbsd32_50	\
 			{ 

CVS commit: [netbsd-9] src/sys/compat/netbsd32

2020-03-08 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Mar  8 10:36:38 UTC 2020

Modified Files:
src/sys/compat/netbsd32 [netbsd-9]: netbsd32_compat_43.c
syscalls.master

Log Message:
Pull up following revision(s) (requested by pgoyette in ticket #761):

sys/compat/netbsd32/syscalls.master: revision 1.132
sys/compat/netbsd32/netbsd32_compat_43.c: revision 1.60

Properly mark netbsd32_compat_43 syscalls that are directly implemented
by calling their compat_43 equivalents.  With these changes, and with
built-in versions of COMPAT_NETBSD32, COMPAT_NOMID, and COMPAT_09, I can
now run a netbsd-0.9 statically linked i386 (32-bit) version of /bin/ls
on a 9.99.x amd64 host!

Addresses PR kern/55047 but more changes coming to handle non-built-in
modules.

XXX pullup-9


To generate a diff of this commit:
cvs rdiff -u -r1.57.4.2 -r1.57.4.3 \
src/sys/compat/netbsd32/netbsd32_compat_43.c
cvs rdiff -u -r1.127.2.1 -r1.127.2.2 src/sys/compat/netbsd32/syscalls.master

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



CVS commit: [netbsd-9] src/sys/compat/netbsd32

2020-02-13 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Feb 13 19:28:15 UTC 2020

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

Log Message:
Pull up following revision(s) (requested by mlelstv in ticket #706):

sys/compat/netbsd32/netbsd32_ioctl.c: revision 1.108
sys/compat/netbsd32/netbsd32_ioctl.c: revision 1.109

Don't use strlcpy to copy untrusted input, it may not be NUL-terminated.

Where did the +1 came from ?


To generate a diff of this commit:
cvs rdiff -u -r1.103 -r1.103.2.1 src/sys/compat/netbsd32/netbsd32_ioctl.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_ioctl.c
diff -u src/sys/compat/netbsd32/netbsd32_ioctl.c:1.103 src/sys/compat/netbsd32/netbsd32_ioctl.c:1.103.2.1
--- src/sys/compat/netbsd32/netbsd32_ioctl.c:1.103	Fri May 17 07:37:12 2019
+++ src/sys/compat/netbsd32/netbsd32_ioctl.c	Thu Feb 13 19:28:15 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: netbsd32_ioctl.c,v 1.103 2019/05/17 07:37:12 msaitoh Exp $	*/
+/*	$NetBSD: netbsd32_ioctl.c,v 1.103.2.1 2020/02/13 19:28:15 martin Exp $	*/
 
 /*
  * Copyright (c) 1998, 2001 Matthew R. Green
@@ -31,7 +31,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: netbsd32_ioctl.c,v 1.103 2019/05/17 07:37:12 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: netbsd32_ioctl.c,v 1.103.2.1 2020/02/13 19:28:15 martin Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_ntp.h"
@@ -146,7 +146,7 @@ netbsd32_to_if_addrprefreq(const struct 
 struct if_addrprefreq *ifap, u_long cmd)
 {
 
-	strlcpy(ifap->ifap_name, ifap32->ifap_name, sizeof(ifap->ifap_name));
+	memcpy(ifap->ifap_name, ifap32->ifap_name, IFNAMSIZ);
 	ifap->ifap_preference = ifap32->ifap_preference;
 	memcpy(>ifap_addr, >ifap_addr,
 	uimin(ifap32->ifap_addr.ss_len, _SS_MAXSIZE));
@@ -385,7 +385,7 @@ netbsd32_to_ieee80211req(struct netbsd32
 struct ieee80211req *ireq, u_long cmd)
 {
 
-	strlcpy(ireq->i_name, ireq32->i_name, IFNAMSIZ);
+	memcpy(ireq->i_name, ireq32->i_name, IFNAMSIZ);
 	ireq->i_type = ireq32->i_type;
 	ireq->i_val = ireq32->i_val;
 	ireq->i_len = ireq32->i_len;
@@ -398,7 +398,7 @@ netbsd32_to_ieee80211_nwkey(struct netbs
 {
 	int i;
 
-	strlcpy(nwk->i_name, nwk32->i_name, IFNAMSIZ);
+	memcpy(nwk->i_name, nwk32->i_name, IFNAMSIZ);
 	nwk->i_wepon = nwk32->i_wepon;
 	nwk->i_defkid = nwk32->i_defkid;
 	for (i = 0; i < IEEE80211_WEP_NKID; i++) {
@@ -629,7 +629,7 @@ netbsd32_from_if_addrprefreq(const struc
 struct netbsd32_if_addrprefreq *ifap32, u_long cmd)
 {
 
-	strlcpy(ifap32->ifap_name, ifap->ifap_name, sizeof(ifap32->ifap_name));
+	memcpy(ifap32->ifap_name, ifap->ifap_name, IFNAMSIZ);
 	ifap32->ifap_preference = ifap->ifap_preference;
 	memcpy(>ifap_addr, >ifap_addr,
 	uimin(ifap->ifap_addr.ss_len, _SS_MAXSIZE));
@@ -864,7 +864,7 @@ netbsd32_from_ieee80211req(struct ieee80
 struct netbsd32_ieee80211req *ireq32, u_long cmd)
 {
 
-	strlcpy(ireq32->i_name, ireq->i_name, IFNAMSIZ);
+	memcpy(ireq32->i_name, ireq->i_name, IFNAMSIZ);
 	ireq32->i_type = ireq->i_type;
 	ireq32->i_val = ireq->i_val;
 	ireq32->i_len = ireq->i_len;
@@ -877,7 +877,7 @@ netbsd32_from_ieee80211_nwkey(struct iee
 {
 	int i;
 
-	strlcpy(nwk32->i_name, nwk->i_name, IFNAMSIZ);
+	memcpy(nwk32->i_name, nwk->i_name, IFNAMSIZ);
 	nwk32->i_wepon = nwk->i_wepon;
 	nwk32->i_defkid = nwk->i_defkid;
 	for (i = 0; i < IEEE80211_WEP_NKID; i++) {



CVS commit: [netbsd-9] src/sys/compat/netbsd32

2020-02-13 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Feb 13 19:28:15 UTC 2020

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

Log Message:
Pull up following revision(s) (requested by mlelstv in ticket #706):

sys/compat/netbsd32/netbsd32_ioctl.c: revision 1.108
sys/compat/netbsd32/netbsd32_ioctl.c: revision 1.109

Don't use strlcpy to copy untrusted input, it may not be NUL-terminated.

Where did the +1 came from ?


To generate a diff of this commit:
cvs rdiff -u -r1.103 -r1.103.2.1 src/sys/compat/netbsd32/netbsd32_ioctl.c

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



CVS commit: [netbsd-9] src/sys/compat/netbsd32

2019-11-19 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Tue Nov 19 13:33:21 UTC 2019

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

Log Message:
Pull up following revision(s) (requested by rin in ticket #456):

sys/compat/netbsd32/netbsd32_signal.c: revision 1.46
sys/compat/netbsd32/netbsd32_signal.c: revision 1.47
sys/compat/netbsd32/netbsd32_signal.c: revision 1.48
sys/compat/netbsd32/netbsd32_signal.c: revision 1.49
sys/compat/netbsd32/netbsd32_signal.c: revision 1.50

Belatedly catch up with kern_sig.c rev 1.358:
Provide syscall information with SIGTRAP TRAP_SCE/TRAP_SCX so that
picotrace/truss, for example, works fine on COMPAT_NETBSD32.
With some minor changes:
- Centralize netbsd32_si{,32}_si{32,}() into netbsd32_ksi{,32}_ksi{32,}().
- Provide si_status with SIGCHLD.
- Remove the remaining of SA.

Sort by signal numbers as far as possible, adjust locations of functions.
No functional changes intended.

XXX
pullup to netbsd-9

Provide _ptrace_state for SIGTRAP with TRAP_EXEC, TRAP_CHLD, or TRAP_LWP.
Pointed out by kamil. Thanks!

XXX
pullup to netbsd-9

When converting siginfo, examine si_code at the beginning,
as explained in siginfo(2).
- If it is SI_NOINFO, there's no additional information.
- If it is non-positive, i.e., codes described in siginfo(2),
   we need to fill in _rt.

XXX
Description for SA_ASYNCIO in siginfo(2) seems outdated;
neither si_fd nor si_band are filled in with that code.

XXX
pullup to netbsd-9

TRAP_EXEC does not have extra fields to be filled in at the moment.
Explicitly ignore fields for now.
Pointed out by kamil. Thanks!

XXX
pullup to netbsd-9


To generate a diff of this commit:
cvs rdiff -u -r1.45 -r1.45.8.1 src/sys/compat/netbsd32/netbsd32_signal.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_signal.c
diff -u src/sys/compat/netbsd32/netbsd32_signal.c:1.45 src/sys/compat/netbsd32/netbsd32_signal.c:1.45.8.1
--- src/sys/compat/netbsd32/netbsd32_signal.c:1.45	Sun Dec 17 20:59:27 2017
+++ src/sys/compat/netbsd32/netbsd32_signal.c	Tue Nov 19 13:33:21 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: netbsd32_signal.c,v 1.45 2017/12/17 20:59:27 christos Exp $	*/
+/*	$NetBSD: netbsd32_signal.c,v 1.45.8.1 2019/11/19 13:33:21 martin Exp $	*/
 
 /*
  * Copyright (c) 1998, 2001 Matthew R. Green
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: netbsd32_signal.c,v 1.45 2017/12/17 20:59:27 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: netbsd32_signal.c,v 1.45.8.1 2019/11/19 13:33:21 martin Exp $");
 
 #if defined(_KERNEL_OPT) 
 #include "opt_ktrace.h"
@@ -188,173 +188,181 @@ netbsd32___sigaction_sigtramp(struct lwp
 void
 netbsd32_ksi32_to_ksi(struct _ksiginfo *si, const struct __ksiginfo32 *si32)
 {
+	size_t i;
+
 	memset(si, 0, sizeof (*si));
 	si->_signo = si32->_signo;
 	si->_code = si32->_code;
 	si->_errno = si32->_errno;
 
+	if (si32->_code == SI_NOINFO)
+		return;
+	else if (si32->_code <= 0)	/* codes described in siginfo(2) */
+		goto fill_rt;
+
 	switch (si32->_signo) {
 	case SIGILL:
+	case SIGFPE:
 	case SIGBUS:
 	case SIGSEGV:
-	case SIGFPE:
-	case SIGTRAP:
+fill_fault:
 		si->_reason._fault._addr =
 		NETBSD32IPTR64(si32->_reason._fault._addr);
 		si->_reason._fault._trap = si32->_reason._fault._trap;
 		break;
+	case SIGTRAP:
+		switch (si32->_code) {
+		case TRAP_EXEC:
+			break;
+		case TRAP_CHLD:
+		case TRAP_LWP:
+			si->_reason._ptrace_state._pe_report_event =
+			si32->_reason._ptrace_state._pe_report_event;
+CTASSERT(sizeof(si->_reason._ptrace_state._option._pe_other_pid) ==
+sizeof(si->_reason._ptrace_state._option._pe_lwp));
+			si->_reason._ptrace_state._option._pe_other_pid =
+			si32->_reason._ptrace_state._option._pe_other_pid;
+			break;
+		case TRAP_SCE:
+		case TRAP_SCX:
+			si->_reason._syscall._sysnum =
+			si32->_reason._syscall._sysnum;
+			si->_reason._syscall._retval[0] =
+			si32->_reason._syscall._retval[0];
+			si->_reason._syscall._retval[1] =
+			si32->_reason._syscall._retval[1];
+			si->_reason._syscall._error =
+			si32->_reason._syscall._error;
+			for (i = 0;
+			i < __arraycount(si->_reason._syscall._args); i++)
+si->_reason._syscall._args[i] =
+si32->_reason._syscall._args[i];
+			break;
+		default:
+			goto fill_fault;
+		}
+		break;
 	case SIGALRM:
 	case SIGVTALRM:
 	case SIGPROF:
 	default:	/* see sigqueue() and kill1() */
+fill_rt:
 		si->_reason._rt._pid = si32->_reason._rt._pid;
 		si->_reason._rt._uid = si32->_reason._rt._uid;
 		si->_reason._rt._value.sival_int =
 		si32->_reason._rt._value.sival_int;
 		break;
+	case SIGURG:
+	case SIGIO:
+		si->_reason._poll._band = si32->_reason._poll._band;
+		si->_reason._poll._fd = si32->_reason._poll._fd;
+		break;
 	case SIGCHLD:
 		si->_reason._child._pid = si32->_reason._child._pid;
 		si->_reason._child._uid = 

CVS commit: [netbsd-9] src/sys/compat/netbsd32

2019-11-19 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Tue Nov 19 13:33:21 UTC 2019

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

Log Message:
Pull up following revision(s) (requested by rin in ticket #456):

sys/compat/netbsd32/netbsd32_signal.c: revision 1.46
sys/compat/netbsd32/netbsd32_signal.c: revision 1.47
sys/compat/netbsd32/netbsd32_signal.c: revision 1.48
sys/compat/netbsd32/netbsd32_signal.c: revision 1.49
sys/compat/netbsd32/netbsd32_signal.c: revision 1.50

Belatedly catch up with kern_sig.c rev 1.358:
Provide syscall information with SIGTRAP TRAP_SCE/TRAP_SCX so that
picotrace/truss, for example, works fine on COMPAT_NETBSD32.
With some minor changes:
- Centralize netbsd32_si{,32}_si{32,}() into netbsd32_ksi{,32}_ksi{32,}().
- Provide si_status with SIGCHLD.
- Remove the remaining of SA.

Sort by signal numbers as far as possible, adjust locations of functions.
No functional changes intended.

XXX
pullup to netbsd-9

Provide _ptrace_state for SIGTRAP with TRAP_EXEC, TRAP_CHLD, or TRAP_LWP.
Pointed out by kamil. Thanks!

XXX
pullup to netbsd-9

When converting siginfo, examine si_code at the beginning,
as explained in siginfo(2).
- If it is SI_NOINFO, there's no additional information.
- If it is non-positive, i.e., codes described in siginfo(2),
   we need to fill in _rt.

XXX
Description for SA_ASYNCIO in siginfo(2) seems outdated;
neither si_fd nor si_band are filled in with that code.

XXX
pullup to netbsd-9

TRAP_EXEC does not have extra fields to be filled in at the moment.
Explicitly ignore fields for now.
Pointed out by kamil. Thanks!

XXX
pullup to netbsd-9


To generate a diff of this commit:
cvs rdiff -u -r1.45 -r1.45.8.1 src/sys/compat/netbsd32/netbsd32_signal.c

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



CVS commit: [netbsd-9] src/sys/compat/netbsd32

2019-11-04 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Nov  4 14:47:33 UTC 2019

Modified Files:
src/sys/compat/netbsd32 [netbsd-9]: netbsd32_syscall.h
netbsd32_syscallargs.h netbsd32_syscalls.c
netbsd32_syscalls_autoload.c netbsd32_sysent.c
netbsd32_systrace_args.c

Log Message:
Regen for ticket #398


To generate a diff of this commit:
cvs rdiff -u -r1.142 -r1.142.2.1 src/sys/compat/netbsd32/netbsd32_syscall.h
cvs rdiff -u -r1.141 -r1.141.2.1 \
src/sys/compat/netbsd32/netbsd32_syscallargs.h \
src/sys/compat/netbsd32/netbsd32_syscalls.c
cvs rdiff -u -r1.21 -r1.21.2.1 \
src/sys/compat/netbsd32/netbsd32_syscalls_autoload.c
cvs rdiff -u -r1.140 -r1.140.2.1 src/sys/compat/netbsd32/netbsd32_sysent.c
cvs rdiff -u -r1.32 -r1.32.2.1 \
src/sys/compat/netbsd32/netbsd32_systrace_args.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_syscall.h
diff -u src/sys/compat/netbsd32/netbsd32_syscall.h:1.142 src/sys/compat/netbsd32/netbsd32_syscall.h:1.142.2.1
--- src/sys/compat/netbsd32/netbsd32_syscall.h:1.142	Tue Jun 18 16:24:32 2019
+++ src/sys/compat/netbsd32/netbsd32_syscall.h	Mon Nov  4 14:47:33 2019
@@ -1,10 +1,10 @@
-/* $NetBSD: netbsd32_syscall.h,v 1.142 2019/06/18 16:24:32 christos Exp $ */
+/* $NetBSD: netbsd32_syscall.h,v 1.142.2.1 2019/11/04 14:47:33 martin Exp $ */
 
 /*
  * System call numbers.
  *
  * DO NOT EDIT-- this file is automatically generated.
- * created from	NetBSD: syscalls.master,v 1.127 2019/06/18 16:23:24 christos Exp
+ * created from	NetBSD: syscalls.master,v 1.127.2.1 2019/11/04 14:46:57 martin Exp
  */
 
 #ifndef _NETBSD32_SYS_SYSCALL_H_
@@ -1228,7 +1228,7 @@
 /* syscall: "netbsd32_openat" ret: "int" args: "int" "const netbsd32_charp" "int" "..." */
 #define	NETBSD32_SYS_netbsd32_openat	468
 
-/* syscall: "netbsd32_readlinkat" ret: "netbsd32_ssize_t" args: "int" "const netbsd32_charp" "netbsd32_charp" "size_t" */
+/* syscall: "netbsd32_readlinkat" ret: "netbsd32_ssize_t" args: "int" "const netbsd32_charp" "netbsd32_charp" "netbsd32_size_t" */
 #define	NETBSD32_SYS_netbsd32_readlinkat	469
 
 /* syscall: "netbsd32_symlinkat" ret: "int" args: "const netbsd32_charp" "int" "const netbsd32_charp" */

Index: src/sys/compat/netbsd32/netbsd32_syscallargs.h
diff -u src/sys/compat/netbsd32/netbsd32_syscallargs.h:1.141 src/sys/compat/netbsd32/netbsd32_syscallargs.h:1.141.2.1
--- src/sys/compat/netbsd32/netbsd32_syscallargs.h:1.141	Tue Jun 18 16:24:32 2019
+++ src/sys/compat/netbsd32/netbsd32_syscallargs.h	Mon Nov  4 14:47:33 2019
@@ -1,10 +1,10 @@
-/* $NetBSD: netbsd32_syscallargs.h,v 1.141 2019/06/18 16:24:32 christos Exp $ */
+/* $NetBSD: netbsd32_syscallargs.h,v 1.141.2.1 2019/11/04 14:47:33 martin Exp $ */
 
 /*
  * System call argument lists.
  *
  * DO NOT EDIT-- this file is automatically generated.
- * created from	NetBSD: syscalls.master,v 1.127 2019/06/18 16:23:24 christos Exp
+ * created from	NetBSD: syscalls.master,v 1.127.2.1 2019/11/04 14:46:57 martin Exp
  */
 
 #ifndef _NETBSD32_SYS_SYSCALLARGS_H_
@@ -2511,7 +2511,7 @@ struct netbsd32_readlinkat_args {
 	syscallarg(int) fd;
 	syscallarg(const netbsd32_charp) path;
 	syscallarg(netbsd32_charp) buf;
-	syscallarg(size_t) bufsize;
+	syscallarg(netbsd32_size_t) bufsize;
 };
 check_syscall_args(netbsd32_readlinkat)
 
Index: src/sys/compat/netbsd32/netbsd32_syscalls.c
diff -u src/sys/compat/netbsd32/netbsd32_syscalls.c:1.141 src/sys/compat/netbsd32/netbsd32_syscalls.c:1.141.2.1
--- src/sys/compat/netbsd32/netbsd32_syscalls.c:1.141	Tue Jun 18 16:24:32 2019
+++ src/sys/compat/netbsd32/netbsd32_syscalls.c	Mon Nov  4 14:47:33 2019
@@ -1,14 +1,14 @@
-/* $NetBSD: netbsd32_syscalls.c,v 1.141 2019/06/18 16:24:32 christos Exp $ */
+/* $NetBSD: netbsd32_syscalls.c,v 1.141.2.1 2019/11/04 14:47:33 martin Exp $ */
 
 /*
  * System call names.
  *
  * DO NOT EDIT-- this file is automatically generated.
- * created from	NetBSD: syscalls.master,v 1.127 2019/06/18 16:23:24 christos Exp
+ * created from	NetBSD: syscalls.master,v 1.127.2.1 2019/11/04 14:46:57 martin Exp
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: netbsd32_syscalls.c,v 1.141 2019/06/18 16:24:32 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: netbsd32_syscalls.c,v 1.141.2.1 2019/11/04 14:47:33 martin Exp $");
 
 #if defined(_KERNEL_OPT)
 #if defined(_KERNEL_OPT)

Index: src/sys/compat/netbsd32/netbsd32_syscalls_autoload.c
diff -u src/sys/compat/netbsd32/netbsd32_syscalls_autoload.c:1.21 src/sys/compat/netbsd32/netbsd32_syscalls_autoload.c:1.21.2.1
--- src/sys/compat/netbsd32/netbsd32_syscalls_autoload.c:1.21	Tue Jun 18 16:24:32 2019
+++ src/sys/compat/netbsd32/netbsd32_syscalls_autoload.c	Mon Nov  4 14:47:33 2019
@@ -1,14 +1,14 @@
-/* $NetBSD: netbsd32_syscalls_autoload.c,v 1.21 2019/06/18 16:24:32 christos Exp $ */
+/* $NetBSD: netbsd32_syscalls_autoload.c,v 1.21.2.1 2019/11/04 14:47:33 martin Exp $ */
 
 /*

CVS commit: [netbsd-9] src/sys/compat/netbsd32

2019-11-04 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Nov  4 14:47:33 UTC 2019

Modified Files:
src/sys/compat/netbsd32 [netbsd-9]: netbsd32_syscall.h
netbsd32_syscallargs.h netbsd32_syscalls.c
netbsd32_syscalls_autoload.c netbsd32_sysent.c
netbsd32_systrace_args.c

Log Message:
Regen for ticket #398


To generate a diff of this commit:
cvs rdiff -u -r1.142 -r1.142.2.1 src/sys/compat/netbsd32/netbsd32_syscall.h
cvs rdiff -u -r1.141 -r1.141.2.1 \
src/sys/compat/netbsd32/netbsd32_syscallargs.h \
src/sys/compat/netbsd32/netbsd32_syscalls.c
cvs rdiff -u -r1.21 -r1.21.2.1 \
src/sys/compat/netbsd32/netbsd32_syscalls_autoload.c
cvs rdiff -u -r1.140 -r1.140.2.1 src/sys/compat/netbsd32/netbsd32_sysent.c
cvs rdiff -u -r1.32 -r1.32.2.1 \
src/sys/compat/netbsd32/netbsd32_systrace_args.c

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



CVS commit: [netbsd-9] src/sys/compat/netbsd32

2019-11-04 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Nov  4 14:46:58 UTC 2019

Modified Files:
src/sys/compat/netbsd32 [netbsd-9]: syscalls.master

Log Message:
Pull up following revision(s) (requested by rin in ticket #398):

sys/compat/netbsd32/syscalls.master: revision 1.129

For netbsd32_readlinkat(2), bufsize is netbsd_size_t, not size_t.

Since bufsize is the last argument, this affects only LP64EB.

XXX
pullup to netbsd-9, -8, and -7


To generate a diff of this commit:
cvs rdiff -u -r1.127 -r1.127.2.1 src/sys/compat/netbsd32/syscalls.master

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



CVS commit: [netbsd-9] src/sys/compat/netbsd32

2019-11-04 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Nov  4 14:46:58 UTC 2019

Modified Files:
src/sys/compat/netbsd32 [netbsd-9]: syscalls.master

Log Message:
Pull up following revision(s) (requested by rin in ticket #398):

sys/compat/netbsd32/syscalls.master: revision 1.129

For netbsd32_readlinkat(2), bufsize is netbsd_size_t, not size_t.

Since bufsize is the last argument, this affects only LP64EB.

XXX
pullup to netbsd-9, -8, and -7


To generate a diff of this commit:
cvs rdiff -u -r1.127 -r1.127.2.1 src/sys/compat/netbsd32/syscalls.master

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/syscalls.master
diff -u src/sys/compat/netbsd32/syscalls.master:1.127 src/sys/compat/netbsd32/syscalls.master:1.127.2.1
--- src/sys/compat/netbsd32/syscalls.master:1.127	Tue Jun 18 16:23:24 2019
+++ src/sys/compat/netbsd32/syscalls.master	Mon Nov  4 14:46:57 2019
@@ -1,4 +1,4 @@
-	$NetBSD: syscalls.master,v 1.127 2019/06/18 16:23:24 christos Exp $
+	$NetBSD: syscalls.master,v 1.127.2.1 2019/11/04 14:46:57 martin Exp $
 
 ;	from: NetBSD: syscalls.master,v 1.81 1998/07/05 08:49:50 jonathan Exp
 ;	@(#)syscalls.master	8.2 (Berkeley) 1/13/94
@@ -1116,7 +1116,7 @@
 469	STD  		{ netbsd32_ssize_t|netbsd32||readlinkat(int fd, \
 			const netbsd32_charp path, \
 			netbsd32_charp buf, \
-			size_t bufsize); }
+			netbsd32_size_t bufsize); }
 470	STD  		{ int|netbsd32||symlinkat(const netbsd32_charp path1, \
 			int fd, \
 			const netbsd32_charp path2); }



CVS commit: [netbsd-9] src/sys/compat/netbsd32

2019-10-16 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Oct 16 17:29:50 UTC 2019

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

Log Message:
Pull up following revision(s) (requested by maxv in ticket #337):

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

Fix netbsd32___mount50():
  - zero out fs_args32 to prevent info leaks
  - remove unused and non-functional copyin in NFS (lgtm bot)
  - declare udata, and don't pass kernel pointers to copyout (lgtm bot)
  - make sure data_len is just big enough, to mimic the native behavior
  - don't forget to update *retval with the 32bit value
  - add an XXX for NFS


To generate a diff of this commit:
cvs rdiff -u -r1.82 -r1.82.4.1 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 src/sys/compat/netbsd32/netbsd32_fs.c:1.82.4.1
--- src/sys/compat/netbsd32/netbsd32_fs.c:1.82	Wed Dec 26 08:01:40 2018
+++ src/sys/compat/netbsd32/netbsd32_fs.c	Wed Oct 16 17:29:49 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: netbsd32_fs.c,v 1.82 2018/12/26 08:01:40 mrg Exp $	*/
+/*	$NetBSD: netbsd32_fs.c,v 1.82.4.1 2019/10/16 17:29:49 martin Exp $	*/
 
 /*
  * Copyright (c) 1998, 2001 Matthew R. Green
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: netbsd32_fs.c,v 1.82 2018/12/26 08:01:40 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: netbsd32_fs.c,v 1.82.4.1 2019/10/16 17:29:49 martin Exp $");
 
 #include 
 #include 
@@ -809,17 +809,21 @@ netbsd32___mount50(struct lwp *l, const 
 	const char *type = SCARG_P32(uap, type);
 	const char *path = SCARG_P32(uap, path);
 	int flags = SCARG(uap, flags);
-	void *data = SCARG_P32(uap, data);
+	void *data, *udata;
 	size_t data_len = SCARG(uap, data_len);
 	enum uio_seg data_seg;
 	size_t len;
 	int error;
  
+	udata = data = SCARG_P32(uap, data);
+	memset(_args32, 0, sizeof(fs_args32));
+
 	error = copyinstr(type, mtype, sizeof(mtype), );
 	if (error)
 		return error;
+
 	if (strcmp(mtype, MOUNT_TMPFS) == 0) {
-		if (data_len != sizeof(fs_args32.tmpfs_args))
+		if (data_len < sizeof(fs_args32.tmpfs_args))
 			return EINVAL;
 		if ((flags & MNT_GETARGS) == 0) {
 			error = copyin(data, _args32.tmpfs_args, 
@@ -843,7 +847,7 @@ netbsd32___mount50(struct lwp *l, const 
 		data = _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 < sizeof(fs_args32.mfs_args))
 			return EINVAL;
 		if ((flags & MNT_GETARGS) == 0) {
 			error = copyin(data, _args32.mfs_args, 
@@ -864,7 +868,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 < sizeof(fs_args32.ufs_args))
 			return EINVAL;
 		if ((flags & MNT_GETARGS) == 0) {
 			error = copyin(data, _args32.ufs_args, 
@@ -878,7 +882,7 @@ netbsd32___mount50(struct lwp *l, const 
 		data = _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 < sizeof(fs_args32.iso_args))
 			return EINVAL;
 		if ((flags & MNT_GETARGS) == 0) {
 			error = copyin(data, _args32.iso_args, 
@@ -895,7 +899,7 @@ netbsd32___mount50(struct lwp *l, const 
 		data = _args.iso_args;
 		data_len = sizeof(fs_args.iso_args);
 	} else if (strcmp(mtype, MOUNT_MSDOS) == 0) {
-		if (data_len != sizeof(fs_args32.msdosfs_args))
+		if (data_len < sizeof(fs_args32.msdosfs_args))
 			return EINVAL;
 		if ((flags & MNT_GETARGS) == 0) {
 			error = copyin(data, _args32.msdosfs_args, 
@@ -925,8 +929,9 @@ netbsd32___mount50(struct lwp *l, const 
 		data = _args.msdosfs_args;
 		data_len = sizeof(fs_args.msdosfs_args);
 	} else if (strcmp(mtype, MOUNT_NFS) == 0) {
-		if (data_len != sizeof(fs_args32.nfs_args))
+		if (data_len < sizeof(fs_args32.nfs_args))
 			return EINVAL;
+		/* XXX: NFS requires copyin even with MNT_GETARGS */
 		if ((flags & MNT_GETARGS) == 0) {
 			error = copyin(data, _args32.nfs_args, 
 			sizeof(fs_args32.nfs_args));
@@ -952,7 +957,7 @@ netbsd32___mount50(struct lwp *l, const 
 		data = _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 < sizeof(fs_args32.null_args))
 			return EINVAL;
 		if ((flags & MNT_GETARGS) == 0) {
 			error = copyin(data, _args32.null_args, 
@@ -968,10 +973,12 @@ netbsd32___mount50(struct lwp *l, const 
 	} else {
 		data_seg = UIO_USERSPACE;
 	}
+
 	error = do_sys_mount(l, mtype, UIO_SYSSPACE, path, flags, data, data_seg,
 	data_len, retval);
 	if (error)
 		return error;
+
 	if (flags & MNT_GETARGS) {
 		data_len = *retval;
 		

CVS commit: [netbsd-9] src/sys/compat/netbsd32

2019-10-16 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Oct 16 17:29:50 UTC 2019

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

Log Message:
Pull up following revision(s) (requested by maxv in ticket #337):

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

Fix netbsd32___mount50():
  - zero out fs_args32 to prevent info leaks
  - remove unused and non-functional copyin in NFS (lgtm bot)
  - declare udata, and don't pass kernel pointers to copyout (lgtm bot)
  - make sure data_len is just big enough, to mimic the native behavior
  - don't forget to update *retval with the 32bit value
  - add an XXX for NFS


To generate a diff of this commit:
cvs rdiff -u -r1.82 -r1.82.4.1 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.