CVS commit: src/tools/gcc

2018-09-04 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Wed Sep  5 05:03:28 UTC 2018

Modified Files:
src/tools/gcc: gcc-version.mk

Log Message:
remove GCC 5 marker.  this is now nb3 20180905.


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/tools/gcc/gcc-version.mk

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/gcc-version.mk
diff -u src/tools/gcc/gcc-version.mk:1.10 src/tools/gcc/gcc-version.mk:1.11
--- src/tools/gcc/gcc-version.mk:1.10	Wed Mar 28 19:30:41 2018
+++ src/tools/gcc/gcc-version.mk	Wed Sep  5 05:03:28 2018
@@ -1,9 +1,9 @@
-#	$NetBSD: gcc-version.mk,v 1.10 2018/03/28 19:30:41 mrg Exp $
+#	$NetBSD: gcc-version.mk,v 1.11 2018/09/05 05:03:28 mrg Exp $
 
 # common location for tools and native build
 
-.if ${HAVE_GCC} == 5
-NETBSD_GCC_VERSION=nb2 20180327
-.elif ${HAVE_GCC} == 6
-NETBSD_GCC_VERSION=nb2 20180327
+.if ${HAVE_GCC} == 6
+NETBSD_GCC_VERSION=nb3 20180905
+.elif ${HAVE_GCC} == 7
+NETBSD_GCC_VERSION=nb1 20180905
 .endif



CVS commit: src/share/misc

2018-09-04 Thread Eitan Adler
Module Name:src
Committed By:   eadler
Date:   Wed Sep  5 04:01:32 UTC 2018

Modified Files:
src/share/misc: bsd-family-tree

Log Message:
bsd-family-tree: Add NetBSD 7.2; fix 8.0

8.0 was not derived from 7.x.
Also add recent release of 7.2.

Reported by:martin


To generate a diff of this commit:
cvs rdiff -u -r1.71 -r1.72 src/share/misc/bsd-family-tree

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

Modified files:

Index: src/share/misc/bsd-family-tree
diff -u src/share/misc/bsd-family-tree:1.71 src/share/misc/bsd-family-tree:1.72
--- src/share/misc/bsd-family-tree:1.71	Wed Aug 15 15:46:41 2018
+++ src/share/misc/bsd-family-tree	Wed Sep  5 04:01:32 2018
@@ -368,12 +368,12 @@ FreeBSD 5.2   |  |  
  | |  | |  NetBSD 7.1.2|   |
  | |  | |  |   |   |
  | |  | |  |  OpenBSD 6.3  |
- | |  | |  |   |   DragonFly 5.2.0
- | |  | |  |   |   |
+ | |  |  NetBSD|   |   DragonFly 5.2.0
+ | |  |8.0 |   |   |
  | |  | |  |   |   DragonFly 5.2.1
  | |  | |  |   |   |
  | |  | |  |   |   DragonFly 5.2.2
- |  FreeBSD   | |  NetBSD 8.0  |   |
+ |  FreeBSD   | |  NetBSD 7.2  |   |
  |   11.2 | |  |   |   |
  | v  | |  |   |   |
  || |  v   |   |
@@ -752,6 +752,7 @@ DragonFly 5.2.1		2018-05-20 [DFB]
 DragonFly 5.2.2		2018-06-18 [DFB]
 FreeBSD 11.2		2018-06-27 [FBD]
 NetBSD 8.0		2018-07-17 [NBD]
+NetBSD 7.2		2018-08-29 [NBD]
 
 Bibliography
 
@@ -817,4 +818,4 @@ Copyright (c) 1997-2012 Wolfram Schneide
 URL: https://svnweb.freebsd.org/base/head/share/misc/bsd-family-tree
 
 $FreeBSD: head/share/misc/bsd-family-tree 336757 2018-07-27 10:40:48Z eadler $
-$NetBSD: bsd-family-tree,v 1.71 2018/08/15 15:46:41 sevan Exp $
+$NetBSD: bsd-family-tree,v 1.72 2018/09/05 04:01:32 eadler Exp $



CVS commit: src/sys/net

2018-09-04 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Wed Sep  5 02:49:09 UTC 2018

Modified Files:
src/sys/net: route.c

Log Message:
route: don't take an extra reference of a rtentry for the delayed free mechanism

Because a reference is already taken at that point.


