Re: CVS commit: src

2019-02-22 Thread Martin Husemann
On Sat, Feb 23, 2019 at 03:10:07AM +, Kamil Rytarowski wrote:
> Module Name:  src
> Committed By: kamil
> Date: Sat Feb 23 03:10:06 UTC 2019
> 
> Modified Files:
>   src/distrib/sets/lists/comp: mi
>   src/distrib/sets/lists/man: mi
>   src/distrib/sets/lists/tests: module.mi
>   src/etc: MAKEDEV.tmpl
>   src/share/man/man4: Makefile
>   src/share/mk: bsd.sys.mk
>   src/sys/arch/amd64/conf: GENERIC
>   src/sys/conf: files majors ssp.mk
>   src/sys/kern: files.kern
>   src/sys/sys: Makefile
>   src/tests/modules: Makefile
> Added Files:
>   src/share/man/man4: kcov.4
>   src/sys/kern: subr_kcov.c
>   src/sys/sys: kcov.h
>   src/tests/modules: t_kcov.c
> 
> Log Message:
> Add KCOV - kernel code coverage tracing device

Please add this also to amd64/conf/ALL and i386/conf/ALL.

The use of both makeoptions KCOV=1 and options KCOV looks pretty ugly, any
way we can get by with one of them? If not, please add comments explaining
what they mean.

subr_kcov.c does not seem to need the  include.

kcov_int_t can not be uint64_t, as that requires 64bit atomic instructions,
which are not available everywhere (see __HAVE_ATOMIC64_OPS).

Martin


CVS commit: src/sys/conf

2019-02-22 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sat Feb 23 07:33:21 UTC 2019

Modified Files:
src/sys/conf: majors

Log Message:
Reserve major number for spi driver


To generate a diff of this commit:
cvs rdiff -u -r1.81 -r1.82 src/sys/conf/majors

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



CVS commit: src/sys/conf

2019-02-22 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sat Feb 23 07:33:21 UTC 2019

Modified Files:
src/sys/conf: majors

Log Message:
Reserve major number for spi driver


To generate a diff of this commit:
cvs rdiff -u -r1.81 -r1.82 src/sys/conf/majors

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

Modified files:

Index: src/sys/conf/majors
diff -u src/sys/conf/majors:1.81 src/sys/conf/majors:1.82
--- src/sys/conf/majors:1.81	Sat Feb 23 03:10:06 2019
+++ src/sys/conf/majors	Sat Feb 23 07:33:20 2019
@@ -1,4 +1,4 @@
-# $NetBSD: majors,v 1.81 2019/02/23 03:10:06 kamil Exp $
+# $NetBSD: majors,v 1.82 2019/02/23 07:33:20 mlelstv Exp $
 #
 # Device majors for Machine-Independent drivers.
 #
@@ -80,3 +80,4 @@ device-major autofschar 343		   auto
 device-major gpiopps   char 344gpiopps
 device-major nvmm  char 345nvmm
 device-major kcov  char 346kcov
+device-major spi   char 347		   spi



CVS commit: [netbsd-7] src/doc

2019-02-22 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sat Feb 23 07:18:00 UTC 2019

Modified Files:
src/doc [netbsd-7]: CHANGES-7.3

Log Message:
Tickets #1679 and #1680


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.39 -r1.1.2.40 src/doc/CHANGES-7.3

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



CVS commit: [netbsd-7] src/doc

2019-02-22 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sat Feb 23 07:18:00 UTC 2019

Modified Files:
src/doc [netbsd-7]: CHANGES-7.3

Log Message:
Tickets #1679 and #1680


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.39 -r1.1.2.40 src/doc/CHANGES-7.3

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

Modified files:

Index: src/doc/CHANGES-7.3
diff -u src/doc/CHANGES-7.3:1.1.2.39 src/doc/CHANGES-7.3:1.1.2.40
--- src/doc/CHANGES-7.3:1.1.2.39	Fri Feb  1 11:07:54 2019
+++ src/doc/CHANGES-7.3	Sat Feb 23 07:18:00 2019
@@ -1,4 +1,4 @@
-# $NetBSD: CHANGES-7.3,v 1.1.2.39 2019/02/01 11:07:54 martin Exp $
+# $NetBSD: CHANGES-7.3,v 1.1.2.40 2019/02/23 07:18:00 martin Exp $
 
 A complete list of changes from the NetBSD 7.2 release to the NetBSD 7.3
 release:
@@ -443,3 +443,28 @@ sys/kern/kern_time.c1.190,1.194
 	Fix kernel info leaks.
 	[maxv, ticket #1678]
 
+sys/compat/linux/common/linux_ipc.c		1.56
+sys/compat/linux32/common/linux32_ipccall.c	1.12
+sys/compat/netbsd32/netbsd32_compat_14.c	1.28
+sys/compat/netbsd32/netbsd32_compat_14.c	1.29
+sys/compat/netbsd32/netbsd32_conv.h		1.38
+sys/compat/sys/ipc.h1.6
+sys/compat/sys/ipc.h1.7
+sys/compat/sys/msg.h1.6
+sys/compat/sys/sem.h1.7
+sys/compat/sys/shm.h1.8
+sys/kern/sysv_msg.c1.73
+sys/kern/sysv_sem.c1.96
+sys/kern/sysv_shm.c1.133
+
+	Fix kernel stack and kernel adddress leaks in msgctl, semctl, and
+	shmctl system calls, for native as well as for the netbsd32, linux,
+	and linux32 compatibility calls.
+	[mrg, ticket #1679]
+
+sys/net/rtsock.c		(patch)
+
+	Fix locking for sysctl_rtable.
+	[sborrill, ticket #1680]
+
+



CVS commit: [netbsd-7] src/sys/net

2019-02-22 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sat Feb 23 07:17:37 UTC 2019

Modified Files:
src/sys/net [netbsd-7]: rtsock.c

Log Message:
Apply patch, requested by sborrill in ticket #1680:

sys/net/rtsock.c(apply patch)

Fix locking for sysctl_rtable (fix in HEAD will be different).


To generate a diff of this commit:
cvs rdiff -u -r1.163.2.1 -r1.163.2.2 src/sys/net/rtsock.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/net/rtsock.c
diff -u src/sys/net/rtsock.c:1.163.2.1 src/sys/net/rtsock.c:1.163.2.2
--- src/sys/net/rtsock.c:1.163.2.1	Wed Nov 28 16:30:06 2018
+++ src/sys/net/rtsock.c	Sat Feb 23 07:17:37 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: rtsock.c,v 1.163.2.1 2018/11/28 16:30:06 martin Exp $	*/
+/*	$NetBSD: rtsock.c,v 1.163.2.2 2019/02/23 07:17:37 martin Exp $	*/
 
 /*
  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -61,7 +61,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: rtsock.c,v 1.163.2.1 2018/11/28 16:30:06 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rtsock.c,v 1.163.2.2 2019/02/23 07:17:37 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -1408,6 +1408,8 @@ again:
 	w.w_needed = 0 - w.w_given;
 	w.w_where = where;
 
+	mutex_enter(softnet_lock);
+	KERNEL_LOCK(1, NULL);
 	s = splsoftnet();
 	switch (w.w_op) {
 
@@ -1434,6 +1436,8 @@ again:
 		break;
 	}
 	splx(s);
+	KERNEL_UNLOCK_ONE(NULL);
+	mutex_exit(softnet_lock);
 
 	/* check to see if we couldn't allocate memory with NOWAIT */
 	if (error == ENOBUFS && w.w_tmem == 0 && w.w_tmemneeded)



CVS commit: [netbsd-7-1] src/sys/net

2019-02-22 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sat Feb 23 07:16:38 UTC 2019

Modified Files:
src/sys/net [netbsd-7-1]: rtsock.c

Log Message:
Apply patch, requested by sborrill in ticket #1680:

sys/net/rtsock.c(apply patch)

Fix locking for sysctl_rtable (fix in HEAD will be different).


To generate a diff of this commit:
cvs rdiff -u -r1.163.8.1 -r1.163.8.2 src/sys/net/rtsock.c

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



CVS commit: [netbsd-7] src/sys/net

2019-02-22 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sat Feb 23 07:17:37 UTC 2019

Modified Files:
src/sys/net [netbsd-7]: rtsock.c

Log Message:
Apply patch, requested by sborrill in ticket #1680:

sys/net/rtsock.c(apply patch)

Fix locking for sysctl_rtable (fix in HEAD will be different).


To generate a diff of this commit:
cvs rdiff -u -r1.163.2.1 -r1.163.2.2 src/sys/net/rtsock.c

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



CVS commit: [netbsd-7-1] src/sys/net

2019-02-22 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sat Feb 23 07:16:38 UTC 2019

Modified Files:
src/sys/net [netbsd-7-1]: rtsock.c

Log Message:
Apply patch, requested by sborrill in ticket #1680:

sys/net/rtsock.c(apply patch)

Fix locking for sysctl_rtable (fix in HEAD will be different).


To generate a diff of this commit:
cvs rdiff -u -r1.163.8.1 -r1.163.8.2 src/sys/net/rtsock.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/net/rtsock.c
diff -u src/sys/net/rtsock.c:1.163.8.1 src/sys/net/rtsock.c:1.163.8.2
--- src/sys/net/rtsock.c:1.163.8.1	Wed Nov 28 16:30:57 2018
+++ src/sys/net/rtsock.c	Sat Feb 23 07:16:37 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: rtsock.c,v 1.163.8.1 2018/11/28 16:30:57 martin Exp $	*/
+/*	$NetBSD: rtsock.c,v 1.163.8.2 2019/02/23 07:16:37 martin Exp $	*/
 
 /*
  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -61,7 +61,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: rtsock.c,v 1.163.8.1 2018/11/28 16:30:57 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rtsock.c,v 1.163.8.2 2019/02/23 07:16:37 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -1408,6 +1408,8 @@ again:
 	w.w_needed = 0 - w.w_given;
 	w.w_where = where;
 
+	mutex_enter(softnet_lock);
+	KERNEL_LOCK(1, NULL);
 	s = splsoftnet();
 	switch (w.w_op) {
 
@@ -1434,6 +1436,8 @@ again:
 		break;
 	}
 	splx(s);
+	KERNEL_UNLOCK_ONE(NULL);
+	mutex_exit(softnet_lock);
 
 	/* check to see if we couldn't allocate memory with NOWAIT */
 	if (error == ENOBUFS && w.w_tmem == 0 && w.w_tmemneeded)



CVS commit: [netbsd-7-1] src/doc

2019-02-22 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sat Feb 23 07:17:03 UTC 2019

Modified Files:
src/doc [netbsd-7-1]: CHANGES-7.1.3

Log Message:
Tickets #1679 and #1680


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.41 -r1.1.2.42 src/doc/CHANGES-7.1.3

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

Modified files:

Index: src/doc/CHANGES-7.1.3
diff -u src/doc/CHANGES-7.1.3:1.1.2.41 src/doc/CHANGES-7.1.3:1.1.2.42
--- src/doc/CHANGES-7.1.3:1.1.2.41	Fri Feb  1 11:10:21 2019
+++ src/doc/CHANGES-7.1.3	Sat Feb 23 07:17:03 2019
@@ -1,4 +1,4 @@
-# $NetBSD: CHANGES-7.1.3,v 1.1.2.41 2019/02/01 11:10:21 martin Exp $
+# $NetBSD: CHANGES-7.1.3,v 1.1.2.42 2019/02/23 07:17:03 martin Exp $
 
 A complete list of changes from the NetBSD 7.1.2 release to the NetBSD 7.1.3
 release:
@@ -424,3 +424,28 @@ sys/kern/kern_time.c1.190,1.194
 	Fix kernel info leaks.
 	[maxv, ticket #1678]
 
+sys/compat/linux/common/linux_ipc.c		1.56
+sys/compat/linux32/common/linux32_ipccall.c	1.12
+sys/compat/netbsd32/netbsd32_compat_14.c	1.28
+sys/compat/netbsd32/netbsd32_compat_14.c	1.29
+sys/compat/netbsd32/netbsd32_conv.h		1.38
+sys/compat/sys/ipc.h1.6
+sys/compat/sys/ipc.h1.7
+sys/compat/sys/msg.h1.6
+sys/compat/sys/sem.h1.7
+sys/compat/sys/shm.h1.8
+sys/kern/sysv_msg.c1.73
+sys/kern/sysv_sem.c1.96
+sys/kern/sysv_shm.c1.133
+
+	Fix kernel stack and kernel adddress leaks in msgctl, semctl, and
+	shmctl system calls, for native as well as for the netbsd32, linux,
+	and linux32 compatibility calls.
+	[mrg, ticket #1679]
+
+sys/net/rtsock.c		(patch)
+
+	Fix locking for sysctl_rtable.
+	[sborrill, ticket #1680]
+
+



CVS commit: [netbsd-7-1] src/doc

2019-02-22 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sat Feb 23 07:17:03 UTC 2019

Modified Files:
src/doc [netbsd-7-1]: CHANGES-7.1.3

Log Message:
Tickets #1679 and #1680


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.41 -r1.1.2.42 src/doc/CHANGES-7.1.3

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



CVS commit: [netbsd-7-0] src/doc

2019-02-22 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sat Feb 23 07:16:06 UTC 2019

Modified Files:
src/doc [netbsd-7-0]: CHANGES-7.0.3

Log Message:
Tickets #1679 and #1680


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.134 -r1.1.2.135 src/doc/CHANGES-7.0.3

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

Modified files:

Index: src/doc/CHANGES-7.0.3
diff -u src/doc/CHANGES-7.0.3:1.1.2.134 src/doc/CHANGES-7.0.3:1.1.2.135
--- src/doc/CHANGES-7.0.3:1.1.2.134	Fri Feb  1 11:12:55 2019
+++ src/doc/CHANGES-7.0.3	Sat Feb 23 07:16:06 2019
@@ -1,4 +1,4 @@
-# $NetBSD: CHANGES-7.0.3,v 1.1.2.134 2019/02/01 11:12:55 martin Exp $
+# $NetBSD: CHANGES-7.0.3,v 1.1.2.135 2019/02/23 07:16:06 martin Exp $
 
 A complete list of changes from the NetBSD 7.0.2 release to the NetBSD 7.0.3
 release:
@@ -5732,3 +5732,28 @@ sys/kern/kern_time.c1.190,1.194
 	Fix kernel info leaks.
 	[maxv, ticket #1678]
 
+sys/compat/linux/common/linux_ipc.c		1.56
+sys/compat/linux32/common/linux32_ipccall.c	1.12
+sys/compat/netbsd32/netbsd32_compat_14.c	1.28
+sys/compat/netbsd32/netbsd32_compat_14.c	1.29
+sys/compat/netbsd32/netbsd32_conv.h		1.38
+sys/compat/sys/ipc.h1.6
+sys/compat/sys/ipc.h1.7
+sys/compat/sys/msg.h1.6
+sys/compat/sys/sem.h1.7
+sys/compat/sys/shm.h1.8
+sys/kern/sysv_msg.c1.73
+sys/kern/sysv_sem.c1.96
+sys/kern/sysv_shm.c1.133
+
+	Fix kernel stack and kernel adddress leaks in msgctl, semctl, and
+	shmctl system calls, for native as well as for the netbsd32, linux,
+	and linux32 compatibility calls.
+	[mrg, ticket #1679]
+
+sys/net/rtsock.c		(patch)
+
+	Fix locking for sysctl_rtable.
+	[sborrill, ticket #1680]
+
+



CVS commit: [netbsd-7-0] src/doc

2019-02-22 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sat Feb 23 07:16:06 UTC 2019

Modified Files:
src/doc [netbsd-7-0]: CHANGES-7.0.3

Log Message:
Tickets #1679 and #1680


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.134 -r1.1.2.135 src/doc/CHANGES-7.0.3

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



CVS commit: [netbsd-7-0] src/sys/net

2019-02-22 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sat Feb 23 07:14:40 UTC 2019

Modified Files:
src/sys/net [netbsd-7-0]: rtsock.c

Log Message:
Apply patch, requested by sborrill in ticket #1680:

sys/net/rtsock.c(apply patch)

Fix locking for sysctl_rtable (fix in HEAD will be different).


To generate a diff of this commit:
cvs rdiff -u -r1.163.4.1 -r1.163.4.2 src/sys/net/rtsock.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/net/rtsock.c
diff -u src/sys/net/rtsock.c:1.163.4.1 src/sys/net/rtsock.c:1.163.4.2
--- src/sys/net/rtsock.c:1.163.4.1	Wed Nov 28 16:32:14 2018
+++ src/sys/net/rtsock.c	Sat Feb 23 07:14:40 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: rtsock.c,v 1.163.4.1 2018/11/28 16:32:14 martin Exp $	*/
+/*	$NetBSD: rtsock.c,v 1.163.4.2 2019/02/23 07:14:40 martin Exp $	*/
 
 /*
  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -61,7 +61,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: rtsock.c,v 1.163.4.1 2018/11/28 16:32:14 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rtsock.c,v 1.163.4.2 2019/02/23 07:14:40 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -1408,6 +1408,8 @@ again:
 	w.w_needed = 0 - w.w_given;
 	w.w_where = where;
 
+	mutex_enter(softnet_lock);
+	KERNEL_LOCK(1, NULL);
 	s = splsoftnet();
 	switch (w.w_op) {
 
@@ -1434,6 +1436,8 @@ again:
 		break;
 	}
 	splx(s);
+	KERNEL_UNLOCK_ONE(NULL);
+	mutex_exit(softnet_lock);
 
 	/* check to see if we couldn't allocate memory with NOWAIT */
 	if (error == ENOBUFS && w.w_tmem == 0 && w.w_tmemneeded)



CVS commit: [netbsd-7-0] src/sys/net

2019-02-22 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sat Feb 23 07:14:40 UTC 2019

Modified Files:
src/sys/net [netbsd-7-0]: rtsock.c

Log Message:
Apply patch, requested by sborrill in ticket #1680:

sys/net/rtsock.c(apply patch)

Fix locking for sysctl_rtable (fix in HEAD will be different).


To generate a diff of this commit:
cvs rdiff -u -r1.163.4.1 -r1.163.4.2 src/sys/net/rtsock.c

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



CVS commit: [netbsd-7-0] src/sys

2019-02-22 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sat Feb 23 07:05:41 UTC 2019

Modified Files:
src/sys/compat/linux/common [netbsd-7-0]: linux_ipc.c
src/sys/compat/linux32/common [netbsd-7-0]: linux32_ipccall.c
src/sys/compat/netbsd32 [netbsd-7-0]: netbsd32_compat_14.c
netbsd32_conv.h
src/sys/compat/sys [netbsd-7-0]: ipc.h msg.h sem.h shm.h
src/sys/kern [netbsd-7-0]: sysv_msg.c sysv_sem.c sysv_shm.c

Log Message:
Pull up following revision(s) (requested by mrg in ticket #1679):
sys/compat/sys/ipc.h: revision 1.6
sys/compat/sys/ipc.h: revision 1.7
sys/compat/sys/shm.h: revision 1.8
sys/kern/sysv_shm.c: revision 1.133
sys/compat/sys/sem.h: revision 1.7
sys/compat/linux/common/linux_ipc.c: revision 1.56
sys/compat/netbsd32/netbsd32_conv.h: revision 1.38
sys/kern/sysv_sem.c: revision 1.96
sys/compat/netbsd32/netbsd32_compat_14.c: revision 1.28
sys/compat/netbsd32/netbsd32_compat_14.c: revision 1.29
sys/compat/linux32/common/linux32_ipccall.c: revision 1.12
sys/kern/sysv_msg.c: revision 1.73
sys/compat/sys/msg.h: revision 1.6

for sysv ipc stat operations, explicitly copy the exported parts
instead of the whole ds structure.
besides triggering a recently added assert in netbsd32, this stops
exposing kernel addresses.

copy the mode clamping to 0777 from sem to shm and msg.

while here, make sure that the compat callers to sysv_ipc clear
the contents of the compat structure before setting the result
members to ensure padding bytes are cleared.

don't set/copy _sem_base, _msg_first, _msg_last or _shm_internal.
even if used, which seems very dodgy, they leak KVAs as well.
possibly this may affect linux binaries, in particular, the
comments around _shm_internal ("XXX Oh well.") may mean apps
rely upon these but hopefully not -- the comments date back to
rev 1.1 in 1995.

the _key, _seq and _msg_cbytes members are exported as before as
i found multiple consumers of these (no less than ipcs(1), and
they appear to be useful for debugging and more.

XXX: the naming of compat functions have too many styles.  there
 are at least 3 different ones changed here.

fix naming errors in previous.  (this file is no longer compiled, but
this fix makes the pull up more obvious, before deleting this file.)

include libkern.h or strings.h.  should fix i386 build issues.


To generate a diff of this commit:
cvs rdiff -u -r1.55 -r1.55.34.1 src/sys/compat/linux/common/linux_ipc.c
cvs rdiff -u -r1.11 -r1.11.38.1 \
src/sys/compat/linux32/common/linux32_ipccall.c
cvs rdiff -u -r1.21.78.1 -r1.21.78.2 \
src/sys/compat/netbsd32/netbsd32_compat_14.c
cvs rdiff -u -r1.28.8.1 -r1.28.8.2 src/sys/compat/netbsd32/netbsd32_conv.h
cvs rdiff -u -r1.4 -r1.4.34.1 src/sys/compat/sys/ipc.h
cvs rdiff -u -r1.4.44.1 -r1.4.44.2 src/sys/compat/sys/msg.h
cvs rdiff -u -r1.6 -r1.6.44.1 src/sys/compat/sys/sem.h
cvs rdiff -u -r1.7 -r1.7.42.1 src/sys/compat/sys/shm.h
cvs rdiff -u -r1.66 -r1.66.8.1 src/sys/kern/sysv_msg.c
cvs rdiff -u -r1.90 -r1.90.6.1 src/sys/kern/sysv_sem.c
cvs rdiff -u -r1.125 -r1.125.6.1 src/sys/kern/sysv_shm.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/linux/common/linux_ipc.c
diff -u src/sys/compat/linux/common/linux_ipc.c:1.55 src/sys/compat/linux/common/linux_ipc.c:1.55.34.1
--- src/sys/compat/linux/common/linux_ipc.c:1.55	Sat May 28 23:24:58 2011
+++ src/sys/compat/linux/common/linux_ipc.c	Sat Feb 23 07:05:40 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: linux_ipc.c,v 1.55 2011/05/28 23:24:58 alnsn Exp $	*/
+/*	$NetBSD: linux_ipc.c,v 1.55.34.1 2019/02/23 07:05:40 martin Exp $	*/
 
 /*-
  * Copyright (c) 1995, 1998 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: linux_ipc.c,v 1.55 2011/05/28 23:24:58 alnsn Exp $");
+__KERNEL_RCSID(0, "$NetBSD: linux_ipc.c,v 1.55.34.1 2019/02/23 07:05:40 martin Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_sysv.h"
@@ -117,6 +117,7 @@ void
 bsd_to_linux_ipc_perm(struct ipc_perm *bpp, struct linux_ipc_perm *lpp)
 {
 
+	memset(lpp, 0, sizeof *lpp);
 	lpp->l_key = bpp->_key;
 	lpp->l_uid = bpp->uid;
 	lpp->l_gid = bpp->gid;
@@ -129,6 +130,8 @@ bsd_to_linux_ipc_perm(struct ipc_perm *b
 void
 bsd_to_linux_ipc64_perm(struct ipc_perm *bpp, struct linux_ipc64_perm *lpp)
 {
+
+	memset(lpp, 0, sizeof *lpp);
 	lpp->l_key = bpp->_key;
 	lpp->l_uid = bpp->uid;
 	lpp->l_gid = bpp->gid;
@@ -152,16 +155,19 @@ bsd_to_linux_ipc64_perm(struct ipc_perm 
 void
 bsd_to_linux_semid_ds(struct semid_ds *bs, struct linux_semid_ds *ls)
 {
+
+	memset(ls, 0, sizeof *ls);
 	bsd_to_linux_ipc_perm(>sem_perm, >l_sem_perm);
 	ls->l_sem_otime = bs->sem_otime;
 	ls->l_sem_ctime = bs->sem_ctime;
 	ls->l_sem_nsems = bs->sem_nsems;
-	ls->l_sem_base = bs->_sem_base;
 }
 
 void
 bsd_to_linux_semid64_ds(struct semid_ds *bs, struct 

CVS commit: [netbsd-7-0] src/sys

2019-02-22 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sat Feb 23 07:05:41 UTC 2019

Modified Files:
src/sys/compat/linux/common [netbsd-7-0]: linux_ipc.c
src/sys/compat/linux32/common [netbsd-7-0]: linux32_ipccall.c
src/sys/compat/netbsd32 [netbsd-7-0]: netbsd32_compat_14.c
netbsd32_conv.h
src/sys/compat/sys [netbsd-7-0]: ipc.h msg.h sem.h shm.h
src/sys/kern [netbsd-7-0]: sysv_msg.c sysv_sem.c sysv_shm.c

Log Message:
Pull up following revision(s) (requested by mrg in ticket #1679):
sys/compat/sys/ipc.h: revision 1.6
sys/compat/sys/ipc.h: revision 1.7
sys/compat/sys/shm.h: revision 1.8
sys/kern/sysv_shm.c: revision 1.133
sys/compat/sys/sem.h: revision 1.7
sys/compat/linux/common/linux_ipc.c: revision 1.56
sys/compat/netbsd32/netbsd32_conv.h: revision 1.38
sys/kern/sysv_sem.c: revision 1.96
sys/compat/netbsd32/netbsd32_compat_14.c: revision 1.28
sys/compat/netbsd32/netbsd32_compat_14.c: revision 1.29
sys/compat/linux32/common/linux32_ipccall.c: revision 1.12
sys/kern/sysv_msg.c: revision 1.73
sys/compat/sys/msg.h: revision 1.6

for sysv ipc stat operations, explicitly copy the exported parts
instead of the whole ds structure.
besides triggering a recently added assert in netbsd32, this stops
exposing kernel addresses.

copy the mode clamping to 0777 from sem to shm and msg.

while here, make sure that the compat callers to sysv_ipc clear
the contents of the compat structure before setting the result
members to ensure padding bytes are cleared.

don't set/copy _sem_base, _msg_first, _msg_last or _shm_internal.
even if used, which seems very dodgy, they leak KVAs as well.
possibly this may affect linux binaries, in particular, the
comments around _shm_internal ("XXX Oh well.") may mean apps
rely upon these but hopefully not -- the comments date back to
rev 1.1 in 1995.

the _key, _seq and _msg_cbytes members are exported as before as
i found multiple consumers of these (no less than ipcs(1), and
they appear to be useful for debugging and more.

XXX: the naming of compat functions have too many styles.  there
 are at least 3 different ones changed here.

fix naming errors in previous.  (this file is no longer compiled, but
this fix makes the pull up more obvious, before deleting this file.)

include libkern.h or strings.h.  should fix i386 build issues.


To generate a diff of this commit:
cvs rdiff -u -r1.55 -r1.55.34.1 src/sys/compat/linux/common/linux_ipc.c
cvs rdiff -u -r1.11 -r1.11.38.1 \
src/sys/compat/linux32/common/linux32_ipccall.c
cvs rdiff -u -r1.21.78.1 -r1.21.78.2 \
src/sys/compat/netbsd32/netbsd32_compat_14.c
cvs rdiff -u -r1.28.8.1 -r1.28.8.2 src/sys/compat/netbsd32/netbsd32_conv.h
cvs rdiff -u -r1.4 -r1.4.34.1 src/sys/compat/sys/ipc.h
cvs rdiff -u -r1.4.44.1 -r1.4.44.2 src/sys/compat/sys/msg.h
cvs rdiff -u -r1.6 -r1.6.44.1 src/sys/compat/sys/sem.h
cvs rdiff -u -r1.7 -r1.7.42.1 src/sys/compat/sys/shm.h
cvs rdiff -u -r1.66 -r1.66.8.1 src/sys/kern/sysv_msg.c
cvs rdiff -u -r1.90 -r1.90.6.1 src/sys/kern/sysv_sem.c
cvs rdiff -u -r1.125 -r1.125.6.1 src/sys/kern/sysv_shm.c

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



CVS commit: [netbsd-7-1] src/sys

2019-02-22 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sat Feb 23 07:04:12 UTC 2019

Modified Files:
src/sys/compat/linux/common [netbsd-7-1]: linux_ipc.c
src/sys/compat/linux32/common [netbsd-7-1]: linux32_ipccall.c
src/sys/compat/netbsd32 [netbsd-7-1]: netbsd32_compat_14.c
netbsd32_conv.h
src/sys/compat/sys [netbsd-7-1]: ipc.h msg.h sem.h shm.h
src/sys/kern [netbsd-7-1]: sysv_msg.c sysv_sem.c sysv_shm.c

Log Message:
Pull up following revision(s) (requested by mrg in ticket #1679):
sys/compat/sys/ipc.h: revision 1.6
sys/compat/sys/ipc.h: revision 1.7
sys/compat/sys/shm.h: revision 1.8
sys/kern/sysv_shm.c: revision 1.133
sys/compat/sys/sem.h: revision 1.7
sys/compat/linux/common/linux_ipc.c: revision 1.56
sys/compat/netbsd32/netbsd32_conv.h: revision 1.38
sys/kern/sysv_sem.c: revision 1.96
sys/compat/netbsd32/netbsd32_compat_14.c: revision 1.28
sys/compat/netbsd32/netbsd32_compat_14.c: revision 1.29
sys/compat/linux32/common/linux32_ipccall.c: revision 1.12
sys/kern/sysv_msg.c: revision 1.73
sys/compat/sys/msg.h: revision 1.6

for sysv ipc stat operations, explicitly copy the exported parts
instead of the whole ds structure.
besides triggering a recently added assert in netbsd32, this stops
exposing kernel addresses.

copy the mode clamping to 0777 from sem to shm and msg.

while here, make sure that the compat callers to sysv_ipc clear
the contents of the compat structure before setting the result
members to ensure padding bytes are cleared.

don't set/copy _sem_base, _msg_first, _msg_last or _shm_internal.
even if used, which seems very dodgy, they leak KVAs as well.
possibly this may affect linux binaries, in particular, the
comments around _shm_internal ("XXX Oh well.") may mean apps
rely upon these but hopefully not -- the comments date back to
rev 1.1 in 1995.

the _key, _seq and _msg_cbytes members are exported as before as
i found multiple consumers of these (no less than ipcs(1), and
they appear to be useful for debugging and more.

XXX: the naming of compat functions have too many styles.  there
 are at least 3 different ones changed here.

fix naming errors in previous.  (this file is no longer compiled, but
this fix makes the pull up more obvious, before deleting this file.)

include libkern.h or strings.h.  should fix i386 build issues.


To generate a diff of this commit:
cvs rdiff -u -r1.55 -r1.55.42.1 src/sys/compat/linux/common/linux_ipc.c
cvs rdiff -u -r1.11 -r1.11.46.1 \
src/sys/compat/linux32/common/linux32_ipccall.c
cvs rdiff -u -r1.21.82.1 -r1.21.82.2 \
src/sys/compat/netbsd32/netbsd32_compat_14.c
cvs rdiff -u -r1.28.4.1.4.1 -r1.28.4.1.4.2 \
src/sys/compat/netbsd32/netbsd32_conv.h
cvs rdiff -u -r1.4 -r1.4.42.1 src/sys/compat/sys/ipc.h
cvs rdiff -u -r1.4.52.1 -r1.4.52.2 src/sys/compat/sys/msg.h
cvs rdiff -u -r1.6 -r1.6.52.1 src/sys/compat/sys/sem.h
cvs rdiff -u -r1.7 -r1.7.50.1 src/sys/compat/sys/shm.h
cvs rdiff -u -r1.66 -r1.66.12.1 src/sys/kern/sysv_msg.c
cvs rdiff -u -r1.90 -r1.90.10.1 src/sys/kern/sysv_sem.c
cvs rdiff -u -r1.125 -r1.125.10.1 src/sys/kern/sysv_shm.c

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



CVS commit: [netbsd-7-1] src/sys

2019-02-22 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sat Feb 23 07:04:12 UTC 2019

Modified Files:
src/sys/compat/linux/common [netbsd-7-1]: linux_ipc.c
src/sys/compat/linux32/common [netbsd-7-1]: linux32_ipccall.c
src/sys/compat/netbsd32 [netbsd-7-1]: netbsd32_compat_14.c
netbsd32_conv.h
src/sys/compat/sys [netbsd-7-1]: ipc.h msg.h sem.h shm.h
src/sys/kern [netbsd-7-1]: sysv_msg.c sysv_sem.c sysv_shm.c

Log Message:
Pull up following revision(s) (requested by mrg in ticket #1679):
sys/compat/sys/ipc.h: revision 1.6
sys/compat/sys/ipc.h: revision 1.7
sys/compat/sys/shm.h: revision 1.8
sys/kern/sysv_shm.c: revision 1.133
sys/compat/sys/sem.h: revision 1.7
sys/compat/linux/common/linux_ipc.c: revision 1.56
sys/compat/netbsd32/netbsd32_conv.h: revision 1.38
sys/kern/sysv_sem.c: revision 1.96
sys/compat/netbsd32/netbsd32_compat_14.c: revision 1.28
sys/compat/netbsd32/netbsd32_compat_14.c: revision 1.29
sys/compat/linux32/common/linux32_ipccall.c: revision 1.12
sys/kern/sysv_msg.c: revision 1.73
sys/compat/sys/msg.h: revision 1.6

for sysv ipc stat operations, explicitly copy the exported parts
instead of the whole ds structure.
besides triggering a recently added assert in netbsd32, this stops
exposing kernel addresses.

copy the mode clamping to 0777 from sem to shm and msg.

while here, make sure that the compat callers to sysv_ipc clear
the contents of the compat structure before setting the result
members to ensure padding bytes are cleared.

don't set/copy _sem_base, _msg_first, _msg_last or _shm_internal.
even if used, which seems very dodgy, they leak KVAs as well.
possibly this may affect linux binaries, in particular, the
comments around _shm_internal ("XXX Oh well.") may mean apps
rely upon these but hopefully not -- the comments date back to
rev 1.1 in 1995.

the _key, _seq and _msg_cbytes members are exported as before as
i found multiple consumers of these (no less than ipcs(1), and
they appear to be useful for debugging and more.

XXX: the naming of compat functions have too many styles.  there
 are at least 3 different ones changed here.

fix naming errors in previous.  (this file is no longer compiled, but
this fix makes the pull up more obvious, before deleting this file.)

include libkern.h or strings.h.  should fix i386 build issues.


To generate a diff of this commit:
cvs rdiff -u -r1.55 -r1.55.42.1 src/sys/compat/linux/common/linux_ipc.c
cvs rdiff -u -r1.11 -r1.11.46.1 \
src/sys/compat/linux32/common/linux32_ipccall.c
cvs rdiff -u -r1.21.82.1 -r1.21.82.2 \
src/sys/compat/netbsd32/netbsd32_compat_14.c
cvs rdiff -u -r1.28.4.1.4.1 -r1.28.4.1.4.2 \
src/sys/compat/netbsd32/netbsd32_conv.h
cvs rdiff -u -r1.4 -r1.4.42.1 src/sys/compat/sys/ipc.h
cvs rdiff -u -r1.4.52.1 -r1.4.52.2 src/sys/compat/sys/msg.h
cvs rdiff -u -r1.6 -r1.6.52.1 src/sys/compat/sys/sem.h
cvs rdiff -u -r1.7 -r1.7.50.1 src/sys/compat/sys/shm.h
cvs rdiff -u -r1.66 -r1.66.12.1 src/sys/kern/sysv_msg.c
cvs rdiff -u -r1.90 -r1.90.10.1 src/sys/kern/sysv_sem.c
cvs rdiff -u -r1.125 -r1.125.10.1 src/sys/kern/sysv_shm.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/linux/common/linux_ipc.c
diff -u src/sys/compat/linux/common/linux_ipc.c:1.55 src/sys/compat/linux/common/linux_ipc.c:1.55.42.1
--- src/sys/compat/linux/common/linux_ipc.c:1.55	Sat May 28 23:24:58 2011
+++ src/sys/compat/linux/common/linux_ipc.c	Sat Feb 23 07:04:12 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: linux_ipc.c,v 1.55 2011/05/28 23:24:58 alnsn Exp $	*/
+/*	$NetBSD: linux_ipc.c,v 1.55.42.1 2019/02/23 07:04:12 martin Exp $	*/
 
 /*-
  * Copyright (c) 1995, 1998 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: linux_ipc.c,v 1.55 2011/05/28 23:24:58 alnsn Exp $");
+__KERNEL_RCSID(0, "$NetBSD: linux_ipc.c,v 1.55.42.1 2019/02/23 07:04:12 martin Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_sysv.h"
@@ -117,6 +117,7 @@ void
 bsd_to_linux_ipc_perm(struct ipc_perm *bpp, struct linux_ipc_perm *lpp)
 {
 
+	memset(lpp, 0, sizeof *lpp);
 	lpp->l_key = bpp->_key;
 	lpp->l_uid = bpp->uid;
 	lpp->l_gid = bpp->gid;
@@ -129,6 +130,8 @@ bsd_to_linux_ipc_perm(struct ipc_perm *b
 void
 bsd_to_linux_ipc64_perm(struct ipc_perm *bpp, struct linux_ipc64_perm *lpp)
 {
+
+	memset(lpp, 0, sizeof *lpp);
 	lpp->l_key = bpp->_key;
 	lpp->l_uid = bpp->uid;
 	lpp->l_gid = bpp->gid;
@@ -152,16 +155,19 @@ bsd_to_linux_ipc64_perm(struct ipc_perm 
 void
 bsd_to_linux_semid_ds(struct semid_ds *bs, struct linux_semid_ds *ls)
 {
+
+	memset(ls, 0, sizeof *ls);
 	bsd_to_linux_ipc_perm(>sem_perm, >l_sem_perm);
 	ls->l_sem_otime = bs->sem_otime;
 	ls->l_sem_ctime = bs->sem_ctime;
 	ls->l_sem_nsems = bs->sem_nsems;
-	ls->l_sem_base = bs->_sem_base;
 }
 
 void
 bsd_to_linux_semid64_ds(struct 

CVS commit: [netbsd-7] src/sys

2019-02-22 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sat Feb 23 07:02:21 UTC 2019

Modified Files:
src/sys/compat/linux/common [netbsd-7]: linux_ipc.c
src/sys/compat/linux32/common [netbsd-7]: linux32_ipccall.c
src/sys/compat/netbsd32 [netbsd-7]: netbsd32_compat_14.c
netbsd32_conv.h
src/sys/compat/sys [netbsd-7]: ipc.h msg.h sem.h shm.h
src/sys/kern [netbsd-7]: sysv_msg.c sysv_sem.c sysv_shm.c

Log Message:
Pull up following revision(s) (requested by mrg in ticket #1679):
sys/compat/sys/ipc.h: revision 1.6
sys/compat/sys/ipc.h: revision 1.7
sys/compat/sys/shm.h: revision 1.8
sys/kern/sysv_shm.c: revision 1.133
sys/compat/sys/sem.h: revision 1.7
sys/compat/linux/common/linux_ipc.c: revision 1.56
sys/compat/netbsd32/netbsd32_conv.h: revision 1.38
sys/kern/sysv_sem.c: revision 1.96
sys/compat/netbsd32/netbsd32_compat_14.c: revision 1.28
sys/compat/netbsd32/netbsd32_compat_14.c: revision 1.29
sys/compat/linux32/common/linux32_ipccall.c: revision 1.12
sys/kern/sysv_msg.c: revision 1.73
sys/compat/sys/msg.h: revision 1.6

for sysv ipc stat operations, explicitly copy the exported parts
instead of the whole ds structure.
besides triggering a recently added assert in netbsd32, this stops
exposing kernel addresses.

copy the mode clamping to 0777 from sem to shm and msg.

while here, make sure that the compat callers to sysv_ipc clear
the contents of the compat structure before setting the result
members to ensure padding bytes are cleared.

don't set/copy _sem_base, _msg_first, _msg_last or _shm_internal.
even if used, which seems very dodgy, they leak KVAs as well.
possibly this may affect linux binaries, in particular, the
comments around _shm_internal ("XXX Oh well.") may mean apps
rely upon these but hopefully not -- the comments date back to
rev 1.1 in 1995.

the _key, _seq and _msg_cbytes members are exported as before as
i found multiple consumers of these (no less than ipcs(1), and
they appear to be useful for debugging and more.

XXX: the naming of compat functions have too many styles.  there
 are at least 3 different ones changed here.

fix naming errors in previous.  (this file is no longer compiled, but
this fix makes the pull up more obvious, before deleting this file.)

include libkern.h or strings.h.  should fix i386 build issues.


To generate a diff of this commit:
cvs rdiff -u -r1.55 -r1.55.30.1 src/sys/compat/linux/common/linux_ipc.c
cvs rdiff -u -r1.11 -r1.11.34.1 \
src/sys/compat/linux32/common/linux32_ipccall.c
cvs rdiff -u -r1.21.74.1 -r1.21.74.2 \
src/sys/compat/netbsd32/netbsd32_compat_14.c
cvs rdiff -u -r1.28.4.2 -r1.28.4.3 src/sys/compat/netbsd32/netbsd32_conv.h
cvs rdiff -u -r1.4 -r1.4.30.1 src/sys/compat/sys/ipc.h
cvs rdiff -u -r1.4.40.1 -r1.4.40.2 src/sys/compat/sys/msg.h
cvs rdiff -u -r1.6 -r1.6.40.1 src/sys/compat/sys/sem.h
cvs rdiff -u -r1.7 -r1.7.38.1 src/sys/compat/sys/shm.h
cvs rdiff -u -r1.66 -r1.66.4.1 src/sys/kern/sysv_msg.c
cvs rdiff -u -r1.90 -r1.90.4.1 src/sys/kern/sysv_sem.c
cvs rdiff -u -r1.125 -r1.125.2.1 src/sys/kern/sysv_shm.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/linux/common/linux_ipc.c
diff -u src/sys/compat/linux/common/linux_ipc.c:1.55 src/sys/compat/linux/common/linux_ipc.c:1.55.30.1
--- src/sys/compat/linux/common/linux_ipc.c:1.55	Sat May 28 23:24:58 2011
+++ src/sys/compat/linux/common/linux_ipc.c	Sat Feb 23 07:02:20 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: linux_ipc.c,v 1.55 2011/05/28 23:24:58 alnsn Exp $	*/
+/*	$NetBSD: linux_ipc.c,v 1.55.30.1 2019/02/23 07:02:20 martin Exp $	*/
 
 /*-
  * Copyright (c) 1995, 1998 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: linux_ipc.c,v 1.55 2011/05/28 23:24:58 alnsn Exp $");
+__KERNEL_RCSID(0, "$NetBSD: linux_ipc.c,v 1.55.30.1 2019/02/23 07:02:20 martin Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_sysv.h"
@@ -117,6 +117,7 @@ void
 bsd_to_linux_ipc_perm(struct ipc_perm *bpp, struct linux_ipc_perm *lpp)
 {
 
+	memset(lpp, 0, sizeof *lpp);
 	lpp->l_key = bpp->_key;
 	lpp->l_uid = bpp->uid;
 	lpp->l_gid = bpp->gid;
@@ -129,6 +130,8 @@ bsd_to_linux_ipc_perm(struct ipc_perm *b
 void
 bsd_to_linux_ipc64_perm(struct ipc_perm *bpp, struct linux_ipc64_perm *lpp)
 {
+
+	memset(lpp, 0, sizeof *lpp);
 	lpp->l_key = bpp->_key;
 	lpp->l_uid = bpp->uid;
 	lpp->l_gid = bpp->gid;
@@ -152,16 +155,19 @@ bsd_to_linux_ipc64_perm(struct ipc_perm 
 void
 bsd_to_linux_semid_ds(struct semid_ds *bs, struct linux_semid_ds *ls)
 {
+
+	memset(ls, 0, sizeof *ls);
 	bsd_to_linux_ipc_perm(>sem_perm, >l_sem_perm);
 	ls->l_sem_otime = bs->sem_otime;
 	ls->l_sem_ctime = bs->sem_ctime;
 	ls->l_sem_nsems = bs->sem_nsems;
-	ls->l_sem_base = bs->_sem_base;
 }
 
 void
 bsd_to_linux_semid64_ds(struct semid_ds *bs, struct 

CVS commit: [netbsd-7] src/sys

2019-02-22 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sat Feb 23 07:02:21 UTC 2019

Modified Files:
src/sys/compat/linux/common [netbsd-7]: linux_ipc.c
src/sys/compat/linux32/common [netbsd-7]: linux32_ipccall.c
src/sys/compat/netbsd32 [netbsd-7]: netbsd32_compat_14.c
netbsd32_conv.h
src/sys/compat/sys [netbsd-7]: ipc.h msg.h sem.h shm.h
src/sys/kern [netbsd-7]: sysv_msg.c sysv_sem.c sysv_shm.c

Log Message:
Pull up following revision(s) (requested by mrg in ticket #1679):
sys/compat/sys/ipc.h: revision 1.6
sys/compat/sys/ipc.h: revision 1.7
sys/compat/sys/shm.h: revision 1.8
sys/kern/sysv_shm.c: revision 1.133
sys/compat/sys/sem.h: revision 1.7
sys/compat/linux/common/linux_ipc.c: revision 1.56
sys/compat/netbsd32/netbsd32_conv.h: revision 1.38
sys/kern/sysv_sem.c: revision 1.96
sys/compat/netbsd32/netbsd32_compat_14.c: revision 1.28
sys/compat/netbsd32/netbsd32_compat_14.c: revision 1.29
sys/compat/linux32/common/linux32_ipccall.c: revision 1.12
sys/kern/sysv_msg.c: revision 1.73
sys/compat/sys/msg.h: revision 1.6

for sysv ipc stat operations, explicitly copy the exported parts
instead of the whole ds structure.
besides triggering a recently added assert in netbsd32, this stops
exposing kernel addresses.

copy the mode clamping to 0777 from sem to shm and msg.

while here, make sure that the compat callers to sysv_ipc clear
the contents of the compat structure before setting the result
members to ensure padding bytes are cleared.

don't set/copy _sem_base, _msg_first, _msg_last or _shm_internal.
even if used, which seems very dodgy, they leak KVAs as well.
possibly this may affect linux binaries, in particular, the
comments around _shm_internal ("XXX Oh well.") may mean apps
rely upon these but hopefully not -- the comments date back to
rev 1.1 in 1995.

the _key, _seq and _msg_cbytes members are exported as before as
i found multiple consumers of these (no less than ipcs(1), and
they appear to be useful for debugging and more.

XXX: the naming of compat functions have too many styles.  there
 are at least 3 different ones changed here.

fix naming errors in previous.  (this file is no longer compiled, but
this fix makes the pull up more obvious, before deleting this file.)

include libkern.h or strings.h.  should fix i386 build issues.


To generate a diff of this commit:
cvs rdiff -u -r1.55 -r1.55.30.1 src/sys/compat/linux/common/linux_ipc.c
cvs rdiff -u -r1.11 -r1.11.34.1 \
src/sys/compat/linux32/common/linux32_ipccall.c
cvs rdiff -u -r1.21.74.1 -r1.21.74.2 \
src/sys/compat/netbsd32/netbsd32_compat_14.c
cvs rdiff -u -r1.28.4.2 -r1.28.4.3 src/sys/compat/netbsd32/netbsd32_conv.h
cvs rdiff -u -r1.4 -r1.4.30.1 src/sys/compat/sys/ipc.h
cvs rdiff -u -r1.4.40.1 -r1.4.40.2 src/sys/compat/sys/msg.h
cvs rdiff -u -r1.6 -r1.6.40.1 src/sys/compat/sys/sem.h
cvs rdiff -u -r1.7 -r1.7.38.1 src/sys/compat/sys/shm.h
cvs rdiff -u -r1.66 -r1.66.4.1 src/sys/kern/sysv_msg.c
cvs rdiff -u -r1.90 -r1.90.4.1 src/sys/kern/sysv_sem.c
cvs rdiff -u -r1.125 -r1.125.2.1 src/sys/kern/sysv_shm.c

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



CVS commit: [netbsd-8] src/doc

2019-02-22 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sat Feb 23 06:59:28 UTC 2019

Modified Files:
src/doc [netbsd-8]: CHANGES-8.1

Log Message:
Ticket #1195


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.109 -r1.1.2.110 src/doc/CHANGES-8.1

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

Modified files:

Index: src/doc/CHANGES-8.1
diff -u src/doc/CHANGES-8.1:1.1.2.109 src/doc/CHANGES-8.1:1.1.2.110
--- src/doc/CHANGES-8.1:1.1.2.109	Wed Feb 20 09:51:25 2019
+++ src/doc/CHANGES-8.1	Sat Feb 23 06:59:28 2019
@@ -1,4 +1,4 @@
-# $NetBSD: CHANGES-8.1,v 1.1.2.109 2019/02/20 09:51:25 martin Exp $
+# $NetBSD: CHANGES-8.1,v 1.1.2.110 2019/02/23 06:59:28 martin Exp $
 
 A complete list of changes from the NetBSD 8.0 release to the NetBSD 8.1
 release:
@@ -2506,3 +2506,22 @@ sys/dev/usb/if_axenreg.h			1.7
 	axen(4): improve RX stability and small cosmetic changes.
 	[rin, ticket #1194]
 
+sys/compat/linux/common/linux_ipc.c		1.56
+sys/compat/linux32/common/linux32_ipccall.c	1.12
+sys/compat/netbsd32/netbsd32_compat_14.c	1.28
+sys/compat/netbsd32/netbsd32_compat_14.c	1.29
+sys/compat/netbsd32/netbsd32_conv.h		1.38
+sys/compat/sys/ipc.h1.6
+sys/compat/sys/ipc.h1.7
+sys/compat/sys/msg.h1.6
+sys/compat/sys/sem.h1.7
+sys/compat/sys/shm.h1.8
+sys/kern/sysv_msg.c1.73
+sys/kern/sysv_sem.c1.96
+sys/kern/sysv_shm.c1.133
+
+	Fix kernel stack and kernel adddress leaks in msgctl, semctl, and
+	shmctl system calls, for native as well as for the netbsd32, linux,
+	and linux32 compatibility calls.
+	[mrg, ticket #1195]
+



CVS commit: [netbsd-8] src/doc

2019-02-22 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sat Feb 23 06:59:28 UTC 2019

Modified Files:
src/doc [netbsd-8]: CHANGES-8.1

Log Message:
Ticket #1195


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.109 -r1.1.2.110 src/doc/CHANGES-8.1

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



CVS commit: [netbsd-8] src/sys

2019-02-22 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sat Feb 23 06:58:14 UTC 2019

Modified Files:
src/sys/compat/linux/common [netbsd-8]: linux_ipc.c
src/sys/compat/linux32/common [netbsd-8]: linux32_ipccall.c
src/sys/compat/netbsd32 [netbsd-8]: netbsd32_compat_14.c
netbsd32_conv.h
src/sys/compat/sys [netbsd-8]: ipc.h msg.h sem.h shm.h
src/sys/kern [netbsd-8]: sysv_msg.c sysv_sem.c sysv_shm.c

Log Message:
Pull up following revision(s) (requested by mrg in ticket #1195):
sys/compat/sys/ipc.h: revision 1.6
sys/compat/sys/ipc.h: revision 1.7
sys/compat/sys/shm.h: revision 1.8
sys/kern/sysv_shm.c: revision 1.133
sys/compat/sys/sem.h: revision 1.7
sys/compat/linux/common/linux_ipc.c: revision 1.56
sys/compat/netbsd32/netbsd32_conv.h: revision 1.38
sys/kern/sysv_sem.c: revision 1.96
sys/compat/netbsd32/netbsd32_compat_14.c: revision 1.28
sys/compat/netbsd32/netbsd32_compat_14.c: revision 1.29
sys/compat/linux32/common/linux32_ipccall.c: revision 1.12
sys/kern/sysv_msg.c: revision 1.73
sys/compat/sys/msg.h: revision 1.6

for sysv ipc stat operations, explicitly copy the exported parts
instead of the whole ds structure.
besides triggering a recently added assert in netbsd32, this stops
exposing kernel addresses.

copy the mode clamping to 0777 from sem to shm and msg.

while here, make sure that the compat callers to sysv_ipc clear
the contents of the compat structure before setting the result
members to ensure padding bytes are cleared.

don't set/copy _sem_base, _msg_first, _msg_last or _shm_internal.
even if used, which seems very dodgy, they leak KVAs as well.
possibly this may affect linux binaries, in particular, the
comments around _shm_internal ("XXX Oh well.") may mean apps
rely upon these but hopefully not -- the comments date back to
rev 1.1 in 1995.

the _key, _seq and _msg_cbytes members are exported as before as
i found multiple consumers of these (no less than ipcs(1), and
they appear to be useful for debugging and more.

XXX: the naming of compat functions have too many styles.  there
 are at least 3 different ones changed here.

fix naming errors in previous.  (this file is no longer compiled, but
this fix makes the pull up more obvious, before deleting this file.)

include libkern.h or strings.h.  should fix i386 build issues.


To generate a diff of this commit:
cvs rdiff -u -r1.55 -r1.55.48.1 src/sys/compat/linux/common/linux_ipc.c
cvs rdiff -u -r1.11 -r1.11.52.1 \
src/sys/compat/linux32/common/linux32_ipccall.c
cvs rdiff -u -r1.26.10.1 -r1.26.10.2 \
src/sys/compat/netbsd32/netbsd32_compat_14.c
cvs rdiff -u -r1.31.8.2 -r1.31.8.3 src/sys/compat/netbsd32/netbsd32_conv.h
cvs rdiff -u -r1.4 -r1.4.48.1 src/sys/compat/sys/ipc.h
cvs rdiff -u -r1.4.58.1 -r1.4.58.2 src/sys/compat/sys/msg.h
cvs rdiff -u -r1.6 -r1.6.58.1 src/sys/compat/sys/sem.h
cvs rdiff -u -r1.7 -r1.7.56.1 src/sys/compat/sys/shm.h
cvs rdiff -u -r1.71 -r1.71.8.1 src/sys/kern/sysv_msg.c
cvs rdiff -u -r1.95 -r1.95.10.1 src/sys/kern/sysv_sem.c
cvs rdiff -u -r1.131 -r1.131.10.1 src/sys/kern/sysv_shm.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/linux/common/linux_ipc.c
diff -u src/sys/compat/linux/common/linux_ipc.c:1.55 src/sys/compat/linux/common/linux_ipc.c:1.55.48.1
--- src/sys/compat/linux/common/linux_ipc.c:1.55	Sat May 28 23:24:58 2011
+++ src/sys/compat/linux/common/linux_ipc.c	Sat Feb 23 06:58:14 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: linux_ipc.c,v 1.55 2011/05/28 23:24:58 alnsn Exp $	*/
+/*	$NetBSD: linux_ipc.c,v 1.55.48.1 2019/02/23 06:58:14 martin Exp $	*/
 
 /*-
  * Copyright (c) 1995, 1998 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: linux_ipc.c,v 1.55 2011/05/28 23:24:58 alnsn Exp $");
+__KERNEL_RCSID(0, "$NetBSD: linux_ipc.c,v 1.55.48.1 2019/02/23 06:58:14 martin Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_sysv.h"
@@ -117,6 +117,7 @@ void
 bsd_to_linux_ipc_perm(struct ipc_perm *bpp, struct linux_ipc_perm *lpp)
 {
 
+	memset(lpp, 0, sizeof *lpp);
 	lpp->l_key = bpp->_key;
 	lpp->l_uid = bpp->uid;
 	lpp->l_gid = bpp->gid;
@@ -129,6 +130,8 @@ bsd_to_linux_ipc_perm(struct ipc_perm *b
 void
 bsd_to_linux_ipc64_perm(struct ipc_perm *bpp, struct linux_ipc64_perm *lpp)
 {
+
+	memset(lpp, 0, sizeof *lpp);
 	lpp->l_key = bpp->_key;
 	lpp->l_uid = bpp->uid;
 	lpp->l_gid = bpp->gid;
@@ -152,16 +155,19 @@ bsd_to_linux_ipc64_perm(struct ipc_perm 
 void
 bsd_to_linux_semid_ds(struct semid_ds *bs, struct linux_semid_ds *ls)
 {
+
+	memset(ls, 0, sizeof *ls);
 	bsd_to_linux_ipc_perm(>sem_perm, >l_sem_perm);
 	ls->l_sem_otime = bs->sem_otime;
 	ls->l_sem_ctime = bs->sem_ctime;
 	ls->l_sem_nsems = bs->sem_nsems;
-	ls->l_sem_base = bs->_sem_base;
 }
 
 void
 bsd_to_linux_semid64_ds(struct semid_ds *bs, struct 

CVS commit: [netbsd-8] src/sys

2019-02-22 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sat Feb 23 06:58:14 UTC 2019

Modified Files:
src/sys/compat/linux/common [netbsd-8]: linux_ipc.c
src/sys/compat/linux32/common [netbsd-8]: linux32_ipccall.c
src/sys/compat/netbsd32 [netbsd-8]: netbsd32_compat_14.c
netbsd32_conv.h
src/sys/compat/sys [netbsd-8]: ipc.h msg.h sem.h shm.h
src/sys/kern [netbsd-8]: sysv_msg.c sysv_sem.c sysv_shm.c

Log Message:
Pull up following revision(s) (requested by mrg in ticket #1195):
sys/compat/sys/ipc.h: revision 1.6
sys/compat/sys/ipc.h: revision 1.7
sys/compat/sys/shm.h: revision 1.8
sys/kern/sysv_shm.c: revision 1.133
sys/compat/sys/sem.h: revision 1.7
sys/compat/linux/common/linux_ipc.c: revision 1.56
sys/compat/netbsd32/netbsd32_conv.h: revision 1.38
sys/kern/sysv_sem.c: revision 1.96
sys/compat/netbsd32/netbsd32_compat_14.c: revision 1.28
sys/compat/netbsd32/netbsd32_compat_14.c: revision 1.29
sys/compat/linux32/common/linux32_ipccall.c: revision 1.12
sys/kern/sysv_msg.c: revision 1.73
sys/compat/sys/msg.h: revision 1.6

for sysv ipc stat operations, explicitly copy the exported parts
instead of the whole ds structure.
besides triggering a recently added assert in netbsd32, this stops
exposing kernel addresses.

copy the mode clamping to 0777 from sem to shm and msg.

while here, make sure that the compat callers to sysv_ipc clear
the contents of the compat structure before setting the result
members to ensure padding bytes are cleared.

don't set/copy _sem_base, _msg_first, _msg_last or _shm_internal.
even if used, which seems very dodgy, they leak KVAs as well.
possibly this may affect linux binaries, in particular, the
comments around _shm_internal ("XXX Oh well.") may mean apps
rely upon these but hopefully not -- the comments date back to
rev 1.1 in 1995.

the _key, _seq and _msg_cbytes members are exported as before as
i found multiple consumers of these (no less than ipcs(1), and
they appear to be useful for debugging and more.

XXX: the naming of compat functions have too many styles.  there
 are at least 3 different ones changed here.

fix naming errors in previous.  (this file is no longer compiled, but
this fix makes the pull up more obvious, before deleting this file.)

include libkern.h or strings.h.  should fix i386 build issues.


To generate a diff of this commit:
cvs rdiff -u -r1.55 -r1.55.48.1 src/sys/compat/linux/common/linux_ipc.c
cvs rdiff -u -r1.11 -r1.11.52.1 \
src/sys/compat/linux32/common/linux32_ipccall.c
cvs rdiff -u -r1.26.10.1 -r1.26.10.2 \
src/sys/compat/netbsd32/netbsd32_compat_14.c
cvs rdiff -u -r1.31.8.2 -r1.31.8.3 src/sys/compat/netbsd32/netbsd32_conv.h
cvs rdiff -u -r1.4 -r1.4.48.1 src/sys/compat/sys/ipc.h
cvs rdiff -u -r1.4.58.1 -r1.4.58.2 src/sys/compat/sys/msg.h
cvs rdiff -u -r1.6 -r1.6.58.1 src/sys/compat/sys/sem.h
cvs rdiff -u -r1.7 -r1.7.56.1 src/sys/compat/sys/shm.h
cvs rdiff -u -r1.71 -r1.71.8.1 src/sys/kern/sysv_msg.c
cvs rdiff -u -r1.95 -r1.95.10.1 src/sys/kern/sysv_sem.c
cvs rdiff -u -r1.131 -r1.131.10.1 src/sys/kern/sysv_shm.c

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



CVS commit: src/tools/gcc

2019-02-22 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Sat Feb 23 06:54:45 UTC 2019

Modified Files:
src/tools/gcc: mknative-gcc

Log Message:
pull out libstdc++ config.h as-is, for gnu.ver processing.
pull out the cxx11_sources and cxx98_sources values to avoid hard coding.


To generate a diff of this commit:
cvs rdiff -u -r1.100 -r1.101 src/tools/gcc/mknative-gcc

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

Modified files:

Index: src/tools/gcc/mknative-gcc
diff -u src/tools/gcc/mknative-gcc:1.100 src/tools/gcc/mknative-gcc:1.101
--- src/tools/gcc/mknative-gcc:1.100	Sat Feb  9 03:57:00 2019
+++ src/tools/gcc/mknative-gcc	Sat Feb 23 06:54:45 2019
@@ -1,5 +1,5 @@
 #!/bin/sh
-#	$NetBSD: mknative-gcc,v 1.100 2019/02/09 03:57:00 mrg Exp $
+#	$NetBSD: mknative-gcc,v 1.101 2019/02/23 06:54:45 mrg Exp $
 #
 # Shell script for generating all the constants needed for a native
 # platform build of gcc.
@@ -233,10 +233,15 @@ get_libstdcxx_v3 () {
 
 	write_c $_OUTDIRBASE/lib/$_subdir/arch/$MACHINE_ARCH/gstdint.h \
 		<$_TMPDIR/$_PLATFORM/libstdc++-v3/include/gstdint.h
+	write_c $_OUTDIRBASE/lib/$_subdir/arch/$MACHINE_ARCH/symver-config.h \
+		<$_TMPDIR/$_PLATFORM/libstdc++-v3/config.h
 
 	{
 		getvars $_PLATFORM/libstdc++-v3/Makefile \
 			port_specific_symbol_files
+		getvars $_PLATFORM/libstdc++-v3/src/Makefile \
+			cxx11_sources \
+			cxx98_sources
 
 		# libsupc++
 		getvars $_PLATFORM/libstdc++-v3/libsupc++/Makefile \



CVS commit: src/tools/gcc

2019-02-22 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Sat Feb 23 06:54:45 UTC 2019

Modified Files:
src/tools/gcc: mknative-gcc

Log Message:
pull out libstdc++ config.h as-is, for gnu.ver processing.
pull out the cxx11_sources and cxx98_sources values to avoid hard coding.


To generate a diff of this commit:
cvs rdiff -u -r1.100 -r1.101 src/tools/gcc/mknative-gcc

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



CVS commit: src

2019-02-22 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Sat Feb 23 03:10:06 UTC 2019

Modified Files:
src/distrib/sets/lists/comp: mi
src/distrib/sets/lists/man: mi
src/distrib/sets/lists/tests: module.mi
src/etc: MAKEDEV.tmpl
src/share/man/man4: Makefile
src/share/mk: bsd.sys.mk
src/sys/arch/amd64/conf: GENERIC
src/sys/conf: files majors ssp.mk
src/sys/kern: files.kern
src/sys/sys: Makefile
src/tests/modules: Makefile
Added Files:
src/share/man/man4: kcov.4
src/sys/kern: subr_kcov.c
src/sys/sys: kcov.h
src/tests/modules: t_kcov.c

Log Message:
Add KCOV - kernel code coverage tracing device

The KCOV driver implements collection of code coverage inside the kernel.
It can be enabled on a per process basis from userland, allowing the kernel
program counter to be collected during syscalls triggered by the same
process.

The device is oriented towards kernel fuzzers, in particular syzkaller.

Currently the only supported coverage type is -fsanitize-coverage=trace-pc.

The KCOV driver was initially developed in Linux. A driver based on the
same concept was then implemented in FreeBSD and OpenBSD.

Documentation is borrowed from OpenBSD and ATF tests from FreeBSD.

This patch has been prepared by Siddharth Muralee, improved by 
and polished by myself before importing into the mainline tree.

All ATF tests pass.


To generate a diff of this commit:
cvs rdiff -u -r1.2258 -r1.2259 src/distrib/sets/lists/comp/mi
cvs rdiff -u -r1.1637 -r1.1638 src/distrib/sets/lists/man/mi
cvs rdiff -u -r1.16 -r1.17 src/distrib/sets/lists/tests/module.mi
cvs rdiff -u -r1.197 -r1.198 src/etc/MAKEDEV.tmpl
cvs rdiff -u -r1.677 -r1.678 src/share/man/man4/Makefile
cvs rdiff -u -r0 -r1.1 src/share/man/man4/kcov.4
cvs rdiff -u -r1.290 -r1.291 src/share/mk/bsd.sys.mk
cvs rdiff -u -r1.516 -r1.517 src/sys/arch/amd64/conf/GENERIC
cvs rdiff -u -r1.1229 -r1.1230 src/sys/conf/files
cvs rdiff -u -r1.80 -r1.81 src/sys/conf/majors
cvs rdiff -u -r1.3 -r1.4 src/sys/conf/ssp.mk
cvs rdiff -u -r1.32 -r1.33 src/sys/kern/files.kern
cvs rdiff -u -r0 -r1.1 src/sys/kern/subr_kcov.c
cvs rdiff -u -r1.168 -r1.169 src/sys/sys/Makefile
cvs rdiff -u -r0 -r1.1 src/sys/sys/kcov.h
cvs rdiff -u -r1.14 -r1.15 src/tests/modules/Makefile
cvs rdiff -u -r0 -r1.1 src/tests/modules/t_kcov.c

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



CVS commit: src

2019-02-22 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Sat Feb 23 03:10:06 UTC 2019

Modified Files:
src/distrib/sets/lists/comp: mi
src/distrib/sets/lists/man: mi
src/distrib/sets/lists/tests: module.mi
src/etc: MAKEDEV.tmpl
src/share/man/man4: Makefile
src/share/mk: bsd.sys.mk
src/sys/arch/amd64/conf: GENERIC
src/sys/conf: files majors ssp.mk
src/sys/kern: files.kern
src/sys/sys: Makefile
src/tests/modules: Makefile
Added Files:
src/share/man/man4: kcov.4
src/sys/kern: subr_kcov.c
src/sys/sys: kcov.h
src/tests/modules: t_kcov.c

Log Message:
Add KCOV - kernel code coverage tracing device

The KCOV driver implements collection of code coverage inside the kernel.
It can be enabled on a per process basis from userland, allowing the kernel
program counter to be collected during syscalls triggered by the same
process.

The device is oriented towards kernel fuzzers, in particular syzkaller.

Currently the only supported coverage type is -fsanitize-coverage=trace-pc.

The KCOV driver was initially developed in Linux. A driver based on the
same concept was then implemented in FreeBSD and OpenBSD.

Documentation is borrowed from OpenBSD and ATF tests from FreeBSD.

This patch has been prepared by Siddharth Muralee, improved by 
and polished by myself before importing into the mainline tree.

All ATF tests pass.


To generate a diff of this commit:
cvs rdiff -u -r1.2258 -r1.2259 src/distrib/sets/lists/comp/mi
cvs rdiff -u -r1.1637 -r1.1638 src/distrib/sets/lists/man/mi
cvs rdiff -u -r1.16 -r1.17 src/distrib/sets/lists/tests/module.mi
cvs rdiff -u -r1.197 -r1.198 src/etc/MAKEDEV.tmpl
cvs rdiff -u -r1.677 -r1.678 src/share/man/man4/Makefile
cvs rdiff -u -r0 -r1.1 src/share/man/man4/kcov.4
cvs rdiff -u -r1.290 -r1.291 src/share/mk/bsd.sys.mk
cvs rdiff -u -r1.516 -r1.517 src/sys/arch/amd64/conf/GENERIC
cvs rdiff -u -r1.1229 -r1.1230 src/sys/conf/files
cvs rdiff -u -r1.80 -r1.81 src/sys/conf/majors
cvs rdiff -u -r1.3 -r1.4 src/sys/conf/ssp.mk
cvs rdiff -u -r1.32 -r1.33 src/sys/kern/files.kern
cvs rdiff -u -r0 -r1.1 src/sys/kern/subr_kcov.c
cvs rdiff -u -r1.168 -r1.169 src/sys/sys/Makefile
cvs rdiff -u -r0 -r1.1 src/sys/sys/kcov.h
cvs rdiff -u -r1.14 -r1.15 src/tests/modules/Makefile
cvs rdiff -u -r0 -r1.1 src/tests/modules/t_kcov.c

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

Modified files:

Index: src/distrib/sets/lists/comp/mi
diff -u src/distrib/sets/lists/comp/mi:1.2258 src/distrib/sets/lists/comp/mi:1.2259
--- src/distrib/sets/lists/comp/mi:1.2258	Sun Feb 10 04:03:03 2019
+++ src/distrib/sets/lists/comp/mi	Sat Feb 23 03:10:05 2019
@@ -1,4 +1,4 @@
-#	$NetBSD: mi,v 1.2258 2019/02/10 04:03:03 mrg Exp $
+#	$NetBSD: mi,v 1.2259 2019/02/23 03:10:05 kamil Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 ./etc/mtree/set.compcomp-sys-root
@@ -3017,6 +3017,7 @@
 ./usr/include/sys/ipc.hcomp-c-include
 ./usr/include/sys/joystick.h			comp-c-include
 ./usr/include/sys/kcore.h			comp-c-include
+./usr/include/sys/kcov.h			comp-c-include
 ./usr/include/sys/kcpuset.h			comp-c-include
 ./usr/include/sys/kernel.h			comp-obsolete		obsolete
 ./usr/include/sys/keylock.h			comp-obsolete		obsolete

Index: src/distrib/sets/lists/man/mi
diff -u src/distrib/sets/lists/man/mi:1.1637 src/distrib/sets/lists/man/mi:1.1638
--- src/distrib/sets/lists/man/mi:1.1637	Wed Feb  6 11:55:05 2019
+++ src/distrib/sets/lists/man/mi	Sat Feb 23 03:10:05 2019
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.1637 2019/02/06 11:55:05 rin Exp $
+# $NetBSD: mi,v 1.1638 2019/02/23 03:10:05 kamil Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 #
@@ -1373,6 +1373,7 @@
 ./usr/share/man/cat4/jmide.0			man-sys-catman		.cat
 ./usr/share/man/cat4/joy.0			man-sys-catman		.cat
 ./usr/share/man/cat4/kame_ipsec.0		man-obsolete		obsolete
+./usr/share/man/cat4/kcov.0			man-sys-catman		.cat
 ./usr/share/man/cat4/kloader.0			man-sys-catman		.cat
 ./usr/share/man/cat4/kse.0			man-sys-catman		.cat
 ./usr/share/man/cat4/ksyms.0			man-sys-catman		.cat
@@ -4496,6 +4497,7 @@
 ./usr/share/man/html4/jmide.html		man-sys-htmlman		html
 ./usr/share/man/html4/joy.html			man-sys-htmlman		html
 ./usr/share/man/html4/kame_ipsec.html		man-obsolete		obsolete
+./usr/share/man/html4/kcov.html		man-sys-htmlman		html
 ./usr/share/man/html4/kloader.html		man-sys-htmlman		html
 ./usr/share/man/html4/kse.html			man-sys-htmlman		html
 ./usr/share/man/html4/ksyms.html		man-sys-htmlman		html
@@ -7459,6 +7461,7 @@
 ./usr/share/man/man4/jmide.4			man-sys-man		.man
 ./usr/share/man/man4/joy.4			man-sys-man		.man
 ./usr/share/man/man4/kame_ipsec.4		man-obsolete		obsolete
+./usr/share/man/man4/kcov.4			man-sys-man		.man
 ./usr/share/man/man4/kloader.4			man-sys-man		.man
 ./usr/share/man/man4/kse.4			man-sys-man		.man
 ./usr/share/man/man4/ksyms.4			

CVS commit: src/sys/arch/sparc/dev

2019-02-22 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Fri Feb 22 23:01:25 UTC 2019

Modified Files:
src/sys/arch/sparc/dev: sxreg.h

Log Message:
some register bits are defined differently by SunOS's sxreg.h and the SPAM
manual, upon investigation the hardware appears to agree with the SunOS header,
so adapt accordingly


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/sys/arch/sparc/dev/sxreg.h

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



CVS commit: src/sys/arch/sparc/dev

2019-02-22 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Fri Feb 22 23:01:25 UTC 2019

Modified Files:
src/sys/arch/sparc/dev: sxreg.h

Log Message:
some register bits are defined differently by SunOS's sxreg.h and the SPAM
manual, upon investigation the hardware appears to agree with the SunOS header,
so adapt accordingly


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/sys/arch/sparc/dev/sxreg.h

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

Modified files:

Index: src/sys/arch/sparc/dev/sxreg.h
diff -u src/sys/arch/sparc/dev/sxreg.h:1.16 src/sys/arch/sparc/dev/sxreg.h:1.17
--- src/sys/arch/sparc/dev/sxreg.h:1.16	Fri Dec  8 22:28:54 2017
+++ src/sys/arch/sparc/dev/sxreg.h	Fri Feb 22 23:01:25 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: sxreg.h,v 1.16 2017/12/08 22:28:54 macallan Exp $	*/
+/*	$NetBSD: sxreg.h,v 1.17 2019/02/22 23:01:25 macallan Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -47,6 +47,8 @@
 #define SX_ID			0x0028
 #define SX_R0_INIT		0x002c
 #define SX_SOFTRESET		0x0030
+#define SX_SYNC			0x0034	/* write will stall CPU until */
+		/* SX is idle		  */
 /* write registers directly, only when processor is stopped */
 #define SX_DIRECT_R0		0x0100
 #define SX_DIRECT_R1		0x0104	/* and so on until R127 */
@@ -73,10 +75,39 @@
 #define SX_EE5		0x0010	/* alignment violation */
 #define SX_EE6		0x0020	/* illegal instruction queue write */
 #define SX_EI		0x0080	/* interrupt on error */
+/*
+ * XXX
+ * the following bit definitions are from the SX manual. They're defined in a
+ * different way in SunOS's sxreg.h, the hardware seems to follow the latter.
+ */
+#if 0
 #define SX_PB		0x1000	/* enable page bound checking */
 #define SX_WO		0x2000	/* write occured ( by SX ) */
 #define SX_GO		0x4000	/* start/stop the processor */
 #define SX_MT		0x8000	/* instruction queue is empty */
+#endif
+
+#define SX_PB		0x0400	/* enable page bound checking */
+#define SX_WO		0x0800	/* write occured ( by SX ) */
+#define SX_GO		0x1000	/* start/stop the processor */
+#define SX_JB		0x2000	/* Jammed/Busy specifies the type of events */
+	/* which increment the SX timer */
+#define SX_MT		0x4000	/* instruction queue is empty */
+#define SX_BZ		0x8000	/* Busy bit. When set it indicates that SX */
+	/* is processing an instruction or an */
+	/* instruction is pending in the Q  */
+#define SX_B0MOD	0x0001	/* When set by SX it indicates that a write */
+	/* to bank zero of the SX registers (0-31) */
+	/* occured */
+#define SX_B1MOD	0x0002	/* When set by SX it indicates that a write */
+	/* to bank 1 of the SX registers (32-63) */
+	/* occured */
+#define SX_B2MOD	0x0004	/* When set by SX it indicates that a write */
+	/* to bank 2 of the SX registers (64-95) */
+	/* occured */
+#define SX_B3MOD	0x0008	/* When set by SX it indicates that a write */
+	/* to bank 3 of the SX registers (96-127) */
+	/* occured */
 
 /* SX_ERROR */
 #define SX_SE1		0x0001	/* illegal instruction */
@@ -87,13 +118,29 @@
 #define SX_SE6		0x0020	/* illegal instruction queue write */
 #define SX_SI		0x0080	/* interrupt on error */
 
-/* SX_ID */
+/* SX_ID from the manual */
+#if 0
 #define SX_ARCHITECTURE_MASK	0x00ff
 #define SX_CHIP_REVISION	0xff00
+#endif
+
+#define SX_ARCHITECTURE_MASK	0x0003
+#define SX_CHIP_REVISION	0x00f8
 
 /* SX_DIAGNOSTICS */
 #define SX_IQ_FIFO_ACCESS	0x0001	/* allow memory instructions
 		 * in SX_INSTRUCTIONS */
+#define SX_SERIAL_INSTRUCTIONS	0x0002	/* force inst. serializing */
+#define SX_RAM_PAGE_CROSS	0x0004	/* indicates page crossing */
+#define SX_ARRAY_CONSTRAINING	0x0008	/* When set constrains VRAM */
+		/* array offset effective */
+		/* address calculation  */
+#define SX_UPG_MPG_DISABLE	0x0010	/* When set, disables page */
+		/* cross input into ld/st */
+		/* state machines */
+#define SX_DIAG_INIT		0x4804		/* Setting of the diag reg */
+		/* upon reset */
+
 
 /*
  * memory referencing instructions are written to 0x8 + PA



CVS commit: src/usr.bin/tip

2019-02-22 Thread Valeriy E. Ushakov
Module Name:src
Committed By:   uwe
Date:   Fri Feb 22 22:25:22 UTC 2019

Modified Files:
src/usr.bin/tip: tip.c

Log Message:
Check getchar() result for EOF.

Call cleanup(SIGHUP) if we get local EOF, as if we've got SIGHUP.
While here, use EOF constant instead of literal -1 in an existing
check.

PR bin/53996


To generate a diff of this commit:
cvs rdiff -u -r1.60 -r1.61 src/usr.bin/tip/tip.c

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

Modified files:

Index: src/usr.bin/tip/tip.c
diff -u src/usr.bin/tip/tip.c:1.60 src/usr.bin/tip/tip.c:1.61
--- src/usr.bin/tip/tip.c:1.60	Wed Feb  6 14:08:50 2019
+++ src/usr.bin/tip/tip.c	Fri Feb 22 22:25:22 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: tip.c,v 1.60 2019/02/06 14:08:50 rin Exp $	*/
+/*	$NetBSD: tip.c,v 1.61 2019/02/22 22:25:22 uwe Exp $	*/
 
 /*
  * Copyright (c) 1983, 1993
@@ -42,7 +42,7 @@ __COPYRIGHT("@(#) Copyright (c) 1983, 19
 #if 0
 static char sccsid[] = "@(#)tip.c	8.1 (Berkeley) 6/6/93";
 #endif
-__RCSID("$NetBSD: tip.c,v 1.60 2019/02/06 14:08:50 rin Exp $");
+__RCSID("$NetBSD: tip.c,v 1.61 2019/02/22 22:25:22 uwe Exp $");
 #endif /* not lint */
 
 /*
@@ -304,7 +304,7 @@ prompt(const char *s, char *volatile p, 
 	unraw();
 	(void)printf("%s", s);
 	if (setjmp(promptbuf) == 0)
-		while ((c = getchar()) != -1 && (*p = c) != '\n' &&
+		while ((c = getchar()) != EOF && (*p = c) != '\n' &&
 		b + l > p)
 			p++;
 	*p = '\0';
@@ -330,6 +330,22 @@ intprompt(int dummy __unused)
 }
 
 /*
+ * getchar() wrapper that checks for EOF on the local end.
+ */
+static char
+xgetchar(void)
+{
+	int c = getchar();
+	if (__predict_false(c == EOF)) {
+		cleanup(SIGHUP);
+		/* NOTREACHED */
+	}
+
+	return (char)c & STRIP_PAR;
+}
+
+
+/*
  * TIPIN   TIPIN
  */
 static void
@@ -350,7 +366,7 @@ tipin(void)
 	}
 
 	for (;;) {
-		gch = getchar()_PAR;
+		gch = xgetchar();
 		if ((gch == character(value(ESCAPE))) && bol) {
 			if (!(gch = escape()))
 continue;
@@ -365,7 +381,7 @@ tipin(void)
 (void)printf("%s\n", gch == '\r' ? "\r" : "");
 			continue;
 		} else if (!cumode && gch && gch == character(value(FORCE)))
-			gch = getchar()_PAR;
+			gch = xgetchar();
 		bol = any(gch, value(EOL));
 		if (boolean(value(RAISE)) && islower((unsigned char)gch))
 			gch = toupper((unsigned char)gch);
@@ -386,7 +402,7 @@ escape(void)
 	esctable_t *p;
 	char c = character(value(ESCAPE));
 
-	gch = (getchar()_PAR);
+	gch = xgetchar();
 	for (p = etable; p->e_char; p++)
 		if (p->e_char == gch) {
 			if ((p->e_flags) && uid)



CVS commit: src/usr.bin/tip

2019-02-22 Thread Valeriy E. Ushakov
Module Name:src
Committed By:   uwe
Date:   Fri Feb 22 22:25:22 UTC 2019

Modified Files:
src/usr.bin/tip: tip.c

Log Message:
Check getchar() result for EOF.

Call cleanup(SIGHUP) if we get local EOF, as if we've got SIGHUP.
While here, use EOF constant instead of literal -1 in an existing
check.

PR bin/53996


To generate a diff of this commit:
cvs rdiff -u -r1.60 -r1.61 src/usr.bin/tip/tip.c

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



CVS commit: src/distrib/amd64/uefi-installimage

2019-02-22 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Fri Feb 22 22:20:18 UTC 2019

Modified Files:
src/distrib/amd64/uefi-installimage: Makefile.bootimage

Log Message:
Explicitly use ${TOOL_AWK} instead of system's awk.


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 \
src/distrib/amd64/uefi-installimage/Makefile.bootimage

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



CVS commit: src/distrib/amd64/uefi-installimage

2019-02-22 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Fri Feb 22 22:20:18 UTC 2019

Modified Files:
src/distrib/amd64/uefi-installimage: Makefile.bootimage

Log Message:
Explicitly use ${TOOL_AWK} instead of system's awk.


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 \
src/distrib/amd64/uefi-installimage/Makefile.bootimage

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

Modified files:

Index: src/distrib/amd64/uefi-installimage/Makefile.bootimage
diff -u src/distrib/amd64/uefi-installimage/Makefile.bootimage:1.10 src/distrib/amd64/uefi-installimage/Makefile.bootimage:1.11
--- src/distrib/amd64/uefi-installimage/Makefile.bootimage:1.10	Fri Feb 22 22:13:58 2019
+++ src/distrib/amd64/uefi-installimage/Makefile.bootimage	Fri Feb 22 22:20:18 2019
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile.bootimage,v 1.10 2019/02/22 22:13:58 tsutsui Exp $
+#	$NetBSD: Makefile.bootimage,v 1.11 2019/02/22 22:20:18 tsutsui Exp $
 #
 # Copyright (c) 2009, 2010, 2011 Izumi Tsutsui.  All rights reserved.
 #
@@ -211,8 +211,8 @@ BSDPARTSECTORS!= expr ${IMAGESECTORS} - 
 FSOFFSET!=	expr ${LABELSECTORS} + ${EFISECTORS}
 SWAPOFFSET!=	expr ${LABELSECTORS} + ${FSSECTORS} + ${EFISECTORS}
 
-BOOTDISK_UUID=`${TOOL_GPT} ${GPT_TIMESSTAMP} ${WORKMBR} show -i 2 | awk '/^GUID/ {print $$2}'`
-SWAPDISK_UUID=`${TOOL_GPT} ${GPT_TIMESSTAMP} ${WORKMBR} show -i 3 | awk '/^GUID/ {print $$2}'`
+BOOTDISK_UUID=`${TOOL_GPT} ${GPT_TIMESSTAMP} ${WORKMBR} show -i 2 | ${TOOL_AWK} '/^GUID/ {print $$2}'`
+SWAPDISK_UUID=`${TOOL_GPT} ${GPT_TIMESSTAMP} ${WORKMBR} show -i 3 | ${TOOL_AWK} '/^GUID/ {print $$2}'`
 .endif
 
 #



CVS commit: src/distrib

2019-02-22 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Fri Feb 22 22:13:58 UTC 2019

Modified Files:
src/distrib/amd64/uefi-installimage: Makefile.bootimage
src/distrib/common/bootimage: Makefile.bootimage

Log Message:
Reduce diffs between common and amd64 uefi Makefile.bootimage files.

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 \
src/distrib/amd64/uefi-installimage/Makefile.bootimage
cvs rdiff -u -r1.20 -r1.21 src/distrib/common/bootimage/Makefile.bootimage

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

Modified files:

Index: src/distrib/amd64/uefi-installimage/Makefile.bootimage
diff -u src/distrib/amd64/uefi-installimage/Makefile.bootimage:1.9 src/distrib/amd64/uefi-installimage/Makefile.bootimage:1.10
--- src/distrib/amd64/uefi-installimage/Makefile.bootimage:1.9	Sat Dec 15 18:03:17 2018
+++ src/distrib/amd64/uefi-installimage/Makefile.bootimage	Fri Feb 22 22:13:58 2019
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile.bootimage,v 1.9 2018/12/15 18:03:17 gson Exp $
+#	$NetBSD: Makefile.bootimage,v 1.10 2019/02/22 22:13:58 tsutsui Exp $
 #
 # Copyright (c) 2009, 2010, 2011 Izumi Tsutsui.  All rights reserved.
 #
@@ -224,8 +224,6 @@ SETS_DEFAULT+=	xbase xcomp xetc xfont xs
 .endif
 
 KERN_SET?=	kern-GENERIC
-COMPRESS_PROGRAM=${"${USE_XZ_SETS:Uno}"!="no":?${TOOL_XZ}:${TOOL_GZIP}}
-TAR_SUFF=	${"${USE_XZ_SETS:Uno}"!="no":?tar.xz:tgz}
 SETS?=		${SETS_DEFAULT}
 IMG_SETS=	${KERN_SET} ${SETS}
 SETS_DIR?=	${RELEASEDIR}/${RELEASEMACHINEDIR}/binary/sets
@@ -241,6 +239,8 @@ WORKFSTAB?=	work.fstab
 WORKRCCONF?=	work.rc.conf
 WORKFS?=work.rootfs
 TARGETFS?=  imgroot.fs
+COMPRESS_PROGRAM=${"${USE_XZ_SETS:Uno}"!="no":?${TOOL_XZ}:${TOOL_GZIP}}
+TAR_SUFF=	${"${USE_XZ_SETS:Uno}"!="no":?tar.xz:tgz}
 
 CLEANFILES+=	${WORKSPEC} ${WORKFSTAB} ${WORKRCCONF} ${WORKFS}
 CLEANFILES+=	${TARGETFS}
@@ -373,7 +373,8 @@ WORKLABEL?=	work.diskproto
 WORKIMG?=	work.img
 EFIWORKDIR?=	work.efidir
 
-CLEANFILES+=	${WORKMBR} ${WORKSWAP} ${WORKEFI} ${WORKGPT}
+CLEANFILES+=	${WORKMBR} ${WORKSWAP}
+CLEANFILES+=	${WORKEFI} ${WORKGPT}
 CLEANFILES+=	${WORKLABEL}.tmp ${WORKLABEL}
 CLEANFILES+=	${WORKIMG} ${IMGBASE}.img
 
@@ -423,7 +424,7 @@ ${IMGBASE}.img:	${TARGETFS}
 	count=2048
 	${DD} if=${WORKMBR} count=${LABELSECTORS} |			\
 	${CAT} - ${WORKEFI} ${TARGETFS} ${WORKGPT} > ${WORKIMG}
-	${TOOL_GPT} ${GPT_TIMESSTAMP} ${WORKIMG} biosboot -i 2\
+	${TOOL_GPT} ${GPT_TIMESSTAMP} ${WORKIMG} biosboot -i 2		\
 	-c ${.OBJDIR}/${WORKDIR}/usr/mdec/gptmbr.bin
 	${TOOL_GPT} ${GPT_TIMESSTAMP} ${WORKIMG} set -a bootme -i 2
 .else	# USE_GPT == "no"

Index: src/distrib/common/bootimage/Makefile.bootimage
diff -u src/distrib/common/bootimage/Makefile.bootimage:1.20 src/distrib/common/bootimage/Makefile.bootimage:1.21
--- src/distrib/common/bootimage/Makefile.bootimage:1.20	Sat Dec 15 18:03:17 2018
+++ src/distrib/common/bootimage/Makefile.bootimage	Fri Feb 22 22:13:58 2019
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile.bootimage,v 1.20 2018/12/15 18:03:17 gson Exp $
+#	$NetBSD: Makefile.bootimage,v 1.21 2019/02/22 22:13:58 tsutsui Exp $
 #
 # Copyright (c) 2009, 2010, 2011 Izumi Tsutsui.  All rights reserved.
 #
@@ -240,7 +240,7 @@ ${TARGETFS}: prepare_md_post
 .endfor
 .if defined(SECONDARY_BOOT)
 	@echo Copying secondary boot...
-	${INSTALL} ${COPY} -m 0644 ${WORKDIR}/usr/mdec/${SECONDARY_BOOT} ${WORKDIR}
+	${INSTALL} ${COPY} -m 0444 ${WORKDIR}/usr/mdec/${SECONDARY_BOOT} ${WORKDIR}
 .endif
 	@echo Preparing /etc/fstab ...
 	${TOOL_SED} < ${FSTAB_IN} > ${WORKFSTAB}
@@ -258,7 +258,7 @@ ${TARGETFS}: prepare_md_post
 	fi
 	${MKDIR} ${MKDIRPERM} ${WORKDIR}/${_TARGET}
 	(cd ${_SRCDIR} ;		\
-	${TOOL_PAX} -rw -pe	-v ${PAX_TIMESTAMP}			\
+	${TOOL_PAX} ${PAX_TIMESTAMP} -rw -pe -v			\
 	${IMGDIR_EXCLUDE}		\
 	. ${.OBJDIR}/${WORKDIR}/${_TARGET} )
 .endfor
@@ -271,8 +271,8 @@ ${TARGETFS}: prepare_md_post
 		false; 			\
 	fi
 	@if [ -f ${_SRC} ]; then 	\
-		echo ${INSTALL} ${COPY} -m 0644 ${_SRC} ${WORKDIR}/${_TARGET};		\
-		${INSTALL} ${COPY} -m 0644 ${_SRC} ${WORKDIR}/${_TARGET};			\
+		echo ${INSTALL} ${COPY} -m 0644 ${_SRC} ${WORKDIR}/${_TARGET}; \
+		${INSTALL} ${COPY} -m 0644 ${_SRC} ${WORKDIR}/${_TARGET}; \
 	fi
 .endfor
 .endif
@@ -370,9 +370,9 @@ ${IMGBASE}.img:	${TARGETFS} ${WORKLABEL}
 .endif
 	${DD} if=${WORKMBR} count=${LABELSECTORS} |			\
 	${CAT} - ${TARGETFS} > ${WORKIMG}
-.else
+.else	# USE_MBR == "no"
 	${INSTALL} ${COPY} -m 0644 ${TARGETFS} ${WORKIMG}
-.endif
+.endif	# USE_MBR != "no"
 .if ${OMIT_SWAPIMG} == "no"
 	${DD} if=/dev/zero of=${WORKSWAP} seek=$$((${SWAPSECTORS} - 1)) count=1
 	${CAT} ${WORKSWAP} >> ${WORKIMG}



CVS commit: src/distrib

2019-02-22 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Fri Feb 22 22:13:58 UTC 2019

Modified Files:
src/distrib/amd64/uefi-installimage: Makefile.bootimage
src/distrib/common/bootimage: Makefile.bootimage

Log Message:
Reduce diffs between common and amd64 uefi Makefile.bootimage files.

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 \
src/distrib/amd64/uefi-installimage/Makefile.bootimage
cvs rdiff -u -r1.20 -r1.21 src/distrib/common/bootimage/Makefile.bootimage

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



CVS commit: src/lib/libm

2019-02-22 Thread Maya Rashish
Module Name:src
Committed By:   maya
Date:   Fri Feb 22 18:17:23 UTC 2019

Modified Files:
src/lib/libm: Makefile

Log Message:
Default our libm to -frounding-math, if built with GCC.

The long-standing GCC default is to not respect rounding mode.
it looks like GCC 7 optimizes rint to a builtin, causing our few
rounding mode tests to fail.

Fixes PR port-amd64/54000: FP tests failing on amd64 since gcc7 import


To generate a diff of this commit:
cvs rdiff -u -r1.205 -r1.206 src/lib/libm/Makefile

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

Modified files:

Index: src/lib/libm/Makefile
diff -u src/lib/libm/Makefile:1.205 src/lib/libm/Makefile:1.206
--- src/lib/libm/Makefile:1.205	Wed Nov  7 04:00:12 2018
+++ src/lib/libm/Makefile	Fri Feb 22 18:17:22 2019
@@ -1,4 +1,4 @@
-#  $NetBSD: Makefile,v 1.205 2018/11/07 04:00:12 riastradh Exp $
+#  $NetBSD: Makefile,v 1.206 2019/02/22 18:17:22 maya Exp $
 #
 #  @(#)Makefile 5.1beta 93/09/24
 #
@@ -14,6 +14,7 @@
 #
 
 NOSANITIZER=		# defined
+COPTS+=			${${ACTIVE_CC} == "gcc":? -frounding-math :}
 
 #
 # There are two options in making libm at fdlibm compile time:



CVS commit: src/lib/libm

2019-02-22 Thread Maya Rashish
Module Name:src
Committed By:   maya
Date:   Fri Feb 22 18:17:23 UTC 2019

Modified Files:
src/lib/libm: Makefile

Log Message:
Default our libm to -frounding-math, if built with GCC.

The long-standing GCC default is to not respect rounding mode.
it looks like GCC 7 optimizes rint to a builtin, causing our few
rounding mode tests to fail.

Fixes PR port-amd64/54000: FP tests failing on amd64 since gcc7 import


To generate a diff of this commit:
cvs rdiff -u -r1.205 -r1.206 src/lib/libm/Makefile

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



CVS commit: src/sys/dev/nvmm/x86

2019-02-22 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Fri Feb 22 12:24:34 UTC 2019

Modified Files:
src/sys/dev/nvmm/x86: nvmm_x86_vmx.c

Log Message:
Fix omission: if we receive a guest trap on CR0, and if the original
instruction would have resulted in Long Mode being enabled, we need to
manually enable Long Mode ourselves. We were already doing that correctly
in setstate, but not in the CR0 trap handler.

Problem initially reported by Aymeric Vincent; ArchLinux wouldn't boot,
now it does and works correctly.

While here, add CR0_ET in the CR0 mask, for the associated shadow to
be taken into account. Normally this shadow bit shouldn't be necessary,
but for now I keep it regardless.


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/sys/dev/nvmm/x86/nvmm_x86_vmx.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/dev/nvmm/x86/nvmm_x86_vmx.c
diff -u src/sys/dev/nvmm/x86/nvmm_x86_vmx.c:1.10 src/sys/dev/nvmm/x86/nvmm_x86_vmx.c:1.11
--- src/sys/dev/nvmm/x86/nvmm_x86_vmx.c:1.10	Thu Feb 21 13:25:44 2019
+++ src/sys/dev/nvmm/x86/nvmm_x86_vmx.c	Fri Feb 22 12:24:34 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: nvmm_x86_vmx.c,v 1.10 2019/02/21 13:25:44 maxv Exp $	*/
+/*	$NetBSD: nvmm_x86_vmx.c,v 1.11 2019/02/22 12:24:34 maxv Exp $	*/
 
 /*
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: nvmm_x86_vmx.c,v 1.10 2019/02/21 13:25:44 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nvmm_x86_vmx.c,v 1.11 2019/02/22 12:24:34 maxv Exp $");
 
 #include 
 #include 
@@ -1154,6 +1154,7 @@ vmx_inkernel_handle_cr0(struct nvmm_mach
 {
 	struct vmx_cpudata *cpudata = vcpu->cpudata;
 	uint64_t type, gpr, cr0;
+	uint64_t efer, ctls1;
 
 	type = __SHIFTOUT(qual, VMX_QUAL_CR_TYPE);
 	if (type != CR_TYPE_WRITE) {
@@ -1176,6 +1177,25 @@ vmx_inkernel_handle_cr0(struct nvmm_mach
 		return -1;
 	}
 
+	/*
+	 * XXX Handle 32bit PAE paging, need to set PDPTEs, fetched manually
+	 * from CR3.
+	 */
+
+	if (cr0 & CR0_PG) {
+		vmx_vmread(VMCS_ENTRY_CTLS, );
+		vmx_vmread(VMCS_GUEST_IA32_EFER, );
+		if (efer & EFER_LME) {
+			ctls1 |= ENTRY_CTLS_LONG_MODE;
+			efer |= EFER_LMA;
+		} else {
+			ctls1 &= ~ENTRY_CTLS_LONG_MODE;
+			efer &= ~EFER_LMA;
+		}
+		vmx_vmwrite(VMCS_GUEST_IA32_EFER, efer);
+		vmx_vmwrite(VMCS_ENTRY_CTLS, ctls1);
+	}
+
 	vmx_vmwrite(VMCS_GUEST_CR0, cr0);
 	vmx_inkernel_advance();
 	return 0;
@@ -2043,7 +2063,7 @@ vmx_vcpu_init(struct nvmm_machine *mach,
 	vmx_vmwrite(VMCS_EXIT_MSR_STORE_COUNT, VMX_MSRLIST_EXIT_NMSR);
 
 	/* Force CR0_NW and CR0_CD to zero, CR0_ET to one. */
-	vmx_vmwrite(VMCS_CR0_MASK, CR0_NW|CR0_CD);
+	vmx_vmwrite(VMCS_CR0_MASK, CR0_NW|CR0_CD|CR0_ET);
 	vmx_vmwrite(VMCS_CR0_SHADOW, CR0_ET);
 
 	/* Force CR4_VMXE to zero. */



CVS commit: src/sys/dev/nvmm/x86

2019-02-22 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Fri Feb 22 12:24:34 UTC 2019

Modified Files:
src/sys/dev/nvmm/x86: nvmm_x86_vmx.c

Log Message:
Fix omission: if we receive a guest trap on CR0, and if the original
instruction would have resulted in Long Mode being enabled, we need to
manually enable Long Mode ourselves. We were already doing that correctly
in setstate, but not in the CR0 trap handler.

Problem initially reported by Aymeric Vincent; ArchLinux wouldn't boot,
now it does and works correctly.

While here, add CR0_ET in the CR0 mask, for the associated shadow to
be taken into account. Normally this shadow bit shouldn't be necessary,
but for now I keep it regardless.


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/sys/dev/nvmm/x86/nvmm_x86_vmx.c

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



CVS commit: src/external/cddl/osnet/dist/uts/common/fs/zfs

2019-02-22 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Fri Feb 22 09:01:32 UTC 2019

Modified Files:
src/external/cddl/osnet/dist/uts/common/fs/zfs: zfs_replay.c

Log Message:
Always set "cn_namelen" in addition to "cn_nameptr".

Fix vnode locking for REMOVE, RMDIR and RENAME.


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 \
src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_replay.c

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



CVS commit: src/external/cddl/osnet/dist/uts/common/fs/zfs

2019-02-22 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Fri Feb 22 09:01:32 UTC 2019

Modified Files:
src/external/cddl/osnet/dist/uts/common/fs/zfs: zfs_replay.c

Log Message:
Always set "cn_namelen" in addition to "cn_nameptr".

Fix vnode locking for REMOVE, RMDIR and RENAME.


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 \
src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_replay.c

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

Modified files:

Index: src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_replay.c
diff -u src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_replay.c:1.11 src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_replay.c:1.12
--- src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_replay.c:1.11	Mon May 28 21:05:07 2018
+++ src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_replay.c	Fri Feb 22 09:01:32 2019
@@ -501,6 +501,9 @@ zfs_replay_create(zfsvfs_t *zfsvfs, lr_c
 			name = (char *)start;
 
 		cn.cn_nameptr = name;
+#ifdef __NetBSD__
+		cn.cn_namelen = strlen(name);
+#endif
 		error = VOP_CREATE(ZTOV(dzp), , , _vattr /*,vflg*/);
 		break;
 	case TX_MKDIR_ATTR:
@@ -519,6 +522,9 @@ zfs_replay_create(zfsvfs_t *zfsvfs, lr_c
 			name = (char *)(lr + 1);
 
 		cn.cn_nameptr = name;
+#ifdef __NetBSD__
+		cn.cn_namelen = strlen(name);
+#endif
 		error = VOP_MKDIR(ZTOV(dzp), , , _vattr /*,vflg*/);
 		break;
 	case TX_MKXATTR:
@@ -528,6 +534,9 @@ zfs_replay_create(zfsvfs_t *zfsvfs, lr_c
 		name = (char *)(lr + 1);
 		link = name + strlen(name) + 1;
 		cn.cn_nameptr = name;
+#ifdef __NetBSD__
+		cn.cn_namelen = strlen(name);
+#endif
 		error = VOP_SYMLINK(ZTOV(dzp), , , _vattr, link /*,vflg*/);
 		break;
 	default:
@@ -585,7 +594,7 @@ zfs_replay_remove(zfsvfs_t *zfsvfs, lr_r
 		goto fail;
 	}
 #ifdef __NetBSD__
-	VOP_UNLOCK(vp, 0);
+	vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
 #endif
 
 	switch ((int)lr->lr_common.lrc_txtype) {
@@ -596,11 +605,12 @@ zfs_replay_remove(zfsvfs_t *zfsvfs, lr_r
 		error = VOP_RMDIR(ZTOV(dzp), vp,  /*,vflg*/);
 		break;
 	default:
+#ifdef __NetBSD__
+		vput(vp);
+#endif
 		error = SET_ERROR(ENOTSUP);
 	}
-#ifdef __NetBSD__
-	vrele(vp);
-#else
+#ifndef __NetBSD__
 	vput(vp);
 #endif
 	VOP_UNLOCK(ZTOV(dzp), 0);
@@ -635,6 +645,9 @@ zfs_replay_link(zfsvfs_t *zfsvfs, lr_lin
 		vflg |= FIGNORECASE;
 
 	cn.cn_nameptr = name;
+#ifdef __NetBSD__
+	cn.cn_namelen = strlen(name);
+#endif
 	cn.cn_cred = kcred;
 #ifndef __NetBSD__
 	cn.cn_thread = curthread;
@@ -698,7 +711,9 @@ zfs_replay_rename(zfsvfs_t *zfsvfs, lr_r
 	VOP_UNLOCK(ZTOV(sdzp), 0);
 	if (error != 0)
 		goto fail;
+#ifndef __NetBSD__
 	VOP_UNLOCK(svp, 0);
+#endif
 
 	tcn.cn_nameptr = tname;
 	tcn.cn_namelen = strlen(tname);
@@ -718,7 +733,8 @@ zfs_replay_rename(zfsvfs_t *zfsvfs, lr_r
 		goto fail;
 	}
 #ifdef __NetBSD__
-	vn_lock(tvp, LK_EXCLUSIVE | LK_RETRY);
+	if (tvp != NULL)
+		vn_lock(tvp, LK_EXCLUSIVE | LK_RETRY);
 #endif
 
 	error = VOP_RENAME(ZTOV(sdzp), svp, , ZTOV(tdzp), tvp,  /*,vflg*/);