To generate a diff of this commit:
cvs rdiff -u -r1.211 -r1.212 src/sys/net/route.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/route.c
diff -u src/sys/net/route.c:1.211 src/sys/net/route.c:1.212
--- src/sys/net/route.c:1.211	Thu Jul 12 02:26:04 2018
+++ src/sys/net/route.c	Wed Sep  5 02:49:09 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: route.c,v 1.211 2018/07/12 02:26:04 ozaki-r Exp $	*/
+/*	$NetBSD: route.c,v 1.212 2018/09/05 02:49:09 ozaki-r Exp $	*/
 
 /*-
  * Copyright (c) 1998, 2008 The NetBSD Foundation, Inc.
@@ -97,7 +97,7 @@
 #endif
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: route.c,v 1.211 2018/07/12 02:26:04 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: route.c,v 1.212 2018/09/05 02:49:09 ozaki-r Exp $");
 
 #include 
 #ifdef RTFLUSH_DEBUG
@@ -726,7 +726,7 @@ rt_free(struct rtentry *rt)
 	}
 
 	mutex_enter(_free_global.lock);
-	rt_ref(rt);
+	/* No need to add a reference here. */
 	SLIST_INSERT_HEAD(_free_global.queue, rt, rt_free);
 	if (!rt_free_global.enqueued) {
 		workqueue_enqueue(rt_free_global.wq, _free_global.wk, NULL);



CVS commit: src/sys/net

2018-09-04 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Wed Sep  5 02:49:41 UTC 2018

Modified Files:
src/sys/net: route.c

Log Message:
route: avoid overwriting rt_free_global.enqueued unexpectedly

rt_free_global.enqueued can be set to true by rt_free during rt_free_work
because rt_free_work releases rt_free_global.lock.  So rt_free_work must update
it once and not update after releasing the lock.


To generate a diff of this commit:
cvs rdiff -u -r1.212 -r1.213 src/sys/net/route.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/route.c
diff -u src/sys/net/route.c:1.212 src/sys/net/route.c:1.213
--- src/sys/net/route.c:1.212	Wed Sep  5 02:49:09 2018
+++ src/sys/net/route.c	Wed Sep  5 02:49:40 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: route.c,v 1.212 2018/09/05 02:49:09 ozaki-r Exp $	*/
+/*	$NetBSD: route.c,v 1.213 2018/09/05 02:49:40 ozaki-r Exp $	*/
 
 /*-
  * Copyright (c) 1998, 2008 The NetBSD Foundation, Inc.
@@ -97,7 +97,7 @@
 #endif
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: route.c,v 1.212 2018/09/05 02:49:09 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: route.c,v 1.213 2018/09/05 02:49:40 ozaki-r Exp $");
 
 #include 
 #ifdef RTFLUSH_DEBUG
@@ -702,8 +702,8 @@ rt_free_work(struct work *wk, void *arg)
 		struct rtentry *rt;
 
 		mutex_enter(_free_global.lock);
-		rt_free_global.enqueued = false;
 		if ((rt = SLIST_FIRST(_free_global.queue)) == NULL) {
+			rt_free_global.enqueued = false;
 			mutex_exit(_free_global.lock);
 			return;
 		}



CVS commit: src/tools/gcc

2018-09-04 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Wed Sep  5 01:20:20 UTC 2018

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

Log Message:
copy across GCC 6.4 mknative-gcc into mknative-gcc.old.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/tools/gcc/mknative-gcc.old

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.old
diff -u src/tools/gcc/mknative-gcc.old:1.5 src/tools/gcc/mknative-gcc.old:1.6
--- src/tools/gcc/mknative-gcc.old:1.5	Wed Oct  4 21:42:20 2017
+++ src/tools/gcc/mknative-gcc.old	Wed Sep  5 01:20:20 2018
@@ -1,10 +1,10 @@
 #!/bin/sh
-#	$NetBSD: mknative-gcc.old,v 1.5 2017/10/04 21:42:20 christos Exp $
+#	$NetBSD: mknative-gcc.old,v 1.6 2018/09/05 01:20:20 mrg Exp $
 #
 # Shell script for generating all the constants needed for a native
 # platform build of gcc.
 #
-# This version is for GCC 5.3
+# This version is for GCC 6.4
 
 # initialise
 
@@ -71,7 +71,9 @@ get_libgcc () {
 	cd $_TMPDIR/$_PLATFORM/libgcc
 	{
 		getvars $_PLATFORM/libgcc/Makefile \
-			INCLUDES LIB2ADD LIB2ADDEH LIB2ADD_ST \
+			INCLUDES \
+			INTERNAL_CFLAGS \
+			LIB2ADD LIB2ADDEH LIB2ADD_ST \
 			LIB1ASMFUNCS LIB1ASMSRC \
 			LIB2_DIVMOD_FUNCS LIB2FUNCS_ST \
 			LIB2FUNCS_EXTRA \
@@ -221,6 +223,9 @@ get_libstdcxx_v3 () {
 		<$_TMPDIR/$_PLATFORM/libstdc++-v3/include/gstdint.h
 
 	{
+		getvars $_PLATFORM/libstdc++-v3/Makefile \
+			port_specific_symbol_files
+
 		# libsupc++
 		getvars $_PLATFORM/libstdc++-v3/libsupc++/Makefile \
 			sources | sed 's/^G_sources=/G_LIBSUPCXX_SOURCES=/'
@@ -303,7 +308,7 @@ get_gcc () {
 			-e 's#build/##g'
 		getvars gcc/Makefile \
 			ALL_CFLAGS ALL_CPPFLAGS C_AND_OBJC_OBJS C_OBJS CCCP_OBJS \
-			GCC_OBJS GCOV_OBJS GXX_OBJS GTM_H PROTO_OBJS ${_extravars1} \
+			GCC_OBJS GCOV_OBJS GCOV_DUMP_OBJS GXX_OBJS GTM_H PROTO_OBJS ${_extravars1} \
 			INCLUDES md_file OBJC_OBJS OBJS out_file version \
 			BUILD_PREFIX RTL_H RTL_BASE_H TREE_H ${_hconfig_h} BASIC_BLOCK_H GCC_H \
 			GGC_H \
@@ -366,10 +371,9 @@ __EOF__
 		if [ "${f}" = "configargs" ]
 		then
 			_srcquoted=$(echo "$_SRC" | sed 's/\//\\\//g')
-			ex <<__EOF__ $_OUTDIR/usr.bin/$_subdir/arch/$MACHINE_ARCH/$f.h
-/static const char configuration_arguments/ s/$_srcquoted/\/usr\/src/g
-wq
-__EOF__
+			sed -i -E -e "s,$_srcquoted,/usr/src,g" \
+  -e 's/--build=[^ ]+ --host=([^ ]+)/--build=\1 --host=\1/' \
+$_OUTDIR/usr.bin/$_subdir/arch/$MACHINE_ARCH/$f.h
 		fi
 	done
 



CVS commit: src/external/gpl3/gcc/lib/libgcc

2018-09-04 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Wed Sep  5 00:51:42 UTC 2018

Modified Files:
src/external/gpl3/gcc/lib/libgcc: Makefile.inc

Log Message:
pull -DHAVE_CC_TLS out of $(INTERNAL_CFLAGS) if it is there, and add
it to CPPFLAGS.

this fixes PR#53567 for me.


To generate a diff of this commit:
cvs rdiff -u -r1.36 -r1.37 src/external/gpl3/gcc/lib/libgcc/Makefile.inc

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

Modified files:

Index: src/external/gpl3/gcc/lib/libgcc/Makefile.inc
diff -u src/external/gpl3/gcc/lib/libgcc/Makefile.inc:1.36 src/external/gpl3/gcc/lib/libgcc/Makefile.inc:1.37
--- src/external/gpl3/gcc/lib/libgcc/Makefile.inc:1.36	Sat Jul 14 23:40:19 2018
+++ src/external/gpl3/gcc/lib/libgcc/Makefile.inc	Wed Sep  5 00:51:42 2018
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile.inc,v 1.36 2018/07/14 23:40:19 christos Exp $
+#	$NetBSD: Makefile.inc,v 1.37 2018/09/05 00:51:42 mrg Exp $
 
 LIBGCC_MACHINE_ARCH?=${MACHINE_ARCH:S/earmv5/earm/}
 
@@ -28,6 +28,7 @@ CPPFLAGS+=	-I${DIST}/libgcc/config/i386
 CPPFLAGS+=	-I${DIST}/libgcc/config/${LIBGCC_MACHINE_ARCH}
 .endif
 CPPFLAGS+=	-I${DIST}/gcc -I${DIST}/include -I.
+CPPFLAGS+=	${G_INTERNAL_CFLAGS:M-DHAVE_CC_TLS}
 
 .if ${LIBGCC_MACHINE_ARCH} == "powerpc" || \
 ${LIBGCC_MACHINE_ARCH} == "sh3el" || \



CVS commit: src/external/gpl3/gcc/lib/libgcc/arch

2018-09-04 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Wed Sep  5 00:22:10 UTC 2018

Modified Files:
src/external/gpl3/gcc/lib/libgcc/arch/aarch64: defs.mk
src/external/gpl3/gcc/lib/libgcc/arch/alpha: defs.mk
src/external/gpl3/gcc/lib/libgcc/arch/arm: defs.mk
src/external/gpl3/gcc/lib/libgcc/arch/armeb: defs.mk
src/external/gpl3/gcc/lib/libgcc/arch/earm: defs.mk
src/external/gpl3/gcc/lib/libgcc/arch/earmeb: defs.mk
src/external/gpl3/gcc/lib/libgcc/arch/earmhf: defs.mk
src/external/gpl3/gcc/lib/libgcc/arch/earmhfeb: defs.mk
src/external/gpl3/gcc/lib/libgcc/arch/earmv4: defs.mk
src/external/gpl3/gcc/lib/libgcc/arch/earmv4eb: defs.mk
src/external/gpl3/gcc/lib/libgcc/arch/earmv6: defs.mk
src/external/gpl3/gcc/lib/libgcc/arch/earmv6eb: defs.mk
src/external/gpl3/gcc/lib/libgcc/arch/earmv6hf: defs.mk
src/external/gpl3/gcc/lib/libgcc/arch/earmv6hfeb: defs.mk
src/external/gpl3/gcc/lib/libgcc/arch/earmv7: defs.mk
src/external/gpl3/gcc/lib/libgcc/arch/earmv7eb: defs.mk
src/external/gpl3/gcc/lib/libgcc/arch/earmv7hf: defs.mk
src/external/gpl3/gcc/lib/libgcc/arch/earmv7hfeb: defs.mk
src/external/gpl3/gcc/lib/libgcc/arch/hppa: defs.mk
src/external/gpl3/gcc/lib/libgcc/arch/i386: defs.mk
src/external/gpl3/gcc/lib/libgcc/arch/ia64: defs.mk
src/external/gpl3/gcc/lib/libgcc/arch/m68000: defs.mk
src/external/gpl3/gcc/lib/libgcc/arch/m68k: defs.mk
src/external/gpl3/gcc/lib/libgcc/arch/mips64eb: defs.mk
src/external/gpl3/gcc/lib/libgcc/arch/mips64el: defs.mk
src/external/gpl3/gcc/lib/libgcc/arch/mipseb: defs.mk
src/external/gpl3/gcc/lib/libgcc/arch/mipsel: defs.mk
src/external/gpl3/gcc/lib/libgcc/arch/powerpc: defs.mk
src/external/gpl3/gcc/lib/libgcc/arch/powerpc64: defs.mk
src/external/gpl3/gcc/lib/libgcc/arch/sh3eb: defs.mk
src/external/gpl3/gcc/lib/libgcc/arch/sh3el: defs.mk
src/external/gpl3/gcc/lib/libgcc/arch/sparc: defs.mk
src/external/gpl3/gcc/lib/libgcc/arch/sparc64: defs.mk
src/external/gpl3/gcc/lib/libgcc/arch/vax: defs.mk
src/external/gpl3/gcc/lib/libgcc/arch/x86_64: defs.mk

Log Message:
regen to pull out INTERNAL_CFLAGS.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 \
src/external/gpl3/gcc/lib/libgcc/arch/aarch64/defs.mk
cvs rdiff -u -r1.3 -r1.4 src/external/gpl3/gcc/lib/libgcc/arch/alpha/defs.mk
cvs rdiff -u -r1.2 -r1.3 src/external/gpl3/gcc/lib/libgcc/arch/arm/defs.mk
cvs rdiff -u -r1.2 -r1.3 src/external/gpl3/gcc/lib/libgcc/arch/armeb/defs.mk
cvs rdiff -u -r1.4 -r1.5 src/external/gpl3/gcc/lib/libgcc/arch/earm/defs.mk
cvs rdiff -u -r1.3 -r1.4 src/external/gpl3/gcc/lib/libgcc/arch/earmeb/defs.mk
cvs rdiff -u -r1.3 -r1.4 src/external/gpl3/gcc/lib/libgcc/arch/earmhf/defs.mk
cvs rdiff -u -r1.3 -r1.4 \
src/external/gpl3/gcc/lib/libgcc/arch/earmhfeb/defs.mk
cvs rdiff -u -r1.3 -r1.4 src/external/gpl3/gcc/lib/libgcc/arch/earmv4/defs.mk
cvs rdiff -u -r1.3 -r1.4 \
src/external/gpl3/gcc/lib/libgcc/arch/earmv4eb/defs.mk
cvs rdiff -u -r1.3 -r1.4 src/external/gpl3/gcc/lib/libgcc/arch/earmv6/defs.mk
cvs rdiff -u -r1.3 -r1.4 \
src/external/gpl3/gcc/lib/libgcc/arch/earmv6eb/defs.mk
cvs rdiff -u -r1.3 -r1.4 \
src/external/gpl3/gcc/lib/libgcc/arch/earmv6hf/defs.mk
cvs rdiff -u -r1.3 -r1.4 \
src/external/gpl3/gcc/lib/libgcc/arch/earmv6hfeb/defs.mk
cvs rdiff -u -r1.3 -r1.4 src/external/gpl3/gcc/lib/libgcc/arch/earmv7/defs.mk
cvs rdiff -u -r1.3 -r1.4 \
src/external/gpl3/gcc/lib/libgcc/arch/earmv7eb/defs.mk
cvs rdiff -u -r1.3 -r1.4 \
src/external/gpl3/gcc/lib/libgcc/arch/earmv7hf/defs.mk
cvs rdiff -u -r1.3 -r1.4 \
src/external/gpl3/gcc/lib/libgcc/arch/earmv7hfeb/defs.mk
cvs rdiff -u -r1.3 -r1.4 src/external/gpl3/gcc/lib/libgcc/arch/hppa/defs.mk
cvs rdiff -u -r1.7 -r1.8 src/external/gpl3/gcc/lib/libgcc/arch/i386/defs.mk
cvs rdiff -u -r1.4 -r1.5 src/external/gpl3/gcc/lib/libgcc/arch/ia64/defs.mk
cvs rdiff -u -r1.9 -r1.10 \
src/external/gpl3/gcc/lib/libgcc/arch/m68000/defs.mk
cvs rdiff -u -r1.4 -r1.5 src/external/gpl3/gcc/lib/libgcc/arch/m68k/defs.mk
cvs rdiff -u -r1.6 -r1.7 \
src/external/gpl3/gcc/lib/libgcc/arch/mips64eb/defs.mk
cvs rdiff -u -r1.5 -r1.6 \
src/external/gpl3/gcc/lib/libgcc/arch/mips64el/defs.mk
cvs rdiff -u -r1.3 -r1.4 src/external/gpl3/gcc/lib/libgcc/arch/mipseb/defs.mk
cvs rdiff -u -r1.3 -r1.4 src/external/gpl3/gcc/lib/libgcc/arch/mipsel/defs.mk
cvs rdiff -u -r1.4 -r1.5 \
src/external/gpl3/gcc/lib/libgcc/arch/powerpc/defs.mk
cvs rdiff -u -r1.4 -r1.5 \
src/external/gpl3/gcc/lib/libgcc/arch/powerpc64/defs.mk
cvs rdiff -u -r1.2 -r1.3 src/external/gpl3/gcc/lib/libgcc/arch/sh3eb/defs.mk
cvs rdiff -u -r1.2 -r1.3 src/external/gpl3/gcc/lib/libgcc/arch/sh3el/defs.mk
cvs rdiff -u -r1.3 -r1.4 src/external/gpl3/gcc/lib/libgcc/arch/sparc/defs.mk
cvs rdiff -u -r1.3 -r1.4 \

CVS commit: src/bin/sh

2018-09-04 Thread Robert Elz
Module Name:src
Committed By:   kre
Date:   Tue Sep  4 23:16:30 UTC 2018

Modified Files:
src/bin/sh: jobs.c jobs.h sh.1

Log Message:
Change the way the pipefail option works.   Now it is the setting of
the option when a pipeline is created that controls the way the exit
status of the pipeline is calculated.  Previously it was the state of
the option when the exit status of the pipeline was collected.

This makes no difference at all for foreground pipelines (there is
no way to change the option between starting and completing the
pipeline) but it does for asynchronous (background) pipelines.

This was always the right way to implement it - it was originally
done the other way as I could not find any other shell implemented
this way - they all seemed to do it our previous way, and I could
not see a good reason to be the sole different shell.

However, now I know that ksh93 works as we will now work, and I
am told that if the option is added to the FreeBSD shell (apparently
the code exists, uncommitted) it will be the same.


To generate a diff of this commit:
cvs rdiff -u -r1.99 -r1.100 src/bin/sh/jobs.c
cvs rdiff -u -r1.21 -r1.22 src/bin/sh/jobs.h
cvs rdiff -u -r1.207 -r1.208 src/bin/sh/sh.1

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

Modified files:

Index: src/bin/sh/jobs.c
diff -u src/bin/sh/jobs.c:1.99 src/bin/sh/jobs.c:1.100
--- src/bin/sh/jobs.c:1.99	Tue Sep  4 01:09:28 2018
+++ src/bin/sh/jobs.c	Tue Sep  4 23:16:30 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: jobs.c,v 1.99 2018/09/04 01:09:28 kre Exp $	*/
+/*	$NetBSD: jobs.c,v 1.100 2018/09/04 23:16:30 kre Exp $	*/
 
 /*-
  * Copyright (c) 1991, 1993
@@ -37,7 +37,7 @@
 #if 0
 static char sccsid[] = "@(#)jobs.c	8.5 (Berkeley) 5/4/95";
 #else
-__RCSID("$NetBSD: jobs.c,v 1.99 2018/09/04 01:09:28 kre Exp $");
+__RCSID("$NetBSD: jobs.c,v 1.100 2018/09/04 23:16:30 kre Exp $");
 #endif
 #endif /* not lint */
 
@@ -635,7 +635,7 @@ jobstatus(const struct job *jp, int raw)
 	int status = 0;
 	int retval;
 
-	if (pipefail && jp->nprocs) {
+	if ((jp->flags & JPIPEFAIL) && jp->nprocs) {
 		int i;
 
 		for (i = 0; i < jp->nprocs; i++)
@@ -1068,7 +1068,7 @@ makejob(union node *node, int nprocs)
 	INTOFF;
 	jp->state = JOBRUNNING;
 	jp->used = 1;
-	jp->flags = 0;
+	jp->flags = pipefail ? JPIPEFAIL : 0;
 	jp->nprocs = 0;
 	jp->pgrp = 0;
 #if JOBS
@@ -1081,8 +1081,8 @@ makejob(union node *node, int nprocs)
 		jp->ps = >ps0;
 	}
 	INTON;
-	VTRACE(DBG_JOBS, ("makejob(0x%lx, %d) returns %%%d\n",
-	(long)node, nprocs, jp - jobtab + 1));
+	VTRACE(DBG_JOBS, ("makejob(%p, %d)%s returns %%%d\n", (void *)node,
+	nprocs, (jp->flags)?" PF":"", jp - jobtab + 1));
 	return jp;
 }
 

Index: src/bin/sh/jobs.h
diff -u src/bin/sh/jobs.h:1.21 src/bin/sh/jobs.h:1.22
--- src/bin/sh/jobs.h:1.21	Sat Oct 28 06:36:17 2017
+++ src/bin/sh/jobs.h	Tue Sep  4 23:16:30 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: jobs.h,v 1.21 2017/10/28 06:36:17 kre Exp $	*/
+/*	$NetBSD: jobs.h,v 1.22 2018/09/04 23:16:30 kre Exp $	*/
 
 /*-
  * Copyright (c) 1991, 1993
@@ -79,6 +79,7 @@ struct job {
 	char	flags;	
 #define	JOBCHANGED	1	/* set if status has changed */
 #define	JOBWANTED	2	/* set if this is a job being sought */
+#define JPIPEFAIL	4	/* set if -o pipefail when job created */
 #if JOBS
 	char 	jobctl;		/* job running under job control */
 	int	prev_job;	/* previous job index */

Index: src/bin/sh/sh.1
diff -u src/bin/sh/sh.1:1.207 src/bin/sh/sh.1:1.208
--- src/bin/sh/sh.1:1.207	Sat Aug 25 17:35:31 2018
+++ src/bin/sh/sh.1	Tue Sep  4 23:16:30 2018
@@ -1,4 +1,4 @@
-.\"	$NetBSD: sh.1,v 1.207 2018/08/25 17:35:31 kre Exp $
+.\"	$NetBSD: sh.1,v 1.208 2018/09/04 23:16:30 kre Exp $
 .\" Copyright (c) 1991, 1993
 .\"	The Regents of the University of California.  All rights reserved.
 .\"
@@ -488,7 +488,8 @@ in the
 section.)
 (Not implemented.)
 .It "\ \ " Em pipefail
-If set, the way the exit status of a pipeline is determined
+If set when a pipeline is created,
+the way the exit status of the pipeline is determined
 is altered.
 See
 .Sx Pipelines
@@ -1155,16 +1156,16 @@ The simplest case of a pipeline is a sin
 .Pp
 If the
 .Ic pipefail
-option is set when the pipeline completes and its status is
-collected, the pipeline status is the status of
-the last (rightmost) command in the pipeline to exit with non-zero exit
-status, or zero, if, and only if, all commands in the pipeline
-exited with a status of zero.
+option was set when a pipeline was started,
+the pipeline status is the status of
+the last (lexically last, i.e.: rightmost) command in the
+pipeline to exit with non-zero exit status, or zero, if,
+and only if, all commands in the pipeline exited with a status of zero.
 If the
 .Ic pipefail
-option is not set, which is the default state,
+option was not set, which is the default state,
 the pipeline status is the exit
-status of the last command in the pipeline,
+status of the last (rightmost) command in the pipeline,
 

CVS commit: src/tools/gcc

2018-09-04 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Tue Sep  4 22:57:25 UTC 2018

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

Log Message:
also pullout INTERNAL_CFLAGS for the libgcc build, where it may have
-DHAVE_CC_TLS defined on the command line.  (we already collect all
the other components.)


To generate a diff of this commit:
cvs rdiff -u -r1.93 -r1.94 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.93 src/tools/gcc/mknative-gcc:1.94
--- src/tools/gcc/mknative-gcc:1.93	Tue Sep  4 06:40:37 2018
+++ src/tools/gcc/mknative-gcc	Tue Sep  4 22:57:25 2018
@@ -1,5 +1,5 @@
 #!/bin/sh
-#	$NetBSD: mknative-gcc,v 1.93 2018/09/04 06:40:37 mrg Exp $
+#	$NetBSD: mknative-gcc,v 1.94 2018/09/04 22:57:25 mrg Exp $
 #
 # Shell script for generating all the constants needed for a native
 # platform build of gcc.
@@ -71,7 +71,9 @@ get_libgcc () {
 	cd $_TMPDIR/$_PLATFORM/libgcc
 	{
 		getvars $_PLATFORM/libgcc/Makefile \
-			INCLUDES LIB2ADD LIB2ADDEH LIB2ADD_ST \
+			INCLUDES \
+			INTERNAL_CFLAGS \
+			LIB2ADD LIB2ADDEH LIB2ADD_ST \
 			LIB1ASMFUNCS LIB1ASMSRC \
 			LIB2_DIVMOD_FUNCS LIB2FUNCS_ST \
 			LIB2FUNCS_EXTRA \



CVS commit: src/sys/stand/efiboot

2018-09-04 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Tue Sep  4 21:29:54 UTC 2018

Modified Files:
src/sys/stand/efiboot: efinet.c

Log Message:
If the loader is loaded from the network, try to load the kernel from the
same network device.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/stand/efiboot/efinet.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/stand/efiboot/efinet.c
diff -u src/sys/stand/efiboot/efinet.c:1.2 src/sys/stand/efiboot/efinet.c:1.3
--- src/sys/stand/efiboot/efinet.c:1.2	Tue Sep  4 15:08:30 2018
+++ src/sys/stand/efiboot/efinet.c	Tue Sep  4 21:29:54 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: efinet.c,v 1.2 2018/09/04 15:08:30 riastradh Exp $	*/
+/*	$NetBSD: efinet.c,v 1.3 2018/09/04 21:29:54 jmcneill Exp $	*/
 
 /*-
  * Copyright (c) 2001 Doug Rabson
@@ -28,6 +28,7 @@
  */
 
 #include 
+#include 
 
 #include "efiboot.h"
 
@@ -334,7 +335,7 @@ efi_net_probe(void)
 	EFI_HANDLE *handles;
 	EFI_STATUS status;
 	UINTN i, nhandles;
-	int nifs;
+	int nifs, depth = -1;
 	bool found;
 
 	status = LibLocateHandle(ByProtocol, , NULL,
@@ -347,6 +348,12 @@ efi_net_probe(void)
 		return;
 	memset(enis, 0, nhandles * sizeof(*enis));
 
+	if (efi_bootdp) {
+		depth = efi_device_path_depth(efi_bootdp, HARDWARE_DEVICE_PATH);
+		if (depth == 0)
+			depth = 1;
+	}
+
 	nifs = 0;
 	for (i = 0; i < nhandles; i++) {
 		status = uefi_call_wrapper(BS->HandleProtocol, 3, handles[i],
@@ -402,6 +409,13 @@ efi_net_probe(void)
 FreePool(handles);
 return;
 			}
+
+			if (depth > 0 && efi_device_path_ncmp(efi_bootdp, dp0, depth) == 0) {
+char devname[9];
+snprintf(devname, sizeof(devname), "net%u", nifs);
+set_default_device(devname);
+			}
+
 			nifs++;
 		}
 	}
@@ -489,9 +503,9 @@ efi_net_get_booted_interface_unit(void)
 int
 efi_net_open(struct open_file *f, ...)
 {
+	char **file, pathbuf[PATH_MAX], *default_device, *path, *ep;
+	const char *fname, *full_path;
 	struct devdesc desc;
-	const char *fname;
-	char **file, *ep;
 	intmax_t dev;
 	va_list ap;
 	int n;
@@ -501,13 +515,25 @@ efi_net_open(struct open_file *f, ...)
 	file = va_arg(ap, char **);
 	va_end(ap);
 
-	if (strncmp(fname, "net", 3) != 0)
+	default_device = get_default_device();
+	if (strchr(fname, ':') == NULL) {
+		if (strlen(default_device) > 0) {
+			snprintf(pathbuf, sizeof(pathbuf), "%s:%s", default_device, fname);
+			full_path = pathbuf;
+			path = __UNCONST(fname);
+		} else {
+			return EINVAL;
+		}
+	} else {
+		full_path = fname;
+		path = strchr(fname, ':') + 1;
+	}
+
+	if (strncmp(full_path, "net", 3) != 0)
 		return EINVAL;
-dev = strtoimax(fname + 3, , 10);
+dev = strtoimax(full_path + 3, , 10);
 if (dev < 0 || dev >= efinetif.netif_nifs)
 return ENXIO;
-	if (*ep != ':')
-		return ENXIO;
 
 for (n = 0; n < ndevs; n++)
 if (strcmp(DEV_NAME([n]), "net") == 0) {
@@ -517,7 +543,7 @@ efi_net_open(struct open_file *f, ...)
 if (n == ndevs)
 return ENXIO;
 
-	*file = ep + 1;
+	*file = path;
 
 	//try_bootp = 1;
 



CVS commit: src/sys/kern

2018-09-04 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Tue Sep  4 16:03:56 UTC 2018

Modified Files:
src/sys/kern: kern_proc.c

Log Message:
Clear the kernel pointers from kern.proc and kern.proc2 when the user is
not privileged.


To generate a diff of this commit:
cvs rdiff -u -r1.216 -r1.217 src/sys/kern/kern_proc.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/kern/kern_proc.c
diff -u src/sys/kern/kern_proc.c:1.216 src/sys/kern/kern_proc.c:1.217
--- src/sys/kern/kern_proc.c:1.216	Tue Sep  4 15:48:44 2018
+++ src/sys/kern/kern_proc.c	Tue Sep  4 16:03:56 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_proc.c,v 1.216 2018/09/04 15:48:44 maxv Exp $	*/
+/*	$NetBSD: kern_proc.c,v 1.217 2018/09/04 16:03:56 maxv Exp $	*/
 
 /*-
  * Copyright (c) 1999, 2006, 2007, 2008 The NetBSD Foundation, Inc.
@@ -62,7 +62,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: kern_proc.c,v 1.216 2018/09/04 15:48:44 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_proc.c,v 1.217 2018/09/04 16:03:56 maxv Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_kstack.h"
@@ -2160,22 +2160,35 @@ done:
 	return error;
 }
 
+#define SET_KERN_ADDR(dst, src, allow)	\
+	do {\
+		if (allow)		\
+			dst = src;	\
+	} while (0);
+
 /*
  * Fill in an eproc structure for the specified process.
  */
 void
 fill_eproc(struct proc *p, struct eproc *ep, bool zombie)
 {
+	bool allowaddr;
 	struct tty *tp;
 	struct lwp *l;
+	int error;
 
 	KASSERT(mutex_owned(proc_lock));
 	KASSERT(mutex_owned(p->p_lock));
 
 	memset(ep, 0, sizeof(*ep));
 
-	ep->e_paddr = p;
-	ep->e_sess = p->p_session;
+	/* If not privileged, don't expose kernel addresses. */
+	error = kauth_authorize_process(kauth_cred_get(), KAUTH_PROCESS_CANSEE,
+	curproc, KAUTH_ARG(KAUTH_REQ_PROCESS_CANSEE_KPTR), NULL, NULL);
+	allowaddr = (error == 0);
+
+	SET_KERN_ADDR(ep->e_paddr, p, allowaddr);
+	SET_KERN_ADDR(ep->e_sess, p->p_session, allowaddr);
 	if (p->p_cred) {
 		kauth_cred_topcred(p->p_cred, >e_pcred);
 		kauth_cred_toucred(p->p_cred, >e_ucred);
@@ -2206,7 +2219,7 @@ fill_eproc(struct proc *p, struct eproc 
 		(tp = p->p_session->s_ttyp)) {
 			ep->e_tdev = tp->t_dev;
 			ep->e_tpgid = tp->t_pgrp ? tp->t_pgrp->pg_id : NO_PGID;
-			ep->e_tsess = tp->t_session;
+			SET_KERN_ADDR(ep->e_tsess, tp->t_session, allowaddr);
 		} else
 			ep->e_tdev = (uint32_t)NODEV;
 		ep->e_flag = p->p_session->s_ttyvp ? EPROC_CTTY : 0;
@@ -2230,24 +2243,31 @@ fill_kproc2(struct proc *p, struct kinfo
 	sigset_t ss1, ss2;
 	struct rusage ru;
 	struct vmspace *vm;
+	bool allowaddr;
+	int error;
 
 	KASSERT(mutex_owned(proc_lock));
 	KASSERT(mutex_owned(p->p_lock));
 
+	/* If not privileged, don't expose kernel addresses. */
+	error = kauth_authorize_process(kauth_cred_get(), KAUTH_PROCESS_CANSEE,
+	curproc, KAUTH_ARG(KAUTH_REQ_PROCESS_CANSEE_KPTR), NULL, NULL);
+	allowaddr = (error == 0);
+
 	sigemptyset();
 	sigemptyset();
 	memset(ki, 0, sizeof(*ki));
 
-	ki->p_paddr = PTRTOUINT64(p);
-	ki->p_fd = PTRTOUINT64(p->p_fd);
-	ki->p_cwdi = PTRTOUINT64(p->p_cwdi);
-	ki->p_stats = PTRTOUINT64(p->p_stats);
-	ki->p_limit = PTRTOUINT64(p->p_limit);
-	ki->p_vmspace = PTRTOUINT64(p->p_vmspace);
-	ki->p_sigacts = PTRTOUINT64(p->p_sigacts);
-	ki->p_sess = PTRTOUINT64(p->p_session);
+	SET_KERN_ADDR(ki->p_paddr, PTRTOUINT64(p), allowaddr);
+	SET_KERN_ADDR(ki->p_fd, PTRTOUINT64(p->p_fd), allowaddr);
+	SET_KERN_ADDR(ki->p_cwdi, PTRTOUINT64(p->p_cwdi), allowaddr);
+	SET_KERN_ADDR(ki->p_stats, PTRTOUINT64(p->p_stats), allowaddr);
+	SET_KERN_ADDR(ki->p_limit, PTRTOUINT64(p->p_limit), allowaddr);
+	SET_KERN_ADDR(ki->p_vmspace, PTRTOUINT64(p->p_vmspace), allowaddr);
+	SET_KERN_ADDR(ki->p_sigacts, PTRTOUINT64(p->p_sigacts), allowaddr);
+	SET_KERN_ADDR(ki->p_sess, PTRTOUINT64(p->p_session), allowaddr);
 	ki->p_tsess = 0;	/* may be changed if controlling tty below */
-	ki->p_ru = PTRTOUINT64(>p_stats->p_ru);
+	SET_KERN_ADDR(ki->p_ru, PTRTOUINT64(>p_stats->p_ru), allowaddr);
 	ki->p_eflag = 0;
 	ki->p_exitsig = p->p_exitsig;
 	ki->p_flag = L_INMEM;   /* Process never swapped out */
@@ -2273,7 +2293,7 @@ fill_kproc2(struct proc *p, struct kinfo
 	ki->p_sticks = p->p_sticks;
 	ki->p_iticks = p->p_iticks;
 	ki->p_tpgid = NO_PGID;	/* may be changed if controlling tty below */
-	ki->p_tracep = PTRTOUINT64(p->p_tracep);
+	SET_KERN_ADDR(ki->p_tracep, PTRTOUINT64(p->p_tracep), allowaddr);
 	ki->p_traceflag = p->p_traceflag;
 
 	memcpy(>p_sigignore, >p_sigctx.ps_sigignore,sizeof(ki_sigset_t));
@@ -2317,7 +2337,7 @@ fill_kproc2(struct proc *p, struct kinfo
 		ki->p_nrlwps = p->p_nrlwps;
 		ki->p_forw = 0;
 		ki->p_back = 0;
-		ki->p_addr = PTRTOUINT64(l->l_addr);
+		SET_KERN_ADDR(ki->p_addr, PTRTOUINT64(l->l_addr), allowaddr);
 		ki->p_stat = l->l_stat;
 		ki->p_flag |= sysctl_map_flags(sysctl_lwpflagmap, l->l_flag);
 		ki->p_swtime = l->l_swtime;
@@ -2330,7 +2350,7 @@ fill_kproc2(struct proc *p, struct kinfo
 		ki->p_usrpri = 

CVS commit: src/sys/arch/aarch64/aarch64

2018-09-04 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Tue Sep  4 15:50:25 UTC 2018

Modified Files:
src/sys/arch/aarch64/aarch64: locore.S

Log Message:
Adjust register usage a bit and unbreak DEBUG_MMU as a result.

The change moves to using callee-saved registers more so that any call
into C will have them preserved (if they're used or not).  It's safe
to use stack as it's setup very early for BP/APs.

Discussed with ryo@


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/sys/arch/aarch64/aarch64/locore.S

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/aarch64/aarch64/locore.S
diff -u src/sys/arch/aarch64/aarch64/locore.S:1.21 src/sys/arch/aarch64/aarch64/locore.S:1.22
--- src/sys/arch/aarch64/aarch64/locore.S:1.21	Thu Aug 30 10:38:01 2018
+++ src/sys/arch/aarch64/aarch64/locore.S	Tue Sep  4 15:50:25 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: locore.S,v 1.21 2018/08/30 10:38:01 maxv Exp $	*/
+/*	$NetBSD: locore.S,v 1.22 2018/09/04 15:50:25 skrll Exp $	*/
 
 /*
  * Copyright (c) 2017 Ryo Shimizu 
@@ -35,7 +35,7 @@
 #include 
 #include "assym.h"
 
-RCSID("$NetBSD: locore.S,v 1.21 2018/08/30 10:38:01 maxv Exp $")
+RCSID("$NetBSD: locore.S,v 1.22 2018/09/04 15:50:25 skrll Exp $")
 
 /* #define DEBUG_LOCORE */
 /* #define DEBUG_MMU */
@@ -496,22 +496,25 @@ END(aarch64_mpstart)
  *.ascii"Hello\r\n\0" <- wouldn't return here
  *.align2
  *nop <- return to here
+ *
+ * x0 is preserved despite being caller saved.
  */
 ENTRY_NP(xprint)
-	mov	x11, lr
-	mov	x12, x0
-	ldrb	w0, [x11], #1
+	stp	x0, x19, [sp, #-16]!
+
+	mov	x19, lr
+	ldrb	w0, [x19], #1
 	cbz	w0, 2f
 
 1:
 	bl	uartputc
-	ldrb	w0, [x11], #1
+	ldrb	w0, [x19], #1
 	cbnz	w0, 1b
 
 2:
-	add	x11, x11, #3
-	bic	lr, x11, #3
-	mov	x0, x12
+	add	x19, x19, #3
+	bic	lr, x19, #3
+	ldp	x0, x19, [sp], #16
 	ret
 END(xprint)
 
@@ -527,47 +530,52 @@ ENTRY_NP(uartputs)
 	ret
 END(uartputs)
 
+/* x0 is preserved despite being caller saved. */
 ENTRY_NP(_print_x0)
 	stp	x0, lr, [sp, #-16]!
-	stp	x4, x5, [sp, #-16]!
-	stp	x6, x7, [sp, #-16]!
+	stp	x20, x21, [sp, #-16]!
 
-	mov	x7, x0		/* number to display */
-	mov	x4, #60		/* num of shift */
-	mov	x5, #0xf	/* mask */
+	mov	x21, x0		/* number to display */
+	mov	x20, #60	/* num of shift */
 1:
-	ror	x0, x7, x4
-	and	x0, x0, x5
+	ror	x0, x21, x20
+	and	x0, x0, #0xf
 	cmp	x0, #10
 	blt	2f
 	add	x0, x0, #('a' - 10 - '0')
 2:	add	x0, x0, #'0'
 	bl	uartputc
-	subs	x4, x4, #4
+	subs	x20, x20, #4
 	bge	1b
 
-	ldp	x6, x7, [sp], #16
-	ldp	x4, x5, [sp], #16
+	ldp	x20, x21, [sp], #16
 	ldp	x0, lr, [sp], #16
 	ret
 END(_print_x0)
 
+/* Preserve x{0,1,2} descpite them being caller saved */
 ENTRY_NP(print_x0)
 	stp	x0, lr, [sp, #-16]!
+	stp	x1, x2, [sp, #-16]!
 	bl	_print_x0
 	PRINT("\r\n")
+	ldp	x1, x2, [sp], #16
 	ldp	x0, lr, [sp], #16
 	ret
 END(print_x0)
 
+/* Preserve x{0,1,2} descpite them being caller saved */
 ENTRY_NP(printn_x1)
 	stp	x0, lr, [sp, #-16]!
+	stp	x1, x2, [sp, #-16]!
 	mov	x0, x1
 	bl	_print_x0
+	ldp	x1, x2, [sp], #16
 	ldp	x0, lr, [sp], #16
 	ret
 END(printn_x1)
 
+/* Preserve x{0,1,2} descpite them being caller saved */
 ENTRY_NP(print_x2)
 	stp	x0, lr, [sp, #-16]!
 	mov	x0, x2
@@ -772,32 +780,42 @@ END(l0_settable)
  */
 ENTRY_NP(l1_setblocks)
 	stp	x0, lr, [sp, #-16]!
+	stp	x19, x20, [sp, #-16]!
+	stp	x21, x22, [sp, #-16]!
 
-	and	x2, x2, #L1_ADDR_BITS
-	mov	x8, #L1_BLOCK
-	orr	x2, x2, x8
-	orr	x2, x2, x3
-	mov	x8, #(LX_BLKPAG_AF|LX_BLKPAG_AP_RW)
-	orr	x2, x2, x8
+	mov	x19, x0			/* l1table */
+	mov	x22, x4			/* N entries */
+
+	and	x21, x2, #L1_ADDR_BITS	/* PA[38:30] */
+	mov	x9, #L1_BLOCK
+	orr	x21, x21, x9
+	orr	x21, x21, x3		/* add in attr */
+	mov	x9, #(LX_BLKPAG_AF|LX_BLKPAG_AP_RW)
+	orr	x21, x21, x9
 #ifdef MULTIPROCESSOR
-	orr	x2, x2, #LX_BLKPAG_SH_IS
+	orr	x21, x21, #LX_BLKPAG_SH_IS
 #endif
-	and	x1, x1, #L1_ADDR_BITS
-	lsr	x1, x1, #L1_SHIFT
+	and	x20, x1, #L1_ADDR_BITS	/* VA[38:30] */
+	lsr	x20, x20, #L1_SHIFT
 1:
-	str	x2, [x0, x1, lsl #3]	/* l1table[x1] = x2 */
+	str	x21, [x19, x20, lsl #3]	/* l1table[x20] = x21 */
+
 #ifdef DEBUG_MMU
 	PRINT("L1 entry[")
-	bl printn_x1
+	mov	x1, x19
+	bl	printn_x1
 	PRINT("]=")
-	bl print_x2
+	mov	x2, x21
+	bl	print_x2
 #endif
-	mov	x3, #L1_SIZE
-	add	x2, x2, x3
-	add	x1, x1, #1
-	subs	x4, x4, #1
+	mov	x9, #L1_SIZE
+	add	x21, x21, x9
+	add	x20, x20, #1
+	subs	x22, x22, #1
 	bne	1b
 
+	ldp	x21, x22, [sp], #16
+	ldp	x19, x20, [sp], #16
 	ldp	x0, lr, [sp], #16
 	ret
 END(l1_setblocks)
@@ -837,32 +855,42 @@ END(l1_settable)
  */
 ENTRY_NP(l2_setblocks)
 	stp	x0, lr, [sp, #-16]!
+	stp	x19, x20, [sp, #-16]!
+	stp	x21, x22, [sp, #-16]!
 
-	and	x2, x2, #L2_BLOCK_MASK
-	mov	x8, #L2_BLOCK
-	orr	x2, x2, x8
-	orr	x2, x2, x3
-	mov	x8, #(LX_BLKPAG_AF|LX_BLKPAG_AP_RW)
-	orr	x2, x2, x8
+	mov	x19, x0			/* l1table */
+	mov	x22, x4			/* N entries */
+
+	and	x21, x2, #L2_BLOCK_MASK
+	mov	x9, #L2_BLOCK
+	orr	x21, x21, x9
+	orr	

CVS commit: src/sys/kern

2018-09-04 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Tue Sep  4 15:48:44 UTC 2018

Modified Files:
src/sys/kern: kern_proc.c

Log Message:
Use p->p_session instead of ep->e_sess, no real functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.215 -r1.216 src/sys/kern/kern_proc.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/kern/kern_proc.c
diff -u src/sys/kern/kern_proc.c:1.215 src/sys/kern/kern_proc.c:1.216
--- src/sys/kern/kern_proc.c:1.215	Tue Sep  4 14:31:18 2018
+++ src/sys/kern/kern_proc.c	Tue Sep  4 15:48:44 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_proc.c,v 1.215 2018/09/04 14:31:18 maxv Exp $	*/
+/*	$NetBSD: kern_proc.c,v 1.216 2018/09/04 15:48:44 maxv Exp $	*/
 
 /*-
  * Copyright (c) 1999, 2006, 2007, 2008 The NetBSD Foundation, Inc.
@@ -62,7 +62,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: kern_proc.c,v 1.215 2018/09/04 14:31:18 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_proc.c,v 1.216 2018/09/04 15:48:44 maxv Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_kstack.h"
@@ -2203,16 +2203,16 @@ fill_eproc(struct proc *p, struct eproc 
 		ep->e_jobc = p->p_pgrp->pg_jobc;
 		ep->e_sid = p->p_session->s_sid;
 		if ((p->p_lflag & PL_CONTROLT) &&
-		(tp = ep->e_sess->s_ttyp)) {
+		(tp = p->p_session->s_ttyp)) {
 			ep->e_tdev = tp->t_dev;
 			ep->e_tpgid = tp->t_pgrp ? tp->t_pgrp->pg_id : NO_PGID;
 			ep->e_tsess = tp->t_session;
 		} else
 			ep->e_tdev = (uint32_t)NODEV;
-		ep->e_flag = ep->e_sess->s_ttyvp ? EPROC_CTTY : 0;
+		ep->e_flag = p->p_session->s_ttyvp ? EPROC_CTTY : 0;
 		if (SESS_LEADER(p))
 			ep->e_flag |= EPROC_SLEADER;
-		strncpy(ep->e_login, ep->e_sess->s_login, MAXLOGNAME);
+		strncpy(ep->e_login, p->p_session->s_login, MAXLOGNAME);
 	}
 	ep->e_xsize = ep->e_xrssize = 0;
 	ep->e_xccount = ep->e_xswrss = 0;



CVS commit: src/doc

2018-09-04 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Tue Sep  4 15:41:09 UTC 2018

Modified Files:
src/doc: TODO.kaslr

Log Message:
more kernel address leaks


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/doc/TODO.kaslr

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

Modified files:

Index: src/doc/TODO.kaslr
diff -u src/doc/TODO.kaslr:1.4 src/doc/TODO.kaslr:1.5
--- src/doc/TODO.kaslr:1.4	Fri Aug 24 17:09:30 2018
+++ src/doc/TODO.kaslr	Tue Sep  4 15:41:08 2018
@@ -17,9 +17,14 @@
 
 [DONE] -- PPPoE sends a kernel address as host unique. (What is this shit.)
 
--- "netstat -nat" leaks kernel addresses.
-
--- Investigate some other tools.
+-- Several entry points leak kernel addresses:
+   [DONE] - "modstat -k"
+   - "netstat -nat"
+   - kern.proc
+   - kern.proc2
+   - kern.file
+   - kern.file2
+   - kern.lwp
 
 -- Be careful with dmesg.
 



CVS commit: src/usr.sbin/npf/npfctl

2018-09-04 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Tue Sep  4 15:36:02 UTC 2018

Modified Files:
src/usr.sbin/npf/npfctl: npf.conf.5

Log Message:
Fix the "Interfaces" section, I understood wrong. Talk about inference,
because it was not mentioned before, and it plays an important role.
Discussed with rmind. Probably not the last pass.


To generate a diff of this commit:
cvs rdiff -u -r1.74 -r1.75 src/usr.sbin/npf/npfctl/npf.conf.5

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

Modified files:

Index: src/usr.sbin/npf/npfctl/npf.conf.5
diff -u src/usr.sbin/npf/npfctl/npf.conf.5:1.74 src/usr.sbin/npf/npfctl/npf.conf.5:1.75
--- src/usr.sbin/npf/npfctl/npf.conf.5:1.74	Sun Sep  2 18:03:23 2018
+++ src/usr.sbin/npf/npfctl/npf.conf.5	Tue Sep  4 15:36:01 2018
@@ -1,4 +1,4 @@
-.\"$NetBSD: npf.conf.5,v 1.74 2018/09/02 18:03:23 wiz Exp $
+.\"$NetBSD: npf.conf.5,v 1.75 2018/09/04 15:36:01 maxv Exp $
 .\"
 .\" Copyright (c) 2009-2017 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -27,7 +27,7 @@
 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 .\" POSSIBILITY OF SUCH DAMAGE.
 .\"
-.Dd September 2, 2018
+.Dd September 4, 2018
 .Dt NPF.CONF 5
 .Os
 .Sh NAME
@@ -99,16 +99,20 @@ form of:
 10.1.1.1
 .Ed
 .Ss Interfaces
-In the context of NPF, an interface is seen as a list of IP addresses,
-that can be IPv4 or IPv6, which are configured on the actual associated
-interface.
-.Pp
-Such list can be either static or dynamic.
-With a static list, NPF will
-capture the interface addresses on configuration load, whereas with a dynamic
-list NPF will capture the runtime list of addresses, reflecting any changes
-to the interface, including the attach and detach.
-.Pp
+In NPF, an interface can be referenced directly by using its name, or can be
+passed to an extraction function which will return a list of IP addresses
+configured on the actual associated interface.
+.Pp
+It is legal to pass an extracted list from an interface in keywords where
+NPF would expect instead a direct reference to said interface.
+In this case, NPF infers a direct reference to the interface, and does not
+consider the list.
+.Pp
+There are two types of IP address lists.
+With a static list, NPF will capture the interface addresses on configuration
+load, whereas with a dynamic list NPF will capture the runtime list of
+addresses, reflecting any changes to the interface, including the attach and
+detach.
 Note that with a dynamic list, marking the interface as ``down'' has no effect,
 all addresses will remain present.
 .Pp
@@ -127,27 +131,27 @@ keyword can be used in combination of a 
 an IP address type.
 .El
 .Pp
-By default, when no extraction function is used,
-.Fn ifaddrs
-is assumed.
-.Pp
-Example of configuration with static interface lists:
-.Bd -literal
-$pub_if4 = inet4(wm0)
-$pub_if46 = { inet4(wm0), inet6(wm0) }
-.Ed
-.Pp
-In the above example, $pub_if4 is the list of IPv4 addresses configured
-on wm0, and $pub_if46 is the list of IPv4 and IPv6 addresses configured
-on wm0.
-.Pp
-Example of configuration with dynamic interface lists:
+Example of configuration:
 .Bd -literal
-$pub_if_1 = ifaddrs(wm0)
-$pub_if_2 = wm0
+$var1 = inet4(wm0)
+$var2 = ifaddrs(wm0)
+group default {
+	block in on wm0 all   # rule 1
+	block in on $var1 all # rule 2
+	block in on inet4(wm0) all# rule 3
+	pass in on inet6(wm0) from $var2  # rule 4
+	pass in on wm0 from ifaddrs(wm0)  # rule 5
+}
 .Ed
 .Pp
-In the above example, $pub_if_1 and $pub_if_2 are equal.
+In the above example, $var1 is the static list of IPv4 addresses configured
+on wm0, and $var2 is the dynamic list of all the IPv4 and IPv6 addresses
+configured on wm0.
+The first three rules are equivalent, because with the
+.Cd block ... on 
+syntax, NPF expects a direct reference to an interface, and therefore does
+not consider the extraction functions.
+The fourth and fifth rules are equivalent, for the same reason.
 .Ss Groups
 NPF requires that all rules be defined within groups.
 Groups can be thought of as higher level rules which can contain subrules.



CVS commit: src/usr.bin/find

2018-09-04 Thread Robert Elz
Module Name:src
Committed By:   kre
Date:   Tue Sep  4 15:16:15 UTC 2018

Modified Files:
src/usr.bin/find: function.c

Log Message:
Inspired by PR pkg/53543

When calculating the length of the args that can be
appended in a "find  -exec something {} +"
usage, remember to allow for the arg pointers, which
form part of what is allowed in ARG_MAX.

>From a fairly empty installation of HEAD on amd64
and with a "/tmp/args" command that simply prints
its arg count, and the length of the arg strings,
with this mod I see ..

netbsd# find / -exec /tmp/args {} +
Argc 5000 Arglen 107645
Argc 5000 Arglen 151324
Argc 5000 Arglen 187725
Argc 5000 Arglen 206591
Argc 5000 Arglen 172909
Argc 5000 Arglen 186264
Argc 5000 Arglen 167906
Argc 2881 Arglen 98260

The upper limit of 5000 args is in the code.

Using the biggest of those, 5000
args, plus 206591 bytes of strings
uses 246591 bytes total (this excludes
the command name, so add a few more).
That's fairly close to the ARG_MAX
of 262144.

On another system (with longer paths) I see:
(this is just a small part of the output, using a
different version of the dummy command, and a
slightly different invocation)

Args: 4546 Len 218030
Args: 4878 Len 217991
Args: 4813 Len 218028
Args: 4803 Len 218029

There, 4878*8 + 217991 == 257015 which is about
as close as we'd want to come to the arg limit.

XXX pullup -8


To generate a diff of this commit:
cvs rdiff -u -r1.76 -r1.77 src/usr.bin/find/function.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/find/function.c
diff -u src/usr.bin/find/function.c:1.76 src/usr.bin/find/function.c:1.77
--- src/usr.bin/find/function.c:1.76	Tue Jun 13 13:10:32 2017
+++ src/usr.bin/find/function.c	Tue Sep  4 15:16:15 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: function.c,v 1.76 2017/06/13 13:10:32 christos Exp $	*/
+/*	$NetBSD: function.c,v 1.77 2018/09/04 15:16:15 kre Exp $	*/
 
 /*-
  * Copyright (c) 1990, 1993
@@ -37,7 +37,7 @@
 #if 0
 static char sccsid[] = "from: @(#)function.c	8.10 (Berkeley) 5/4/95";
 #else
-__RCSID("$NetBSD: function.c,v 1.76 2017/06/13 13:10:32 christos Exp $");
+__RCSID("$NetBSD: function.c,v 1.77 2018/09/04 15:16:15 kre Exp $");
 #endif
 #endif /* not lint */
 
@@ -759,7 +759,9 @@ c_exec(char ***argvp, int isok, char *op
 		size_t c, bufsize;
 
 		cnt = ap - *argvp - 1;			/* units are words */
-		new->ep_maxargs = 5000;
+		new->ep_maxargs = ARG_MAX / (sizeof (char *) + 16);
+		if (new->ep_maxargs > 5000)
+			new->ep_maxargs = 5000;
 		new->e_argv = emalloc((cnt + new->ep_maxargs)
 		* sizeof(*new->e_argv));
 
@@ -780,7 +782,9 @@ c_exec(char ***argvp, int isok, char *op
 errx(1, "Arguments too long");
 			new->e_argv[cnt] = *argv;
 		}
-		bufsize = MAXARG - c;
+		if (c + new->ep_maxargs * sizeof (char *) >= MAXARG)
+			errx(1, "Arguments too long");
+		bufsize = MAXARG - c - new->ep_maxargs * sizeof (char *);
 
 		/*
 		 * Allocate, and then initialize current, base, and



CVS commit: src/sys

2018-09-04 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Tue Sep  4 15:08:30 UTC 2018

Modified Files:
src/sys/arch/cobalt/stand/boot: lcd.c
src/sys/arch/ews4800mips/stand/common: lance.c
src/sys/arch/hp300/stand/inst: inst.c
src/sys/arch/hppa/stand/common: lif.c
src/sys/arch/ia64/stand/common: interp_parse.c
src/sys/arch/luna68k/stand/boot: lance.c
src/sys/arch/next68k/next68k: disksubr.c
src/sys/stand/efiboot: efinet.c

Log Message:
Fix some min/max -> uimin/uimax stragglers.

Confirmed by the 2018-09-04T04:40Z autobuild.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/cobalt/stand/boot/lcd.c
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/ews4800mips/stand/common/lance.c
cvs rdiff -u -r1.22 -r1.23 src/sys/arch/hp300/stand/inst/inst.c
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/hppa/stand/common/lif.c
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/ia64/stand/common/interp_parse.c
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/luna68k/stand/boot/lance.c
cvs rdiff -u -r1.28 -r1.29 src/sys/arch/next68k/next68k/disksubr.c
cvs rdiff -u -r1.1 -r1.2 src/sys/stand/efiboot/efinet.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/arch/cobalt/stand/boot/lcd.c
diff -u src/sys/arch/cobalt/stand/boot/lcd.c:1.2 src/sys/arch/cobalt/stand/boot/lcd.c:1.3
--- src/sys/arch/cobalt/stand/boot/lcd.c:1.2	Thu May 29 14:25:01 2008
+++ src/sys/arch/cobalt/stand/boot/lcd.c	Tue Sep  4 15:08:30 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: lcd.c,v 1.2 2008/05/29 14:25:01 tsutsui Exp $	*/
+/*	$NetBSD: lcd.c,v 1.3 2018/09/04 15:08:30 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2008 Izumi Tsutsui.  All rights reserved.
@@ -88,7 +88,7 @@ void
 lcd_loadfile(const char *file)
 {
 
-	memcpy(loadfile_message.row2, file, min(NCOLS, strlen(file)));
+	memcpy(loadfile_message.row2, file, uimin(NCOLS, strlen(file)));
 
 	lcd_puts(_message);
 }

Index: src/sys/arch/ews4800mips/stand/common/lance.c
diff -u src/sys/arch/ews4800mips/stand/common/lance.c:1.6 src/sys/arch/ews4800mips/stand/common/lance.c:1.7
--- src/sys/arch/ews4800mips/stand/common/lance.c:1.6	Sun Jan 13 14:24:24 2013
+++ src/sys/arch/ews4800mips/stand/common/lance.c	Tue Sep  4 15:08:30 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: lance.c,v 1.6 2013/01/13 14:24:24 tsutsui Exp $	*/
+/*	$NetBSD: lance.c,v 1.7 2018/09/04 15:08:30 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2004 The NetBSD Foundation, Inc.
@@ -161,14 +161,14 @@ lance_put(void *data, size_t len)
 	tmd->tmd1_bits = LE_T1_STP;
 	for (i = 0; i < 8; i++) {
 		current = (current + 1) & 0x7;
-		n = min(len, 512);
+		n = uimin(len, 512);
 		p = (uint8_t *)((tmd->tmd1_hadr << 16) | tmd->tmd0 |
 		0xa000);
 		for (j = 0; j < n; j++)
 			*p++ = *q++;
 		len -= n;
 #if 1
-		tmd->tmd2 = -max(n, 64) | 0xf000;
+		tmd->tmd2 = -uimax(n, 64) | 0xf000;
 #else
 		tmd->tmd2 = -n | 0xf000;
 #endif

Index: src/sys/arch/hp300/stand/inst/inst.c
diff -u src/sys/arch/hp300/stand/inst/inst.c:1.22 src/sys/arch/hp300/stand/inst/inst.c:1.23
--- src/sys/arch/hp300/stand/inst/inst.c:1.22	Sat Jun 11 06:20:11 2016
+++ src/sys/arch/hp300/stand/inst/inst.c	Tue Sep  4 15:08:30 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: inst.c,v 1.22 2016/06/11 06:20:11 dholland Exp $	*/
+/*	$NetBSD: inst.c,v 1.23 2018/09/04 15:08:30 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 1996, 1997 The NetBSD Foundation, Inc.
@@ -356,7 +356,7 @@ get_fstype(struct disklabel *lp, int par
 	}
 
 	fragsize = blocksize / 8;	/* XXX */
-	fragsize = max(fragsize, lp->d_secsize);
+	fragsize = uimax(fragsize, lp->d_secsize);
 	GETNUM(" FFS fragment size? [%d] ", fragsize);
 	if (fragsize < lp->d_secsize || (fragsize % lp->d_secsize) != 0) {
 		printf("FFS fragment size must be a multiple of sector size"

Index: src/sys/arch/hppa/stand/common/lif.c
diff -u src/sys/arch/hppa/stand/common/lif.c:1.1 src/sys/arch/hppa/stand/common/lif.c:1.2
--- src/sys/arch/hppa/stand/common/lif.c:1.1	Mon Feb 24 07:23:43 2014
+++ src/sys/arch/hppa/stand/common/lif.c	Tue Sep  4 15:08:30 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: lif.c,v 1.1 2014/02/24 07:23:43 skrll Exp $	*/
+/*	$NetBSD: lif.c,v 1.2 2018/09/04 15:08:30 riastradh Exp $	*/
 
 /*	$OpenBSD: lif.c,v 1.7 2001/06/09 03:54:41 mickey Exp $	*/
 
@@ -179,7 +179,7 @@ lif_read(struct open_file *f, void *buf,
 			break;
 		if (p == bbuf) {
 			bsize = sizeof(bbuf) - (foff & (sizeof(bbuf) - 1));
-			bsize = min(bsize, size);
+			bsize = uimin(bsize, size);
 			memcpy(buf, bbuf + (foff & (sizeof(bbuf) - 1)), bsize);
 			p = buf;
 		}

Index: src/sys/arch/ia64/stand/common/interp_parse.c
diff -u src/sys/arch/ia64/stand/common/interp_parse.c:1.5 src/sys/arch/ia64/stand/common/interp_parse.c:1.6
--- src/sys/arch/ia64/stand/common/interp_parse.c:1.5	Mon Oct 26 19:16:56 2009
+++ src/sys/arch/ia64/stand/common/interp_parse.c	Tue Sep  4 15:08:30 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: interp_parse.c,v 1.5 2009/10/26 19:16:56 cegger Exp $	*/
+/*	

CVS commit: src/sys

2018-09-04 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Tue Sep  4 14:31:19 UTC 2018

Modified Files:
src/sys/kern: kern_proc.c sys_module.c
src/sys/secmodel/extensions: secmodel_extensions.c
src/sys/secmodel/suser: secmodel_suser.c
src/sys/sys: kauth.h

Log Message:
Introduce KAUTH_REQ_PROCESS_CANSEE_KPTR, and use it in the already-existing
modstat code. No real functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.214 -r1.215 src/sys/kern/kern_proc.c
cvs rdiff -u -r1.24 -r1.25 src/sys/kern/sys_module.c
cvs rdiff -u -r1.9 -r1.10 src/sys/secmodel/extensions/secmodel_extensions.c
cvs rdiff -u -r1.47 -r1.48 src/sys/secmodel/suser/secmodel_suser.c
cvs rdiff -u -r1.79 -r1.80 src/sys/sys/kauth.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/kern/kern_proc.c
diff -u src/sys/kern/kern_proc.c:1.214 src/sys/kern/kern_proc.c:1.215
--- src/sys/kern/kern_proc.c:1.214	Mon Sep  3 16:29:35 2018
+++ src/sys/kern/kern_proc.c	Tue Sep  4 14:31:18 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_proc.c,v 1.214 2018/09/03 16:29:35 riastradh Exp $	*/
+/*	$NetBSD: kern_proc.c,v 1.215 2018/09/04 14:31:18 maxv Exp $	*/
 
 /*-
  * Copyright (c) 1999, 2006, 2007, 2008 The NetBSD Foundation, Inc.
@@ -62,7 +62,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: kern_proc.c,v 1.214 2018/09/03 16:29:35 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_proc.c,v 1.215 2018/09/04 14:31:18 maxv Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_kstack.h"
@@ -278,6 +278,7 @@ proc_listener_cb(kauth_cred_t cred, kaut
 
 			break;
 
+		case KAUTH_REQ_PROCESS_CANSEE_KPTR:
 		default:
 			break;
 		}

Index: src/sys/kern/sys_module.c
diff -u src/sys/kern/sys_module.c:1.24 src/sys/kern/sys_module.c:1.25
--- src/sys/kern/sys_module.c:1.24	Mon Sep  3 16:29:35 2018
+++ src/sys/kern/sys_module.c	Tue Sep  4 14:31:18 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: sys_module.c,v 1.24 2018/09/03 16:29:35 riastradh Exp $	*/
+/*	$NetBSD: sys_module.c,v 1.25 2018/09/04 14:31:18 maxv Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: sys_module.c,v 1.24 2018/09/03 16:29:35 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sys_module.c,v 1.25 2018/09/04 14:31:18 maxv Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_modular.h"
@@ -123,8 +123,8 @@ handle_modctl_stat(struct iovec *iov, vo
 	bool stataddr;
 
 	/* If not privileged, don't expose kernel addresses. */
-	error = kauth_authorize_system(kauth_cred_get(), KAUTH_SYSTEM_MODULE,
-	0, (void *)(uintptr_t)MODCTL_STAT, NULL, NULL);
+	error = kauth_authorize_process(kauth_cred_get(), KAUTH_PROCESS_CANSEE,
+	curproc, KAUTH_ARG(KAUTH_REQ_PROCESS_CANSEE_KPTR), NULL, NULL);
 	stataddr = (error == 0);
 
 	kernconfig_lock();

Index: src/sys/secmodel/extensions/secmodel_extensions.c
diff -u src/sys/secmodel/extensions/secmodel_extensions.c:1.9 src/sys/secmodel/extensions/secmodel_extensions.c:1.10
--- src/sys/secmodel/extensions/secmodel_extensions.c:1.9	Sat Aug 25 09:54:37 2018
+++ src/sys/secmodel/extensions/secmodel_extensions.c	Tue Sep  4 14:31:19 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: secmodel_extensions.c,v 1.9 2018/08/25 09:54:37 maxv Exp $ */
+/* $NetBSD: secmodel_extensions.c,v 1.10 2018/09/04 14:31:19 maxv Exp $ */
 /*-
  * Copyright (c) 2011 Elad Efrat 
  * All rights reserved.
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: secmodel_extensions.c,v 1.9 2018/08/25 09:54:37 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: secmodel_extensions.c,v 1.10 2018/09/04 14:31:19 maxv Exp $");
 
 #include 
 #include 
@@ -450,6 +450,7 @@ secmodel_extensions_process_cb(kauth_cre
 
 			break;
 
+		case KAUTH_REQ_PROCESS_CANSEE_KPTR:
 		default:
 			break;
 		}

Index: src/sys/secmodel/suser/secmodel_suser.c
diff -u src/sys/secmodel/suser/secmodel_suser.c:1.47 src/sys/secmodel/suser/secmodel_suser.c:1.48
--- src/sys/secmodel/suser/secmodel_suser.c:1.47	Sat Aug 25 09:54:37 2018
+++ src/sys/secmodel/suser/secmodel_suser.c	Tue Sep  4 14:31:19 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: secmodel_suser.c,v 1.47 2018/08/25 09:54:37 maxv Exp $ */
+/* $NetBSD: secmodel_suser.c,v 1.48 2018/09/04 14:31:19 maxv Exp $ */
 /*-
  * Copyright (c) 2006 Elad Efrat 
  * All rights reserved.
@@ -38,7 +38,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: secmodel_suser.c,v 1.47 2018/08/25 09:54:37 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: secmodel_suser.c,v 1.48 2018/09/04 14:31:19 maxv Exp $");
 
 #include 
 #include 
@@ -500,6 +500,7 @@ secmodel_suser_process_cb(kauth_cred_t c
 		case KAUTH_REQ_PROCESS_CANSEE_ENTRY:
 		case KAUTH_REQ_PROCESS_CANSEE_OPENFILES:
 		case KAUTH_REQ_PROCESS_CANSEE_EPROC:
+		case KAUTH_REQ_PROCESS_CANSEE_KPTR:
 			if (isroot) {
 result = KAUTH_RESULT_ALLOW;
 break;

Index: src/sys/sys/kauth.h
diff -u src/sys/sys/kauth.h:1.79 src/sys/sys/kauth.h:1.80
--- src/sys/sys/kauth.h:1.79	Sat Aug 25 09:54:37 

CVS commit: [pgoyette-compat] src/sys/kern

2018-09-04 Thread Paul Goyette
Module Name:src
Committed By:   pgoyette
Date:   Tue Sep  4 11:53:46 UTC 2018

Modified Files:
src/sys/kern [pgoyette-compat]: kern_module.c

Log Message:
Use correct structure member for module's name.


To generate a diff of this commit:
cvs rdiff -u -r1.130.2.15 -r1.130.2.16 src/sys/kern/kern_module.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/kern/kern_module.c
diff -u src/sys/kern/kern_module.c:1.130.2.15 src/sys/kern/kern_module.c:1.130.2.16
--- src/sys/kern/kern_module.c:1.130.2.15	Tue Sep  4 11:48:38 2018
+++ src/sys/kern/kern_module.c	Tue Sep  4 11:53:46 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_module.c,v 1.130.2.15 2018/09/04 11:48:38 pgoyette Exp $	*/
+/*	$NetBSD: kern_module.c,v 1.130.2.16 2018/09/04 11:53:46 pgoyette Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: kern_module.c,v 1.130.2.15 2018/09/04 11:48:38 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_module.c,v 1.130.2.16 2018/09/04 11:53:46 pgoyette Exp $");
 
 #define _MODULE_INTERNAL
 
@@ -949,7 +949,7 @@ module_do_builtin(const module_t *pmod, 
 error = EEXIST;
 module_error("built-in module %s alias %s "
 "already exists in module %s", name,
-*--aliasp, mod2->mod_info->mod_name);
+*--aliasp, mod2->mod_info->mi_name);
 goto fail;
 			}
 		}



CVS commit: [pgoyette-compat] src/sys/kern

2018-09-04 Thread Paul Goyette
Module Name:src
Committed By:   pgoyette
Date:   Tue Sep  4 11:48:38 UTC 2018

Modified Files:
src/sys/kern [pgoyette-compat]: kern_module.c

Log Message:
Add some helpful error messages when things fail.


To generate a diff of this commit:
cvs rdiff -u -r1.130.2.14 -r1.130.2.15 src/sys/kern/kern_module.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/kern/kern_module.c
diff -u src/sys/kern/kern_module.c:1.130.2.14 src/sys/kern/kern_module.c:1.130.2.15
--- src/sys/kern/kern_module.c:1.130.2.14	Tue Sep  4 11:31:11 2018
+++ src/sys/kern/kern_module.c	Tue Sep  4 11:48:38 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_module.c,v 1.130.2.14 2018/09/04 11:31:11 pgoyette Exp $	*/
+/*	$NetBSD: kern_module.c,v 1.130.2.15 2018/09/04 11:48:38 pgoyette Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: kern_module.c,v 1.130.2.14 2018/09/04 11:31:11 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_module.c,v 1.130.2.15 2018/09/04 11:48:38 pgoyette Exp $");
 
 #define _MODULE_INTERNAL
 
@@ -904,8 +904,8 @@ module_do_builtin(const module_t *pmod, 
 		 * cases (such as nfsserver + nfs), the dependee can be
 		 * succesfully linked without the dependencies.
 		 */
-		module_error("%s: can't find builtin dependency `%s'",
-		pmod->mod_info->mi_name, name);
+		module_error("built-in module %s can't find builtin "
+		"dependency `%s'", pmod->mod_info->mi_name, name);
 		return ENOENT;
 	}
 
@@ -929,6 +929,8 @@ module_do_builtin(const module_t *pmod, 
 			alloc_required(mod);
 			error = module_do_builtin(mod, buf, , NULL);
 			if (error != 0) {
+module_error("built-in module %s prerequisite "
+"%s failed, error %d", name, buf, error);
 goto fail;
 			}
 			(*mod->mod_required)[mod->mod_nrequired++] = mod2;
@@ -945,6 +947,9 @@ module_do_builtin(const module_t *pmod, 
 if (modp != NULL)
 	*modp = mod2;
 error = EEXIST;
+module_error("built-in module %s alias %s "
+"already exists in module %s", name,
+*--aliasp, mod2->mod_info->mod_name);
 goto fail;
 			}
 		}
@@ -957,8 +962,8 @@ module_do_builtin(const module_t *pmod, 
 	error = (*mi->mi_modcmd)(MODULE_CMD_INIT, props);
 	module_active = prev_active;
 	if (error != 0) {
-		module_error("builtin module `%s' "
-		"failed to init, error %d", mi->mi_name, error);
+		module_error("built-in module %s failed its MODULE_CMD_INIT, "
+		"error %d", mi->mi_name, error);
 		goto fail;
 	}
 



CVS commit: [pgoyette-compat] src/doc

2018-09-04 Thread Paul Goyette
Module Name:src
Committed By:   pgoyette
Date:   Tue Sep  4 11:36:06 UTC 2018

Modified Files:
src/doc [pgoyette-compat]: COMPAT-branch-notes

Log Message:
Put the COMPAT_BSDPTY entry in the proper group (ie, the "done" group).


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.20 -r1.1.2.21 src/doc/COMPAT-branch-notes

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

Modified files:

Index: src/doc/COMPAT-branch-notes
diff -u src/doc/COMPAT-branch-notes:1.1.2.20 src/doc/COMPAT-branch-notes:1.1.2.21
--- src/doc/COMPAT-branch-notes:1.1.2.20	Tue Sep  4 02:24:03 2018
+++ src/doc/COMPAT-branch-notes	Tue Sep  4 11:36:06 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: COMPAT-branch-notes,v 1.1.2.20 2018/09/04 02:24:03 pgoyette Exp $ */
+/* $NetBSD: COMPAT-branch-notes,v 1.1.2.21 2018/09/04 11:36:06 pgoyette Exp $ */
 
 DONE
 
@@ -48,6 +48,9 @@ DONE
 10. syscalls.master has been updated to autoload the version-specific
 compat modules rather than the monolithic modules.
 
+11. Separated COMPAT_BSDPTY stuff, allowing the COMPAT_60 module to be
+built regardless.
+
 
 TODO - Required for branch merge
 
@@ -89,6 +92,3 @@ TODO - Not required for branch merge
 source file.  Additionally, the zaurus platform defines COMPAT_44 in
 its INSTALL kernel configuration - but no other configuration files!
 
-5.  Separated COMPAT_BSDPTY stuff, allowing the COMPAT_60 module to be
-built regardless.
-



CVS commit: [pgoyette-compat] src/sys/kern

2018-09-04 Thread Paul Goyette
Module Name:src
Committed By:   pgoyette
Date:   Tue Sep  4 11:31:12 UTC 2018

Modified Files:
src/sys/kern [pgoyette-compat]: kern_module.c

Log Message:
If loading a built-in module fails, make sure we reset all the stuff
related to its pre-requisite modules.  Otherwise if we try to load it
again we will panic.


To generate a diff of this commit:
cvs rdiff -u -r1.130.2.13 -r1.130.2.14 src/sys/kern/kern_module.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/kern/kern_module.c
diff -u src/sys/kern/kern_module.c:1.130.2.13 src/sys/kern/kern_module.c:1.130.2.14
--- src/sys/kern/kern_module.c:1.130.2.13	Mon Jul  9 08:45:41 2018
+++ src/sys/kern/kern_module.c	Tue Sep  4 11:31:11 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_module.c,v 1.130.2.13 2018/07/09 08:45:41 pgoyette Exp $	*/
+/*	$NetBSD: kern_module.c,v 1.130.2.14 2018/09/04 11:31:11 pgoyette Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: kern_module.c,v 1.130.2.13 2018/07/09 08:45:41 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_module.c,v 1.130.2.14 2018/09/04 11:31:11 pgoyette Exp $");
 
 #define _MODULE_INTERNAL
 
@@ -847,7 +847,7 @@ alloc_required(module_t *mod)
 		areq = mod->mod_arequired + MAXMODDEPS;
 		old = mod->mod_required;
 		new = kmem_zalloc(areq * sizeof(module_t *), KM_SLEEP);
-		for (i = 0; i< mod->mod_arequired; i++)
+		for (i = 0; i < mod->mod_arequired; i++)
 			(*new)[i] = (*old)[i];
 		mod->mod_required = new;
 		if (old)
@@ -912,8 +912,10 @@ module_do_builtin(const module_t *pmod, 
 	/*
 	 * Initialize pre-requisites.
 	 */
+	KASSERT(mod->mod_required == NULL);
+	KASSERT(mod->mod_arequired == 0);
+	KASSERT(mod->mod_nrequired == 0);
 	if (mi->mi_required != NULL) {
-		mod->mod_arequired = 0;
 		for (s = mi->mi_required; *s != '\0'; s = p) {
 			if (*s == ',')
 s++;
@@ -926,8 +928,9 @@ module_do_builtin(const module_t *pmod, 
 break;
 			alloc_required(mod);
 			error = module_do_builtin(mod, buf, , NULL);
-			if (error != 0)
+			if (error != 0) {
 goto fail;
+			}
 			(*mod->mod_required)[mod->mod_nrequired++] = mod2;
 		}
 	}
@@ -973,6 +976,9 @@ module_do_builtin(const module_t *pmod, 
 	if (mod->mod_required)
 		kmem_free(mod->mod_required, mod->mod_arequired *
 		sizeof(module_t *));
+	mod->mod_arequired = 0;
+	mod->mod_nrequired = 0;
+	mod->mod_required = NULL;
 	return error;
 }
 



CVS commit: [pgoyette-compat] src/sys/compat/common

2018-09-04 Thread Paul Goyette
Module Name:src
Committed By:   pgoyette
Date:   Tue Sep  4 11:25:53 UTC 2018

Modified Files:
src/sys/compat/common [pgoyette-compat]: compat_sysv_mod.c

Log Message:
Use correct module names for the aliases.


To generate a diff of this commit:
cvs rdiff -u -r1.4.10.2 -r1.4.10.3 src/sys/compat/common/compat_sysv_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/common/compat_sysv_mod.c
diff -u src/sys/compat/common/compat_sysv_mod.c:1.4.10.2 src/sys/compat/common/compat_sysv_mod.c:1.4.10.3
--- src/sys/compat/common/compat_sysv_mod.c:1.4.10.2	Tue Apr 17 23:06:11 2018
+++ src/sys/compat/common/compat_sysv_mod.c	Tue Sep  4 11:25:53 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: compat_sysv_mod.c,v 1.4.10.2 2018/04/17 23:06:11 pgoyette Exp $	*/
+/*	$NetBSD: compat_sysv_mod.c,v 1.4.10.3 2018/09/04 11:25:53 pgoyette Exp $	*/
 
 /*-
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: compat_sysv_mod.c,v 1.4.10.2 2018/04/17 23:06:11 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: compat_sysv_mod.c,v 1.4.10.3 2018/09/04 11:25:53 pgoyette Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_compat_netbsd.h"
@@ -47,7 +47,7 @@ __KERNEL_RCSID(0, "$NetBSD: compat_sysv_
 #include 
 
 static const char * const compat_sysv_includes[] = {
-"compat_sysv_50", "compat_14", "compat_10", NULL
+"compat_sysv_50", "compat_sysv_14", "compat_sysv_10", NULL
 };
 
 MODULE_WITH_ALIASES(MODULE_CLASS_EXEC, compat_sysv, "sysv_ipc",



CVS commit: src/tools/gcc

2018-09-04 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Tue Sep  4 06:40:37 UTC 2018

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

Log Message:
in configargs.h, as well as normalising to /usr/src, normalise the
--build to the same as the --host, so that it never changes based
upon the host you ran mknative on.  (some recent changes are only
because i updated a system from netbsd-7 to netbsd-8.  this will
avoid that in the future.)


To generate a diff of this commit:
cvs rdiff -u -r1.92 -r1.93 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.92 src/tools/gcc/mknative-gcc:1.93
--- src/tools/gcc/mknative-gcc:1.92	Tue Feb  6 07:04:01 2018
+++ src/tools/gcc/mknative-gcc	Tue Sep  4 06:40:37 2018
@@ -1,5 +1,5 @@
 #!/bin/sh
-#	$NetBSD: mknative-gcc,v 1.92 2018/02/06 07:04:01 mrg Exp $
+#	$NetBSD: mknative-gcc,v 1.93 2018/09/04 06:40:37 mrg Exp $
 #
 # Shell script for generating all the constants needed for a native
 # platform build of gcc.
@@ -369,10 +369,9 @@ __EOF__
 		if [ "${f}" = "configargs" ]
 		then
 			_srcquoted=$(echo "$_SRC" | sed 's/\//\\\//g')
-			ex <<__EOF__ $_OUTDIR/usr.bin/$_subdir/arch/$MACHINE_ARCH/$f.h
-/static const char configuration_arguments/ s/$_srcquoted/\/usr\/src/g
-wq
-__EOF__
+			sed -i -E -e "s,$_srcquoted,/usr/src,g" \
+  -e 's/--build=[^ ]+ --host=([^ ]+)/--build=\1 --host=\1/' \
+$_OUTDIR/usr.bin/$_subdir/arch/$MACHINE_ARCH/$f.h
 		fi
 	done
 



CVS commit: src/external/lgpl3/gmp/lib/libgmp

2018-09-04 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Tue Sep  4 06:09:31 UTC 2018

Modified Files:
src/external/lgpl3/gmp/lib/libgmp: Makefile

Log Message:
add missing sources needed by new mpfr/mpc.


To generate a diff of this commit:
cvs rdiff -u -r1.27 -r1.28 src/external/lgpl3/gmp/lib/libgmp/Makefile

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

Modified files:

Index: src/external/lgpl3/gmp/lib/libgmp/Makefile
diff -u src/external/lgpl3/gmp/lib/libgmp/Makefile:1.27 src/external/lgpl3/gmp/lib/libgmp/Makefile:1.28
--- src/external/lgpl3/gmp/lib/libgmp/Makefile:1.27	Tue Aug 22 09:59:37 2017
+++ src/external/lgpl3/gmp/lib/libgmp/Makefile	Tue Sep  4 06:09:31 2018
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.27 2017/08/22 09:59:37 mrg Exp $
+#	$NetBSD: Makefile,v 1.28 2018/09/04 06:09:31 mrg Exp $
 
 .include 
 
@@ -72,9 +72,12 @@ MPZ_SRCS = \
 	millerrabin.c mod.c mul.c mul_2exp.c		\
 	mul_si.c mul_ui.c\
 	n_pow_ui.c neg.c nextprime.c			\
+	oddfac_1.c	\
 	out_raw.c out_str.c perfpow.c perfsqr.c		\
 	popcount.c pow_ui.c powm.c			\
-	powm_ui.c pprime_p.c random.c random2.c		\
+	powm_ui.c pprime_p.c \
+	prodlimbs.c	\
+	random.c random2.c\
 	realloc.c realloc2.c remove.c			\
 	roinit_n.c	\
 	root.c rootrem.c rrandomb.c scan0.c		\
@@ -125,7 +128,7 @@ SRCS+= 	\
 	mp_bpl.c mp_clz_tab.c mp_dv_tab.c mp_minv_tab.c mp_get_fns.c	\
 	mp_set_fns.c randclr.c randdef.c randiset.c randlc2s.c 	\
 	randlc2x.c randmt.c randmts.c rands.c randsd.c randsdui.c 	\
-	randbui.c randmui.c version.c nextprime.c
+	randbui.c randmui.c version.c nextprime.c primesieve.c
 
 SRCS+=	tal-reent.c
 



CVS commit: src/doc

2018-09-04 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Tue Sep  4 06:05:39 UTC 2018

Modified Files:
src/doc: 3RDPARTY

Log Message:
Update for new mpc and mpfr.


To generate a diff of this commit:
cvs rdiff -u -r1.1561 -r1.1562 src/doc/3RDPARTY

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

Modified files:

Index: src/doc/3RDPARTY
diff -u src/doc/3RDPARTY:1.1561 src/doc/3RDPARTY:1.1562
--- src/doc/3RDPARTY:1.1561	Mon Sep  3 15:32:09 2018
+++ src/doc/3RDPARTY	Tue Sep  4 06:05:39 2018
@@ -1,4 +1,4 @@
-#	$NetBSD: 3RDPARTY,v 1.1561 2018/09/03 15:32:09 christos Exp $
+#	$NetBSD: 3RDPARTY,v 1.1562 2018/09/04 06:05:39 wiz Exp $
 #
 # This file contains a list of the software that has been integrated into
 # NetBSD where we are not the primary maintainer.
@@ -1508,7 +1508,7 @@ Notes:
 3. Carefully check for GPL components leaked into the dist area.
 
 Package:	mpc
-Version:	1.0.3
+Version:	1.1.0
 Current Vers:	1.1.0
 Maintainer:	
 Archive Site:	http://www.multiprecision.org/mpc/download/
@@ -1520,7 +1520,7 @@ Location:	external/lgpl3/mpc/dist
 Notes:
 
 Package:	mpfr
-Version:	3.1.5
+Version:	4.0.1
 Current Vers:	4.0.1
 Maintainer:	
 Archive Site:	http://www.mpfr.org/mpfr-current/